Skip to content

Commit

Permalink
refactor: remove overly verbose debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <philip.laine@gmail.com>
  • Loading branch information
phillebaba committed Jul 23, 2024
1 parent 05ef439 commit b44d5e7
Show file tree
Hide file tree
Showing 19 changed files with 3 additions and 56 deletions.
2 changes: 0 additions & 2 deletions src/internal/agent/hooks/argocd-application.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ func mutateApplication(ctx context.Context, r *v1.AdmissionRequest, cluster *clu
return nil, fmt.Errorf(lang.ErrUnmarshal, err)
}

message.Debugf("Data %v", string(r.Object.Raw))

patches := []operations.PatchOperation{}

if app.Spec.Source != nil {
Expand Down
3 changes: 0 additions & 3 deletions src/internal/agent/http/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ func (h *Handler) Serve(hook operations.Hook) http.HandlerFunc {
return
}

message.Debug("PATCH: ", string(admissionResponse.Response.Patch))
message.Debug("RESPONSE: ", string(jsonResponse))

message.Infof(lang.AgentInfoWebhookAllowed, r.URL.Path, review.Request.Operation, result.Allowed)
w.WriteHeader(http.StatusOK)
//nolint: errcheck // ignore
Expand Down
5 changes: 0 additions & 5 deletions src/internal/agent/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ import (
"github.com/zarf-dev/zarf/src/internal/agent/hooks"
"github.com/zarf-dev/zarf/src/internal/agent/http/admission"
"github.com/zarf-dev/zarf/src/pkg/cluster"
"github.com/zarf-dev/zarf/src/pkg/message"
)

// NewAdmissionServer creates a http.Server for the mutating webhook admission handler.
func NewAdmissionServer(ctx context.Context, port string) (*http.Server, error) {
message.Debugf("http.NewAdmissionServer(%s)", port)

c, err := cluster.NewCluster()
if err != nil {
return nil, err
Expand Down Expand Up @@ -56,8 +53,6 @@ func NewAdmissionServer(ctx context.Context, port string) (*http.Server, error)

// NewProxyServer creates and returns an http proxy server.
func NewProxyServer(port string) *http.Server {
message.Debugf("http.NewHTTPProxy(%s)", port)

mux := http.NewServeMux()
mux.Handle("/healthz", healthz())
mux.Handle("/", ProxyHandler())
Expand Down
3 changes: 0 additions & 3 deletions src/internal/agent/operations/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"

"github.com/zarf-dev/zarf/src/config/lang"
"github.com/zarf-dev/zarf/src/pkg/message"
admission "k8s.io/api/admission/v1"
)

Expand All @@ -32,8 +31,6 @@ type Hook struct {

// Execute evaluates the request and try to execute the function for operation specified in the request.
func (h *Hook) Execute(r *admission.AdmissionRequest) (*Result, error) {
message.Debugf("operations.Execute(*admission.AdmissionRequest) - %#v , %s/%s: %#v", r.Kind, r.Namespace, r.Name, r.Operation)

switch r.Operation {
case admission.Create:
return wrapperExecution(h.Create, r)
Expand Down
6 changes: 0 additions & 6 deletions src/internal/packager/git/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (

// CheckoutTag performs a `git checkout` of the provided tag to a detached HEAD.
func (g *Git) CheckoutTag(tag string) error {
message.Debugf("git checkout tag %s", tag)

options := &git.CheckoutOptions{
Branch: ParseRef(tag),
}
Expand All @@ -35,8 +33,6 @@ func (g *Git) checkoutRefAsBranch(ref string, branch plumbing.ReferenceName) err
// than checking out to a detached head, checks out to the provided branch ref
// It will delete the branch provided if it exists.
func (g *Git) checkoutTagAsBranch(tag string, branch plumbing.ReferenceName) error {
message.Debugf("git checkout tag %s on %s", tag, branch)

repo, err := git.PlainOpen(g.GitPath)
if err != nil {
return fmt.Errorf("not a valid git repo or unable to open: %w", err)
Expand All @@ -54,8 +50,6 @@ func (g *Git) checkoutTagAsBranch(tag string, branch plumbing.ReferenceName) err
// with the provided hash
// It will delete the branch provided if it exists.
func (g *Git) checkoutHashAsBranch(hash plumbing.Hash, branch plumbing.ReferenceName) error {
message.Debugf("git checkout hash %s on %s", hash, branch)

repo, err := git.PlainOpen(g.GitPath)
if err != nil {
return fmt.Errorf("not a valid git repo or unable to open: %w", err)
Expand Down
2 changes: 0 additions & 2 deletions src/internal/packager/git/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type CreateTokenResponse struct {

// CreateReadOnlyUser uses the Gitea API to create a non-admin Zarf user.
func (g *Git) CreateReadOnlyUser(ctx context.Context) error {
message.Debugf("git.CreateReadOnlyUser()")

c, err := cluster.NewCluster()
if err != nil {
return err
Expand Down
10 changes: 2 additions & 8 deletions src/internal/packager/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) {
histClient := action.NewHistory(h.actionConfig)
tryHelm := func() error {
var err error
var output *release.Release

releases, histErr := histClient.Run(h.chart.ReleaseName)

Expand All @@ -70,14 +69,14 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) {
// No prior release, try to install it.
spinner.Updatef("Attempting chart installation")

output, err = h.installChart(postRender)
_, err = h.installChart(postRender)
} else if histErr == nil && len(releases) > 0 {
// Otherwise, there is a prior release so upgrade it.
spinner.Updatef("Attempting chart upgrade")

lastRelease := releases[len(releases)-1]

output, err = h.upgradeChart(lastRelease, postRender)
_, err = h.upgradeChart(lastRelease, postRender)
} else {
// 😭 things aren't working
return fmt.Errorf("unable to verify the chart installation status: %w", histErr)
Expand All @@ -87,7 +86,6 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) {
return err
}

message.Debug(output.Info.Description)
spinner.Success()
return nil
}
Expand Down Expand Up @@ -127,7 +125,6 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) {

// TemplateChart generates a helm template from a given chart.
func (h *Helm) TemplateChart() (manifest string, chartValues chartutil.Values, err error) {
message.Debugf("helm.TemplateChart()")
spinner := message.NewProgressSpinner("Templating helm chart %s", h.chart.Name)
defer spinner.Stop()

Expand Down Expand Up @@ -323,7 +320,6 @@ func (h *Helm) upgradeChart(lastRelease *release.Release, postRender *renderer)
}

func (h *Helm) rollbackChart(name string, version int) error {
message.Debugf("helm.rollbackChart(%s)", name)
client := action.NewRollback(h.actionConfig)
client.CleanupOnFail = true
client.Force = true
Expand All @@ -334,7 +330,6 @@ func (h *Helm) rollbackChart(name string, version int) error {
}

func (h *Helm) uninstallChart(name string) (*release.UninstallReleaseResponse, error) {
message.Debugf("helm.uninstallChart(%s)", name)
client := action.NewUninstall(h.actionConfig)
client.KeepHistory = false
client.Wait = true
Expand All @@ -343,7 +338,6 @@ func (h *Helm) uninstallChart(name string) (*release.UninstallReleaseResponse, e
}

func (h *Helm) loadChartData() (*chart.Chart, chartutil.Values, error) {
message.Debugf("helm.loadChartData()")
var (
loadedChart *chart.Chart
chartValues chartutil.Values
Expand Down
2 changes: 0 additions & 2 deletions src/internal/packager/helm/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package helm
import (
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/goccy/go-yaml"
"github.com/zarf-dev/zarf/src/pkg/message"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
)
Expand Down Expand Up @@ -45,7 +44,6 @@ func FindAnnotatedImagesForChart(chartPath string, values chartutil.Values) (ima
// Only include the image if the current values/condition specify it should be included
if i.Condition != "" {
value, err := values.PathValue(i.Condition)
message.Debugf("%#v - %#v - %#v\n", value, i.Condition, err)
// We intentionally ignore the error here because the key could be missing from the values.yaml
if err == nil && value == true {
images = append(images, i.Image)
Expand Down
2 changes: 0 additions & 2 deletions src/internal/packager/helm/post-render.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type renderer struct {
}

func (h *Helm) newRenderer() (*renderer, error) {
message.Debugf("helm.NewRenderer()")

rend := &renderer{
Helm: h,
connectStrings: types.ConnectStrings{},
Expand Down
2 changes: 0 additions & 2 deletions src/internal/packager/images/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func Push(ctx context.Context, cfg PushConfig) error {
return err
}

message.Debugf("push %s -> %s)", refInfo.Reference, offlineNameCRC)

if err = pushImage(img, offlineNameCRC); err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/cluster/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ func (c *Cluster) checkForZarfConnectLabel(ctx context.Context, name string) (Tu
var err error
var zt TunnelInfo

message.Debugf("Looking for a Zarf Connect Label in the cluster")

selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{
ZarfConnectLabelName: name,
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/packager/creator/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package creator
import (
"context"

"github.com/zarf-dev/zarf/src/pkg/message"
"github.com/zarf-dev/zarf/src/pkg/packager/composer"
"github.com/zarf-dev/zarf/src/types"
)
Expand Down Expand Up @@ -37,7 +36,6 @@ func ComposeComponents(ctx context.Context, pkg types.ZarfPackage, flavor string
if err != nil {
return types.ZarfPackage{}, nil, err
}
message.Debugf("%s", chain)

// migrate any deprecated component configurations now
warning := chain.Migrate(pkg.Build)
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/packager/creator/normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ func (pc *PackageCreator) addComponent(ctx context.Context, component types.Zarf
}

for filesIdx, file := range component.Files {
message.Debugf("Loading %#v", file)

rel := filepath.Join(layout.FilesDir, strconv.Itoa(filesIdx), filepath.Base(file.Target))
dst := filepath.Join(componentPaths.Base, rel)
destinationDir := filepath.Dir(dst)
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/packager/creator/skeleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ func (sc *SkeletonCreator) addComponent(component types.ZarfComponent, dst *layo
}

for filesIdx, file := range component.Files {
message.Debugf("Loading %#v", file)

if helpers.IsURL(file.Source) {
continue
}
Expand Down
3 changes: 1 addition & 2 deletions src/pkg/packager/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ func (p *Packager) findImages(ctx context.Context) (imgMap map[string][]string,
}

// Break the manifest into separate resources
contentString := string(contents)
message.Debugf("%s", contentString)
// TODO: Do not dogsled error
yamls, _ := utils.SplitYAML(contents)
resources = append(resources, yamls...)

Expand Down
3 changes: 0 additions & 3 deletions src/pkg/packager/sources/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/defenseunicorns/pkg/oci"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/pkg/layout"
"github.com/zarf-dev/zarf/src/pkg/message"
"github.com/zarf-dev/zarf/src/pkg/packager/filters"
"github.com/zarf-dev/zarf/src/pkg/zoci"
"github.com/zarf-dev/zarf/src/types"
Expand Down Expand Up @@ -85,7 +84,5 @@ func New(pkgOpts *types.ZarfPackageOptions) (PackageSource, error) {
return nil, fmt.Errorf("could not identify source type for %q", pkgSrc)
}

message.Debugf("Using %T for %q", source, pkgSrc)

return source, nil
}
2 changes: 0 additions & 2 deletions src/pkg/packager/sources/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type OCISource struct {

// LoadPackage loads a package from an OCI registry.
func (s *OCISource) LoadPackage(ctx context.Context, dst *layout.PackagePaths, filter filters.ComponentFilterStrategy, unarchiveAll bool) (pkg types.ZarfPackage, warnings []string, err error) {
message.Debugf("Loading package from %q", s.PackageSource)

pkg, err = s.FetchZarfYAML(ctx)
if err != nil {
return pkg, nil, err
Expand Down
5 changes: 0 additions & 5 deletions src/pkg/utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/pkg/message"
)

const (
Expand All @@ -25,14 +24,10 @@ func MakeTempDir(basePath string) (string, error) {
return "", err
}
}

tmp, err := os.MkdirTemp(basePath, tmpPathPrefix)
if err != nil {
return "", err
}

message.Debug("Using temporary directory:", tmp)

return tmp, nil
}

Expand Down
1 change: 0 additions & 1 deletion src/pkg/utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func parseChecksum(src string) (string, string, error) {

// DownloadToFile downloads a given URL to the target filepath (including the cosign key if necessary).
func DownloadToFile(src string, dst string, cosignKeyPath string) (err error) {
message.Debugf("Downloading %s to %s", src, dst)
// check if the parsed URL has a checksum
// if so, remove it and use the checksum to validate the file
src, checksum, err := parseChecksum(src)
Expand Down

0 comments on commit b44d5e7

Please sign in to comment.