Skip to content

Commit

Permalink
move some unnecessary logs to debug (#1522)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
imjasonh authored Feb 11, 2025
1 parent 47f59ec commit 5a28433
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ _output

# SBOM outputs from apko
sbom-*

.DS_Store
2 changes: 1 addition & 1 deletion internal/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/apk/apk/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apk/apk/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions pkg/build/oci/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/build/types/image_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/types/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions pkg/build/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5a28433

Please sign in to comment.