Skip to content

Commit

Permalink
fix: passing context into packager (#3303)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 authored Dec 9, 2024
1 parent 610013d commit 8ae4946
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/pkg/packager/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/types/packager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8ae4946

Please sign in to comment.