Skip to content

Commit

Permalink
corrected rangeValCopy linter error (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdob authored Aug 27, 2024
1 parent 9a1ebc4 commit b184f7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
15 changes: 7 additions & 8 deletions pkg/image/validation/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ func validateHelm(k8s *image.Kubernetes, valuesDir, certsDir string) []FailedVal
}

seenHelmRepos := make(map[string]bool)
for _, chart := range k8s.Helm.Charts {
c := chart
failures = append(failures, validateChart(&c, helmRepositoryNames, valuesDir)...)
for i := range k8s.Helm.Charts {
failures = append(failures, validateChart(&k8s.Helm.Charts[i], helmRepositoryNames, valuesDir)...)

seenHelmRepos[chart.RepositoryName] = true
seenHelmRepos[k8s.Helm.Charts[i].RepositoryName] = true
}

for _, repo := range k8s.Helm.Repositories {
Expand Down Expand Up @@ -405,12 +404,12 @@ func validateHelmChartValues(chartName, valuesFile, valuesDir string) string {
func validateHelmChartDuplicates(charts []image.HelmChart) string {
seenHelmCharts := make(map[string]bool)

for _, chart := range charts {
if _, exists := seenHelmCharts[chart.Name]; exists {
return fmt.Sprintf("The 'helmCharts' field contains duplicate entries: %s", chart.Name)
for i := range charts {
if _, exists := seenHelmCharts[charts[i].Name]; exists {
return fmt.Sprintf("The 'helmCharts' field contains duplicate entries: %s", charts[i].Name)
}

seenHelmCharts[chart.Name] = true
seenHelmCharts[charts[i].Name] = true
}

return ""
Expand Down
20 changes: 9 additions & 11 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,19 @@ func storeHelmCharts(ctx *image.Context, helmClient helmClient) ([]*helmChart, e

var charts []*helmChart

for _, chart := range helm.Charts {
c := chart
repository, ok := chartRepositories[c.RepositoryName]
for i := range helm.Charts {
repository, ok := chartRepositories[helm.Charts[i].RepositoryName]
if !ok {
return nil, fmt.Errorf("repository not found for chart %s", c.Name)
return nil, fmt.Errorf("repository not found for chart %s", helm.Charts[i].Name)
}

localPath, err := downloadChart(helmClient, &c, repository, helmDir)
localPath, err := downloadChart(helmClient, &helm.Charts[i], repository, helmDir)
if err != nil {
return nil, fmt.Errorf("downloading chart: %w", err)
}

charts = append(charts, &helmChart{
HelmChart: c,
HelmChart: helm.Charts[i],
localPath: localPath,
repositoryURL: repository.URL,
})
Expand All @@ -149,11 +148,10 @@ func storeHelmCharts(ctx *image.Context, helmClient helmClient) ([]*helmChart, e
func mapChartsToRepos(helm *image.Helm) map[string]*image.HelmRepository {
chartRepoMap := make(map[string]*image.HelmRepository)

for _, chart := range helm.Charts {
for _, repo := range helm.Repositories {
if chart.RepositoryName == repo.Name {
r := repo
chartRepoMap[chart.RepositoryName] = &r
for i := range helm.Charts {
for j := range helm.Repositories {
if helm.Charts[i].RepositoryName == helm.Repositories[j].Name {
chartRepoMap[helm.Charts[i].RepositoryName] = &helm.Repositories[j]
}
}
}
Expand Down

0 comments on commit b184f7c

Please sign in to comment.