From c7cecd0c5e64dd2ad37a6be0b3eb06514c9f610a Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Wed, 20 Nov 2024 17:16:06 -0800 Subject: [PATCH 1/2] add logger lines to packager.Publish and remove stderr text check from e2e test Signed-off-by: Kit Patella --- src/pkg/packager/publish.go | 12 ++++++++++++ src/test/e2e/50_oci_publish_deploy_test.go | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pkg/packager/publish.go b/src/pkg/packager/publish.go index 34c54bd546..2cb8e64ab6 100644 --- a/src/pkg/packager/publish.go +++ b/src/pkg/packager/publish.go @@ -9,6 +9,7 @@ import ( "fmt" "os" "strings" + "time" "github.com/defenseunicorns/pkg/helpers/v2" "github.com/defenseunicorns/pkg/oci" @@ -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" @@ -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 @@ -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) // Publish the package/skeleton to the registry if err := remote.PublishPackage(ctx, &p.cfg.Pkg, p.layout, config.CommonOptions.OCIConcurrency); err != nil { @@ -123,5 +130,10 @@ func (p *Packager) Publish(ctx context.Context) (err error) { return err } } + l.Info("packaged successfully published", + "name", p.cfg.Pkg.Metadata.Name, + "ref", ref, + "duration", time.Since(start), + ) return nil } diff --git a/src/test/e2e/50_oci_publish_deploy_test.go b/src/test/e2e/50_oci_publish_deploy_test.go index 4c2e250551..921c127deb 100644 --- a/src/test/e2e/50_oci_publish_deploy_test.go +++ b/src/test/e2e/50_oci_publish_deploy_test.go @@ -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) // Pull the package via OCI. stdOut, stdErr, err = e2e.Zarf(suite.T(), "package", "pull", "oci://"+ref+"/helm-charts:0.0.1", "--plain-http") From daeb177b821c3ed8addd7275998abc2ad3b8be25 Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Thu, 21 Nov 2024 08:26:59 -0800 Subject: [PATCH 2/2] remove double print in packager.Publish Signed-off-by: Kit Patella --- src/pkg/packager/publish.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pkg/packager/publish.go b/src/pkg/packager/publish.go index 2cb8e64ab6..34e56b2a9d 100644 --- a/src/pkg/packager/publish.go +++ b/src/pkg/packager/publish.go @@ -107,7 +107,6 @@ 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) // Publish the package/skeleton to the registry if err := remote.PublishPackage(ctx, &p.cfg.Pkg, p.layout, config.CommonOptions.OCIConcurrency); err != nil {