Skip to content

Commit

Permalink
chore: add logger to packager2 Remove (#3151)
Browse files Browse the repository at this point in the history
Signed-off-by: Kit Patella <[email protected]>
  • Loading branch information
mkcp authored Oct 28, 2024
1 parent 1605d80 commit affdb5b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/internal/packager2/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"errors"
"fmt"
"github.com/zarf-dev/zarf/src/pkg/logger"
"slices"

"helm.sh/helm/v3/pkg/action"
Expand All @@ -33,6 +34,7 @@ type RemoveOptions struct {

// Remove removes a package that was already deployed onto a cluster, uninstalling all installed helm charts.
func Remove(ctx context.Context, opt RemoveOptions) error {
l := logger.From(ctx)
pkg, err := packageFromSourceOrCluster(ctx, opt.Cluster, opt.Source, opt.SkipSignatureValidation, opt.PublicKeyPath)
if err != nil {
return err
Expand Down Expand Up @@ -109,6 +111,7 @@ func Remove(ctx context.Context, opt RemoveOptions) error {
}
if errors.Is(err, driver.ErrReleaseNotFound) {
message.Warnf("Helm release for helm chart '%s' in the namespace '%s' was not found. Was it already removed?", chart.ChartName, chart.Namespace)
l.Warn("helm release was not found. was it already removed?", "name", chart.ChartName, "namespace", chart.Namespace)
}

// Pop the removed helm chart from the installed charts slice.
Expand All @@ -119,6 +122,7 @@ func Remove(ctx context.Context, opt RemoveOptions) error {
if err != nil {
// We warn and ignore errors because we may have removed the cluster that this package was inside of
message.Warnf("Unable to update the secret for package %s, this may be normal if the cluster was removed: %s", depPkg.Name, err.Error())
l.Warn("unable to update secret for package, this may be normal if the cluster was removed", "pkgName", depPkg.Name, "error", err.Error())
}
}
}
Expand All @@ -139,6 +143,7 @@ func Remove(ctx context.Context, opt RemoveOptions) error {
if err != nil {
// We warn and ignore errors because we may have removed the cluster that this package was inside of
message.Warnf("Unable to update the secret for package %s, this may be normal if the cluster was removed: %s", depPkg.Name, err.Error())
l.Warn("unable to update secret package, this may be normal if the cluster was removed", "pkgName", depPkg.Name, "error", err.Error())
}
}
return nil
Expand All @@ -157,6 +162,7 @@ func Remove(ctx context.Context, opt RemoveOptions) error {
err := opt.Cluster.DeleteDeployedPackage(ctx, depPkg.Name)
if err != nil {
message.Warnf("Unable to delete the secret for package %s, this may be normal if the cluster was removed: %s", depPkg.Name, err.Error())
l.Warn("unable to delete secret for package, this may be normal if the cluster was removed", "pkgName", depPkg.Name, "error", err.Error())
}
}

Expand Down

0 comments on commit affdb5b

Please sign in to comment.