From 5a28433ca17a09ac879dbeee31c33e984e6133c0 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 11 Feb 2025 10:06:36 -0600 Subject: [PATCH] move some unnecessary logs to debug (#1522) - don't log requests to `apk-configuration` - don't log what architectures we're building for by default - don't log what apk repositories we're using by default - don't log "skipping local tagging" which isn't warn-worthy or even debug-worthy (we always do this) - deprecate some stuff we don't use and shouldn't recommend --------- Signed-off-by: Jason Hall --- .gitignore | 2 ++ internal/cli/build.go | 2 +- pkg/apk/apk/implementation.go | 1 + pkg/apk/apk/repo.go | 2 +- pkg/build/oci/publish.go | 4 +--- pkg/build/options.go | 2 +- pkg/build/types/image_configuration.go | 4 +++- pkg/build/types/schema.json | 2 +- pkg/build/types/types.go | 2 ++ 9 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index bc27f8314..a728f1786 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ _output # SBOM outputs from apko sbom-* + +.DS_Store diff --git a/internal/cli/build.go b/internal/cli/build.go index 69380aa4f..d3dbc6c75 100644 --- a/internal/cli/build.go +++ b/internal/cli/build.go @@ -206,7 +206,7 @@ func buildImageComponents(ctx context.Context, workDir string, archs []types.Arc ic.Archs = types.AllArchs } // save the final set we will build - log.Infof("Building images for %d architectures: %+v", len(ic.Archs), ic.Archs) + log.Debugf("Building images for %d architectures: %+v", len(ic.Archs), ic.Archs) // Probe the VCS URL if it is not set and we are asked to do so. if o.WithVCS && ic.VCSUrl == "" { diff --git a/pkg/apk/apk/implementation.go b/pkg/apk/apk/implementation.go index 26cdb81db..5eeb20159 100644 --- a/pkg/apk/apk/implementation.go +++ b/pkg/apk/apk/implementation.go @@ -851,6 +851,7 @@ func DiscoverKeys(ctx context.Context, client *http.Client, auth auth.Authentica rc := retryablehttp.NewClient() rc.HTTPClient = client + rc.Logger = clog.FromContext(ctx) discoveryResponse, err := rc.StandardClient().Do(discoveryRequest) if err != nil { return nil, fmt.Errorf("failed to perform key discovery: %w", err) diff --git a/pkg/apk/apk/repo.go b/pkg/apk/apk/repo.go index dc4afe700..d1cc54c79 100644 --- a/pkg/apk/apk/repo.go +++ b/pkg/apk/apk/repo.go @@ -105,7 +105,7 @@ func (a *APK) SetRepositories(ctx context.Context, repos []string) error { ctx, span := otel.Tracer("go-apk").Start(ctx, "SetRepositories") defer span.End() - clog.InfoContextf(ctx, "setting apk repositories: %v", repos) + clog.DebugContextf(ctx, "setting apk repositories: %v", repos) if len(repos) == 0 { return fmt.Errorf("must provide at least one repository") diff --git a/pkg/build/oci/publish.go b/pkg/build/oci/publish.go index bfec28954..671bb37c7 100644 --- a/pkg/build/oci/publish.go +++ b/pkg/build/oci/publish.go @@ -56,9 +56,7 @@ func LoadImage(ctx context.Context, image oci.SignedImage, tags []string) (name. if err != nil { return name.Digest{}, err } - if strings.HasPrefix(localSrcTag.Name(), fmt.Sprintf("%s/", LocalDomain)) { - log.Warnf("skipping local domain tagging %s as %s", localSrcTag.Name(), localDstTag.Name()) - } else { + if !strings.HasPrefix(localSrcTag.Name(), fmt.Sprintf("%s/", LocalDomain)) { log.Infof("tagging local image %s as %s", localSrcTag.Name(), localDstTag.Name()) if err := daemon.Tag(localSrcTag, localDstTag, daemon.WithContext(ctx)); err != nil { return name.Digest{}, err diff --git a/pkg/build/options.go b/pkg/build/options.go index 889f0dc82..6a86a9d8c 100644 --- a/pkg/build/options.go +++ b/pkg/build/options.go @@ -44,7 +44,7 @@ func WithConfig(configFile string, includePaths []string) Option { var ic types.ImageConfiguration hasher := sha2562.New() - if err := ic.Load(ctx, configFile, includePaths, hasher); err != nil { + if err := ic.Load(ctx, configFile, includePaths, hasher); err != nil { //nolint:staticcheck return fmt.Errorf("failed to load image configuration: %w", err) } diff --git a/pkg/build/types/image_configuration.go b/pkg/build/types/image_configuration.go index 36c8497d5..b6b6f5358 100644 --- a/pkg/build/types/image_configuration.go +++ b/pkg/build/types/image_configuration.go @@ -45,7 +45,7 @@ func (ic *ImageConfiguration) ProbeVCSUrl(ctx context.Context, imageConfigPath s if url != "" { ic.VCSUrl = url - log.Infof("detected %s as VCS URL", ic.VCSUrl) + log.Debugf("detected %s as VCS URL", ic.VCSUrl) } } @@ -179,6 +179,8 @@ func (ic *ImageConfiguration) readLocal(imageconfigPath string, includePaths []s // Load - loads an image configuration given a configuration file path. // Populates configHasher with the configuration data loaded from the imageConfigPath and the other referenced files. // You can pass any dummy hasher (like fnv.New32()), if you don't care about the hash of the configuration. +// +// Deprecated: This will be removed in a future release. func (ic *ImageConfiguration) Load(ctx context.Context, imageConfigPath string, includePaths []string, configHasher hash.Hash) error { data, err := ic.readLocal(imageConfigPath, includePaths) if err != nil { diff --git a/pkg/build/types/schema.json b/pkg/build/types/schema.json index 088c4c548..6ba79e701 100644 --- a/pkg/build/types/schema.json +++ b/pkg/build/types/schema.json @@ -122,7 +122,7 @@ }, "include": { "type": "string", - "description": "Optional: Path to a local file containing additional image configuration\n\nThe included configuration is deep merged with the parent configuration" + "description": "Optional: Path to a local file containing additional image configuration\n\nThe included configuration is deep merged with the parent configuration\n\nDeprecated: This will be removed in a future release." }, "volumes": { "items": { diff --git a/pkg/build/types/types.go b/pkg/build/types/types.go index c4869abed..cb5b51b6a 100644 --- a/pkg/build/types/types.go +++ b/pkg/build/types/types.go @@ -181,6 +181,8 @@ type ImageConfiguration struct { // Optional: Path to a local file containing additional image configuration // // The included configuration is deep merged with the parent configuration + // + // Deprecated: This will be removed in a future release. Include string `json:"include,omitempty" yaml:"include,omitempty"` // Optional: A list of volumes to configure