From 86e2d18f5eed1d8c3df6816ed9e5bf0d04ca9d66 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 9 Dec 2024 17:57:56 +0000 Subject: [PATCH] fix packager context passing Signed-off-by: Austin Abro --- src/cmd/dev.go | 6 +++--- src/cmd/initialize.go | 2 +- src/cmd/package.go | 4 ++-- src/pkg/packager/common.go | 1 + src/types/packager.go | 6 ------ 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cmd/dev.go b/src/cmd/dev.go index c7471d72ca..3dcfe51fb9 100644 --- a/src/cmd/dev.go +++ b/src/cmd/dev.go @@ -57,7 +57,7 @@ var devDeployCmd = &cobra.Command{ pkgConfig.PkgOpts.SetVariables = helpers.TransformAndMergeMap( v.GetStringMapString(common.VPkgDeploySet), pkgConfig.PkgOpts.SetVariables, strings.ToUpper) - pkgClient, err := packager.New(&pkgConfig) + pkgClient, err := packager.New(&pkgConfig, packager.WithContext(ctx)) if err != nil { return err } @@ -87,7 +87,7 @@ var devGenerateCmd = &cobra.Command{ pkgConfig.CreateOpts.BaseDir = "." pkgConfig.FindImagesOpts.RepoHelmChartPath = pkgConfig.GenerateOpts.GitPath - pkgClient, err := packager.New(&pkgConfig) + pkgClient, err := packager.New(&pkgConfig, packager.WithContext(cmd.Context())) if err != nil { return err } @@ -252,7 +252,7 @@ var devFindImagesCmd = &cobra.Command{ v.GetStringMapString(common.VPkgCreateSet), pkgConfig.CreateOpts.SetVariables, strings.ToUpper) pkgConfig.PkgOpts.SetVariables = helpers.TransformAndMergeMap( v.GetStringMapString(common.VPkgDeploySet), pkgConfig.PkgOpts.SetVariables, strings.ToUpper) - pkgClient, err := packager.New(&pkgConfig) + pkgClient, err := packager.New(&pkgConfig, packager.WithContext(cmd.Context())) if err != nil { return err } diff --git a/src/cmd/initialize.go b/src/cmd/initialize.go index d2fe5d5d35..c946752d23 100644 --- a/src/cmd/initialize.go +++ b/src/cmd/initialize.go @@ -61,7 +61,7 @@ var initCmd = &cobra.Command{ pkgConfig.PkgOpts.SetVariables = helpers.TransformAndMergeMap( v.GetStringMapString(common.VPkgDeploySet), pkgConfig.PkgOpts.SetVariables, strings.ToUpper) - pkgClient, err := packager.New(&pkgConfig, packager.WithSource(src)) + pkgClient, err := packager.New(&pkgConfig, packager.WithSource(src), packager.WithContext(ctx)) if err != nil { return err } diff --git a/src/cmd/package.go b/src/cmd/package.go index 52b640279c..2fc06378ca 100644 --- a/src/cmd/package.go +++ b/src/cmd/package.go @@ -110,7 +110,7 @@ var packageDeployCmd = &cobra.Command{ pkgConfig.PkgOpts.SetVariables = helpers.TransformAndMergeMap( v.GetStringMapString(common.VPkgDeploySet), pkgConfig.PkgOpts.SetVariables, strings.ToUpper) - pkgClient, err := packager.New(&pkgConfig) + pkgClient, err := packager.New(&pkgConfig, packager.WithContext(cmd.Context())) if err != nil { return err } @@ -360,7 +360,7 @@ var packagePublishCmd = &cobra.Command{ pkgConfig.PublishOpts.PackageDestination = ref.String() - pkgClient, err := packager.New(&pkgConfig) + pkgClient, err := packager.New(&pkgConfig, packager.WithContext(cmd.Context())) if err != nil { return err } diff --git a/src/pkg/packager/common.go b/src/pkg/packager/common.go index 333c707a3e..ec0062768c 100644 --- a/src/pkg/packager/common.go +++ b/src/pkg/packager/common.go @@ -32,6 +32,7 @@ import ( // Packager is the main struct for managing packages. type Packager struct { + // NOTE(mkcp): Storing ctx on structs is not recommended, but this is intended as a temporary workaround. ctx context.Context cfg *types.PackagerConfig variableConfig *variables.VariableConfig diff --git a/src/types/packager.go b/src/types/packager.go index 840d05242a..2af18f1534 100644 --- a/src/types/packager.go +++ b/src/types/packager.go @@ -5,17 +5,11 @@ package types import ( - "context" - "github.com/zarf-dev/zarf/src/api/v1alpha1" ) // PackagerConfig is the main struct that the packager uses to hold high-level options. type PackagerConfig struct { - // Context provides deadlines, cancellations, and values throughout the API. - // NOTE(mkcp): Storing ctx on structs is not recommended, but this is intended as a temporary workaround. - Context context.Context - // CreateOpts tracks the user-defined options used to create the package CreateOpts ZarfCreateOptions