Skip to content

Commit

Permalink
minor improvements, tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissgyulev committed Oct 10, 2022
1 parent da46f3b commit a3c985f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/chart/dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestUpdateRequirementsFile(t *testing.T) {

chartPath := newChartPath(t, "../../testdata/kafka-10.3.3.tgz", "kafka")
requirementsFile := path.Join(chartPath, RequirementsFilename)
if err := updateRequirementsFile(chartPath, lock, source.GetRepo(), target.GetRepo()); err != nil {
if err := updateRequirementsFile(chartPath, lock, source.GetRepo(), target.GetRepo(), false); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -163,7 +163,7 @@ func TestUpdateChartMetadataFile(t *testing.T) {
t.Fatal(err)
}

if err := updateChartMetadataFile(chartPath, lock, source.GetRepo(), target.GetRepo()); err != nil {
if err := updateChartMetadataFile(chartPath, lock, source.GetRepo(), target.GetRepo(), false); err != nil {
t.Fatal(err)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/syncer/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ func (s *Syncer) processVersion(name, version string, publishingThreshold time.T
return nil
}

if err := s.loadChart(name, version, ""); err != nil {
if err := s.loadChart(name, version, "", false); err != nil {
klog.Errorf("unable to load %q chart: %v", id, err)
return err
}
return nil
}

// loadChart loads a chart in the chart index map
func (s *Syncer) loadChart(name string, version string, repository string) error {
func (s *Syncer) loadChart(name string, version string, repository string, isDep bool) error {
id := fmt.Sprintf("%s-%s", name, version)
// loadChart is a recursive function and it will be invoked again for each
// dependency.
Expand Down Expand Up @@ -202,8 +202,8 @@ func (s *Syncer) loadChart(name string, version string, repository string) error
//main source repo client
client := s.cli.src

//in case of dependency - switch to deps client (also includes main client - for deps in the Source repo)
if repository != "" {
//in case of dependency - switch to deps client, but only if there is a valid entry for the current repo
if isDep && len(s.cli.deps) > 0 && s.cli.deps[repository] != nil {
client = s.cli.deps[repository]
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func (s *Syncer) loadChart(name string, version string, repository string) error
var errs error
for _, dep := range deps {
depID := fmt.Sprintf("%s-%s", dep.Name, dep.Version)
if err := s.loadChart(dep.Name, dep.Version, dep.Repository); err != nil {
if err := s.loadChart(dep.Name, dep.Version, dep.Repository, true); err != nil {
errs = multierror.Append(errs, errors.Annotatef(err, "invalid %q chart dependency", depID))
continue
}
Expand Down

0 comments on commit a3c985f

Please sign in to comment.