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

fix: passing context into packager #3303

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading