Skip to content

Commit

Permalink
refactor: replace debug logs with returning errors
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <[email protected]>
  • Loading branch information
phillebaba committed Aug 2, 2024
1 parent 5e77e38 commit 2991b01
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var connectCmd = &cobra.Command{
} else {
spinner.Updatef(lang.CmdConnectEstablishedWeb, tunnel.FullURL())
if err := exec.LaunchURL(tunnel.FullURL()); err != nil {
message.Debug(err)
return err
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/pkg/cluster/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ func (c *Cluster) RecordPackageDeploymentAndWait(ctx context.Context, pkg types.
func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg types.ZarfPackage, components []types.DeployedComponent, connectStrings types.ConnectStrings, generation int) (deployedPackage *types.DeployedPackage, err error) {
packageName := pkg.Metadata.Name

// Attempt to load information about webhooks for the package
// Optionally try to get information about webhooks for the package.
var componentWebhooks map[string]map[string]types.Webhook
existingPackageSecret, err := c.GetDeployedPackage(ctx, packageName)
if err != nil {
message.Debugf("Unable to fetch existing secret for package '%s': %s", packageName, err.Error())
if err != nil && !kerrors.IsNotFound(err) {
return nil, err
}
if existingPackageSecret != nil {
componentWebhooks = existingPackageSecret.ComponentWebhooks
Expand Down
15 changes: 7 additions & 8 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (p *Packager) deployComponents(ctx context.Context) (deployedComponents []t
if p.isConnectedToCluster() {
deployedComponent.InstalledCharts, err = p.cluster.GetInstalledChartsForComponent(ctx, p.cfg.Pkg.Metadata.Name, component)
if err != nil {
message.Debugf("Unable to fetch installed Helm charts for component '%s': %s", component.Name, err.Error())
return nil, err
}
}

Expand All @@ -178,7 +178,7 @@ func (p *Packager) deployComponents(ctx context.Context) (deployedComponents []t
// Update the package secret to indicate that we are attempting to deploy this component
if p.isConnectedToCluster() {
if _, err := p.cluster.RecordPackageDeploymentAndWait(ctx, p.cfg.Pkg, deployedComponents, p.connectStrings, p.generation, component, p.cfg.DeployOpts.SkipWebhooks); err != nil {
message.Debugf("Unable to record package deployment for component %s: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
return nil, err
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ func (p *Packager) deployComponents(ctx context.Context) (deployedComponents []t
deployedComponents[idx].Status = types.ComponentStatusFailed
if p.isConnectedToCluster() {
if _, err := p.cluster.RecordPackageDeploymentAndWait(ctx, p.cfg.Pkg, deployedComponents, p.connectStrings, p.generation, component, p.cfg.DeployOpts.SkipWebhooks); err != nil {
message.Debugf("Unable to record package deployment for component %q: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
return nil, err
}
}

Expand All @@ -218,7 +218,7 @@ func (p *Packager) deployComponents(ctx context.Context) (deployedComponents []t
deployedComponents[idx].Status = types.ComponentStatusSucceeded
if p.isConnectedToCluster() {
if _, err := p.cluster.RecordPackageDeploymentAndWait(ctx, p.cfg.Pkg, deployedComponents, p.connectStrings, p.generation, component, p.cfg.DeployOpts.SkipWebhooks); err != nil {
message.Debugf("Unable to record package deployment for component %q: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
return nil, err
}
}

Expand Down Expand Up @@ -312,10 +312,9 @@ func (p *Packager) deployComponent(ctx context.Context, component types.ZarfComp
// Disable the registry HPA scale down if we are deploying images and it is not already disabled
if hasImages && !p.hpaModified && p.state.RegistryInfo.InternalRegistry {
if err := p.cluster.DisableRegHPAScaleDown(ctx); err != nil {
message.Debugf("unable to disable the registry HPA scale down: %s", err.Error())
} else {
p.hpaModified = true
return nil, fmt.Errorf("unable to dsable the registry HPA scale down: %w", err)
}
p.hpaModified = true
}
}

Expand Down Expand Up @@ -407,7 +406,7 @@ func (p *Packager) processComponentFiles(component types.ZarfComponent, pkgLocat
// Check if the file looks like a text file
isText, err := helpers.IsTextFile(subFile)
if err != nil {
message.Debugf("unable to determine if file %s is a text file: %s", subFile, err)
return err
}

// If the file is a text file, template it
Expand Down

0 comments on commit 2991b01

Please sign in to comment.