Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logger to packager.Publish #3259

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/pkg/packager/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"strings"
"time"

"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/pkg/oci"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/zarf-dev/zarf/src/api/v1alpha1"
"github.com/zarf-dev/zarf/src/config"
"github.com/zarf-dev/zarf/src/pkg/layout"
"github.com/zarf-dev/zarf/src/pkg/logger"
"github.com/zarf-dev/zarf/src/pkg/message"
"github.com/zarf-dev/zarf/src/pkg/packager/creator"
"github.com/zarf-dev/zarf/src/pkg/packager/filters"
Expand All @@ -27,6 +29,10 @@ import (

// Publish publishes the package to a registry
func (p *Packager) Publish(ctx context.Context) (err error) {
l := logger.From(ctx)
start := time.Now()
l.Debug("start publish")

_, isOCISource := p.source.(*sources.OCISource)
if isOCISource && p.cfg.PublishOpts.SigningKeyPath == "" {
// oci --> oci is a special case, where we will use oci.CopyPackage so that we can transfer the package
Expand Down Expand Up @@ -101,6 +107,7 @@ func (p *Packager) Publish(ctx context.Context) (err error) {
}

message.HeaderInfof("📦 PACKAGE PUBLISH %s:%s", p.cfg.Pkg.Metadata.Name, ref)
l.Info("publishing package", "name", p.cfg.Pkg.Metadata.Name, "ref", ref)
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved

// Publish the package/skeleton to the registry
if err := remote.PublishPackage(ctx, &p.cfg.Pkg, p.layout, config.CommonOptions.OCIConcurrency); err != nil {
Expand All @@ -123,5 +130,10 @@ func (p *Packager) Publish(ctx context.Context) (err error) {
return err
}
}
l.Info("packaged successfully published",
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved
"name", p.cfg.Pkg.Metadata.Name,
"ref", ref,
"duration", time.Since(start),
)
return nil
}
1 change: 0 additions & 1 deletion src/test/e2e/50_oci_publish_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (suite *PublishDeploySuiteTestSuite) Test_0_Publish() {
ref := suite.Reference.String()
stdOut, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", example, "oci://"+ref, "--plain-http")
suite.NoError(err, stdOut, stdErr)
suite.Contains(stdErr, "Published "+ref)
mkcp marked this conversation as resolved.
Show resolved Hide resolved

// Pull the package via OCI.
stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "--plain-http")
Expand Down