Skip to content

Commit

Permalink
chore(warehouse): enrich helm discovery logs
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
  • Loading branch information
hiddeco committed May 17, 2024
1 parent d07d037 commit 6d870a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/controller/warehouses/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,46 @@ func (r *reconciler) discoverCharts(
logger.Debug("found no credentials for chart repo")
}

// Enrich the logger with additional fields for this subscription.
if sub.SemverConstraint != "" {
logger = logger.WithField("semverConstraint", sub.SemverConstraint)
}

// Discover versions of the chart based on the semver constraint.
versions, err := r.discoverChartVersionsFn(ctx, sub.RepoURL, sub.Name, sub.SemverConstraint, helmCreds)
if err != nil {
if sub.Name == "" {
return nil, fmt.Errorf(
"error discovering latest suitable chart versions in repository %q: %w",
"error discovering latest chart versions in repository %q: %w",
sub.RepoURL,
err,
)
}
return nil, fmt.Errorf(
"error discovering latest suitable chart versions for chart %q in repository %q: %w",
"error discovering latest chart versions for chart %q in repository %q: %w",
sub.Name,
sub.RepoURL,
err,
)
}

if len(versions) == 0 {
logger.Debug("discovered no suitable chart versions")
results = append(results, kargoapi.ChartDiscoveryResult{
RepoURL: sub.RepoURL,
Name: sub.Name,
SemverConstraint: sub.SemverConstraint,
})
logger.Debug("discovered no chart versions")
continue
}

logger.Debugf("discovered %d suitable chart versions", len(versions))
results = append(results, kargoapi.ChartDiscoveryResult{
RepoURL: sub.RepoURL,
Name: sub.Name,
SemverConstraint: sub.SemverConstraint,
Versions: trimSlice(versions, 20),
})
logger.Debugf("discovered %d chart versions", len(versions))
}

return results, nil
Expand Down

0 comments on commit 6d870a7

Please sign in to comment.