From ae416b82541332249a448a77cfc9617fb97efcce Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 23 Aug 2024 17:12:53 +0000 Subject: [PATCH 1/2] WIP, tryout annotations to cover for deprecated group Signed-off-by: Austin Abro --- src/api/v1beta1/package.go | 6 ++++++ src/api/v1beta1/translate.go | 3 +++ src/pkg/packager/filters/deploy.go | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/api/v1beta1/package.go b/src/api/v1beta1/package.go index e190102e54..8c4dc84daf 100644 --- a/src/api/v1beta1/package.go +++ b/src/api/v1beta1/package.go @@ -59,6 +59,12 @@ func (pkg ZarfPackage) IsInitConfig() bool { return pkg.Kind == ZarfInitConfig } +// GetDeprecatedGroup gets the group of the component, if it is set. This should only be set +// by for backwards compatibility with v1alpha1 packages. +func (pkg ZarfPackage) GetDeprecatedGroup(componentIndex int) string { + return pkg.Metadata.Annotations[fmt.Sprintf("group-%d", componentIndex)] +} + // HasImages returns true if one of the components contains an image. func (pkg ZarfPackage) HasImages() bool { for _, component := range pkg.Components { diff --git a/src/api/v1beta1/translate.go b/src/api/v1beta1/translate.go index 78d2182492..97620ec540 100644 --- a/src/api/v1beta1/translate.go +++ b/src/api/v1beta1/translate.go @@ -64,6 +64,9 @@ func TranslateAlphaPackage(alphaPkg v1alpha1.ZarfPackage) (ZarfPackage, error) { for i := range betaPkg.Components { betaPkg.Components[i].Optional = helpers.BoolPtr(!alphaPkg.Components[i].IsRequired()) for j := range betaPkg.Components[i].Charts { + if alphaPkg.Components[i].DeprecatedGroup != "" { + betaPkg.Metadata.Annotations[fmt.Sprintf("group-%d", i)] = alphaPkg.Components[i].DeprecatedGroup + } oldURL := alphaPkg.Components[i].Charts[j].URL if helpers.IsOCIURL(oldURL) { betaPkg.Components[i].Charts[j].OCI.URL = oldURL diff --git a/src/pkg/packager/filters/deploy.go b/src/pkg/packager/filters/deploy.go index 4b562d1c92..c308ead1a7 100644 --- a/src/pkg/packager/filters/deploy.go +++ b/src/pkg/packager/filters/deploy.go @@ -11,7 +11,7 @@ import ( "github.com/agnivade/levenshtein" "github.com/defenseunicorns/pkg/helpers/v2" - "github.com/zarf-dev/zarf/src/api/v1alpha1" + "github.com/zarf-dev/zarf/src/api/v1beta1" "github.com/zarf-dev/zarf/src/pkg/interactive" ) @@ -40,16 +40,16 @@ var ( ) // Apply applies the filter. -func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfComponent, error) { - var selectedComponents []v1alpha1.ZarfComponent - groupedComponents := map[string][]v1alpha1.ZarfComponent{} +func (f *deploymentFilter) Apply(pkg v1beta1.ZarfPackage) ([]v1beta1.ZarfComponent, error) { + var selectedComponents []v1beta1.ZarfComponent + groupedComponents := map[string][]v1beta1.ZarfComponent{} orderedComponentGroups := []string{} // Group the components by Name and Group while maintaining order - for _, component := range pkg.Components { + for idx, component := range pkg.Components { groupKey := component.Name - if component.DeprecatedGroup != "" { - groupKey = component.DeprecatedGroup + if pkg.GetDeprecatedGroup(idx) != "" { + groupKey = pkg.GetDeprecatedGroup(idx) } if !slices.Contains(orderedComponentGroups, groupKey) { @@ -66,8 +66,8 @@ func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfCompo // NOTE: This does not use forIncludedComponents as it takes group, default and required status into account. for _, groupKey := range orderedComponentGroups { - var groupDefault *v1alpha1.ZarfComponent - var groupSelected *v1alpha1.ZarfComponent + var groupDefault *v1beta1.ZarfComponent + var groupSelected *v1beta1.ZarfComponent for _, component := range groupedComponents[groupKey] { // Ensure we have a local version of the component to point to (otherwise the pointer might change on us) @@ -75,7 +75,7 @@ func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfCompo selectState, matchedRequest := includedOrExcluded(component.Name, f.requestedComponents) - if !component.IsRequired() { + if component.IsOptional() { if selectState == excluded { // If the component was explicitly excluded, record the match and continue matchedRequests[matchedRequest] = true @@ -161,7 +161,7 @@ func (f *deploymentFilter) Apply(pkg v1alpha1.ZarfPackage) ([]v1alpha1.ZarfCompo } else { component := groupedComponents[groupKey][0] - if component.IsRequired() { + if !component.IsOptional() { selectedComponents = append(selectedComponents, component) continue } From 24cccd0932f5e5818f4a5b297ca390844a9eccae Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 27 Aug 2024 12:23:32 +0000 Subject: [PATCH 2/2] POC for deprecating the big bang extension Signed-off-by: Austin Abro --- src/api/v1beta1/component.go | 2 + src/api/v1beta1/package.go | 55 +++++++++++++++++++-- src/api/v1beta1/translate.go | 28 ++++++++++- src/extensions/bigbang/bigbang.go | 72 +++++++++++++++------------- src/extensions/bigbang/flux.go | 10 ++-- src/internal/packager/helm/common.go | 3 +- src/pkg/packager/creator/normal.go | 11 +++-- 7 files changed, 131 insertions(+), 50 deletions(-) diff --git a/src/api/v1beta1/component.go b/src/api/v1beta1/component.go index 2d27777c54..6589e21722 100644 --- a/src/api/v1beta1/component.go +++ b/src/api/v1beta1/component.go @@ -148,6 +148,8 @@ type GitRepoSource struct { URL string `json:"url"` // The sub directory to the chart within a git repo. Path string `json:"path,omitempty"` + // The Tag of the repo where the helm chart is stored. + Tag string `json:"tag,omitempty"` } // LocalRepoSource represents a Helm chart stored locally. diff --git a/src/api/v1beta1/package.go b/src/api/v1beta1/package.go index 8c4dc84daf..f7a8611bf6 100644 --- a/src/api/v1beta1/package.go +++ b/src/api/v1beta1/package.go @@ -7,6 +7,9 @@ package v1beta1 import ( "fmt" "regexp" + "strings" + + "github.com/zarf-dev/zarf/src/api/v1alpha1/extensions" ) // VariableType represents a type of a Zarf package variable @@ -59,10 +62,56 @@ func (pkg ZarfPackage) IsInitConfig() bool { return pkg.Kind == ZarfInitConfig } +func (pkg ZarfPackage) IsAirGap() bool { + if pkg.Metadata.Airgap == nil { + return true + } + return *pkg.Metadata.Airgap + +} + +// GetDeprecatedGroup gets the group of the component, if it is set. This should only be set +// by annotations for backwards compatibility with v1alpha1 packages. +func (pkg ZarfPackage) GetDeprecatedGroup(compIdx int) string { + if pkg.Metadata.Annotations == nil { + return "" + } + + return pkg.Metadata.Annotations[fmt.Sprintf("group-%d", compIdx)] +} + // GetDeprecatedGroup gets the group of the component, if it is set. This should only be set -// by for backwards compatibility with v1alpha1 packages. -func (pkg ZarfPackage) GetDeprecatedGroup(componentIndex int) string { - return pkg.Metadata.Annotations[fmt.Sprintf("group-%d", componentIndex)] +// by annotations for backwards compatibility with v1alpha1 packages. +func (pkg ZarfPackage) GetDeprecatedCosignKey(compIdx int) string { + if pkg.Metadata.Annotations == nil { + return "" + } + + return pkg.Metadata.Annotations[fmt.Sprintf("cosign-key-path-%d", compIdx)] +} + +// GetDeprecatedExtension gets the extensions of the component, if it is set. This should only be set +// by annotations for backwards compatibility with v1alpha1 packages. +func (pkg ZarfPackage) GetDeprecatedExtensions(compIdx int) extensions.ZarfComponentExtensions { + if pkg.Metadata.Annotations == nil { + return extensions.ZarfComponentExtensions{} + } + + if pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-version", compIdx)] == "" { + return extensions.ZarfComponentExtensions{} + } + + extensions := extensions.ZarfComponentExtensions{ + BigBang: &extensions.BigBang{ + Version: pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-version", compIdx)], + ValuesFiles: strings.Split(pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-values-files", compIdx)], ","), + SkipFlux: pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-skip-flux", compIdx)] == "true", + Repo: pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-repo", compIdx)], + FluxPatchFiles: strings.Split(pkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-values-files", compIdx)], ","), + }, + } + + return extensions } // HasImages returns true if one of the components contains an image. diff --git a/src/api/v1beta1/translate.go b/src/api/v1beta1/translate.go index 97620ec540..a8df2310be 100644 --- a/src/api/v1beta1/translate.go +++ b/src/api/v1beta1/translate.go @@ -7,6 +7,7 @@ package v1beta1 import ( "encoding/json" "fmt" + "strconv" "strings" "time" @@ -63,10 +64,33 @@ func TranslateAlphaPackage(alphaPkg v1alpha1.ZarfPackage) (ZarfPackage, error) { for i := range betaPkg.Components { betaPkg.Components[i].Optional = helpers.BoolPtr(!alphaPkg.Components[i].IsRequired()) + if alphaPkg.Components[i].DeprecatedGroup != "" { + betaPkg.Metadata.Annotations[fmt.Sprintf("group-%d", i)] = alphaPkg.Components[i].DeprecatedGroup + } + for j := range betaPkg.Components[i].Charts { - if alphaPkg.Components[i].DeprecatedGroup != "" { - betaPkg.Metadata.Annotations[fmt.Sprintf("group-%d", i)] = alphaPkg.Components[i].DeprecatedGroup + if alphaPkg.Components[i].Extensions.BigBang != nil { + if alphaPkg.Components[i].Extensions.BigBang.Version != "" { + betaPkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-version", i)] = alphaPkg.Components[i].Extensions.BigBang.Version + } + if alphaPkg.Components[i].Extensions.BigBang.Repo != "" { + betaPkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-repo", i)] = alphaPkg.Components[i].Extensions.BigBang.Repo + } + + if alphaPkg.Components[i].Extensions.BigBang.FluxPatchFiles != nil { + betaPkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-flux-patch-files", i)] = strings.Join(alphaPkg.Components[i].Extensions.BigBang.FluxPatchFiles, ",") + } + + if alphaPkg.Components[i].Extensions.BigBang.ValuesFiles != nil { + betaPkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-values-files", i)] = strings.Join(alphaPkg.Components[i].Extensions.BigBang.ValuesFiles, ",") + } + betaPkg.Metadata.Annotations[fmt.Sprintf("big-bang-%d-skip-flux", i)] = strconv.FormatBool(alphaPkg.Components[i].Extensions.BigBang.SkipFlux) } + + if alphaPkg.Components[i].DeprecatedCosignKeyPath != "" { + betaPkg.Metadata.Annotations[fmt.Sprintf("cosign-key-path-%d", i)] = alphaPkg.Components[i].DeprecatedCosignKeyPath + } + oldURL := alphaPkg.Components[i].Charts[j].URL if helpers.IsOCIURL(oldURL) { betaPkg.Components[i].Charts[j].OCI.URL = oldURL diff --git a/src/extensions/bigbang/bigbang.go b/src/extensions/bigbang/bigbang.go index 6b59d2a829..c033e19f38 100644 --- a/src/extensions/bigbang/bigbang.go +++ b/src/extensions/bigbang/bigbang.go @@ -19,6 +19,7 @@ import ( fluxSrcCtrl "github.com/fluxcd/source-controller/api/v1beta2" "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/api/v1alpha1/extensions" + "github.com/zarf-dev/zarf/src/api/v1beta1" "github.com/zarf-dev/zarf/src/internal/packager/helm" "github.com/zarf-dev/zarf/src/pkg/layout" "github.com/zarf-dev/zarf/src/pkg/message" @@ -43,19 +44,20 @@ var tenMins = metav1.Duration{ // Run mutates a component that should deploy Big Bang to a set of manifests // that contain the flux deployment of Big Bang -func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1alpha1.ZarfComponent) (v1alpha1.ZarfComponent, error) { - cfg := c.Extensions.BigBang - manifests := []v1alpha1.ZarfManifest{} +func Run(ctx context.Context, tmpPaths *layout.ComponentPaths, pkg v1beta1.ZarfPackage, compIdx int) (v1beta1.ZarfComponent, error) { + manifests := []v1beta1.ZarfManifest{} + cfg := pkg.GetDeprecatedExtensions(compIdx).BigBang + c := pkg.Components[compIdx] validVersionResponse, err := isValidVersion(cfg.Version) if err != nil { - return c, fmt.Errorf("could not parse the Big Bang version %s: %w", cfg.Version, err) + return v1beta1.ZarfComponent{}, fmt.Errorf("could not parse the Big Bang version %s: %w", cfg.Version, err) } // Make sure the version is valid. if !validVersionResponse { - return c, fmt.Errorf("Big Bang version %s must be at least %s", cfg.Version, bbMinRequiredVersion) + return v1beta1.ZarfComponent{}, fmt.Errorf("Big Bang version %s must be at least %s", cfg.Version, bbMinRequiredVersion) } // Print the banner for Big Bang. @@ -68,15 +70,19 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al // By default, we want to deploy flux. if !cfg.SkipFlux { + if cfg.Repo == "" { + cfg.Repo = bbRepo + } + fluxManifest, images, err := getFlux(tmpPaths.Temp, cfg) if err != nil { - return c, err + return v1beta1.ZarfComponent{}, err } // Add the flux manifests to the list of manifests to be pulled down by Zarf. manifests = append(manifests, fluxManifest) - if !YOLO { + if pkg.IsAirGap() { // Add the images to the list of images to be pulled down by Zarf. c.Images = append(c.Images, images...) } @@ -86,13 +92,15 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al // Configure helm to pull down the Big Bang chart. helmCfg := helm.New( - v1alpha1.ZarfChart{ - Name: bb, - Namespace: bb, - URL: bbRepo, - Version: cfg.Version, + v1beta1.ZarfChart{ + Name: bb, + Namespace: bb, + Git: v1beta1.GitRepoSource{ + URL: bbRepo, + Tag: cfg.Version, + Path: "./chart", + }, ValuesFiles: cfg.ValuesFiles, - GitPath: "./chart", }, path.Join(tmpPaths.Temp, bb), path.Join(tmpPaths.Temp, bb, "values"), @@ -100,7 +108,7 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al ) // Download the chart from Git and save it to a temporary directory. - err = helmCfg.PackageChartFromGit(ctx, c.DeprecatedCosignKeyPath) + err = helmCfg.PackageChartFromGit(ctx, pkg.GetDeprecatedCosignKey(compIdx)) if err != nil { return c, fmt.Errorf("unable to download Big Bang Chart: %w", err) } @@ -113,7 +121,7 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al } // Add the Big Bang repo to the list of repos to be pulled down by Zarf. - if !YOLO { + if pkg.IsAirGap() { bbRepo := fmt.Sprintf("%s@%s", cfg.Repo, cfg.Version) c.Repos = append(c.Repos, bbRepo) } @@ -122,7 +130,7 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al if err != nil { return c, fmt.Errorf("unable to find Big Bang resources: %w", err) } - if !YOLO { + if pkg.IsAirGap() { for _, gitRepo := range gitRepos { c.Repos = append(c.Repos, gitRepo) } @@ -139,9 +147,9 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al } // ten minutes in seconds - maxTotalSeconds := 10 * 60 + maxTotalSeconds := time.Duration(10 * 60 * time.Second) - defaultMaxTotalSeconds := c.Actions.OnDeploy.Defaults.MaxTotalSeconds + defaultMaxTotalSeconds := c.Actions.OnDeploy.Defaults.Timeout.Duration if defaultMaxTotalSeconds > maxTotalSeconds { maxTotalSeconds = defaultMaxTotalSeconds } @@ -149,11 +157,11 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al // Add wait actions for each of the helm releases in generally the order they should be deployed. for _, hrNamespacedName := range namespacedHelmReleaseNames { hr := hrDependencies[hrNamespacedName] - action := v1alpha1.ZarfComponentAction{ - Description: fmt.Sprintf("Big Bang Helm Release `%s` to be ready", hrNamespacedName), - MaxTotalSeconds: &maxTotalSeconds, - Wait: &v1alpha1.ZarfComponentActionWait{ - Cluster: &v1alpha1.ZarfComponentActionWaitCluster{ + action := v1beta1.ZarfComponentAction{ + Description: fmt.Sprintf("Big Bang Helm Release `%s` to be ready", hrNamespacedName), + Timeout: &metav1.Duration{Duration: maxTotalSeconds}, + Wait: &v1beta1.ZarfComponentActionWait{ + Cluster: &v1beta1.ZarfComponentActionWaitCluster{ Kind: "HelmRelease", Name: hr.Metadata.Name, Namespace: hr.Metadata.Namespace, @@ -168,7 +176,7 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al // https://repo1.dso.mil/big-bang/bigbang/-/blob/1.54.0/chart/templates/metrics-server/helmrelease.yaml if hr.Metadata.Name == "metrics-server" { action.Description = "K8s metric server to exist or be deployed by Big Bang" - action.Wait.Cluster = &v1alpha1.ZarfComponentActionWaitCluster{ + action.Wait.Cluster = &v1beta1.ZarfComponentActionWaitCluster{ Kind: "APIService", // https://github.com/kubernetes-sigs/metrics-server#compatibility-matrix Name: "v1beta1.metrics.k8s.io", @@ -195,13 +203,13 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al // Add onFailure actions with additional troubleshooting information. for _, cmd := range failureGeneral { - c.Actions.OnDeploy.OnFailure = append(c.Actions.OnDeploy.OnFailure, v1alpha1.ZarfComponentAction{ + c.Actions.OnDeploy.OnFailure = append(c.Actions.OnDeploy.OnFailure, v1beta1.ZarfComponentAction{ Cmd: fmt.Sprintf("./zarf tools kubectl %s", cmd), }) } for _, cmd := range failureDebug { - c.Actions.OnDeploy.OnFailure = append(c.Actions.OnDeploy.OnFailure, v1alpha1.ZarfComponentAction{ + c.Actions.OnDeploy.OnFailure = append(c.Actions.OnDeploy.OnFailure, v1beta1.ZarfComponentAction{ Mute: &t, Description: "Storing debug information to the log for troubleshooting.", Cmd: fmt.Sprintf("./zarf tools kubectl %s", cmd), @@ -209,13 +217,13 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al } // Add a pre-remove action to suspend the Big Bang HelmReleases to prevent reconciliation during removal. - c.Actions.OnRemove.Before = append(c.Actions.OnRemove.Before, v1alpha1.ZarfComponentAction{ + c.Actions.OnRemove.Before = append(c.Actions.OnRemove.Before, v1beta1.ZarfComponentAction{ Description: "Suspend Big Bang HelmReleases to prevent reconciliation during removal.", Cmd: `./zarf tools kubectl patch helmrelease -n bigbang bigbang --type=merge -p '{"spec":{"suspend":true}}'`, }) // Select the images needed to support the repos for this configuration of Big Bang. - if !YOLO { + if pkg.IsAirGap() { for _, hr := range hrDependencies { namespacedName := getNamespacedNameFromMeta(hr.Metadata) gitRepo := gitRepos[hr.NamespacedSource] @@ -234,7 +242,7 @@ func Run(ctx context.Context, YOLO bool, tmpPaths *layout.ComponentPaths, c v1al } // Create the flux wrapper around Big Bang for deployment. - manifest, err := addBigBangManifests(YOLO, tmpPaths.Temp, cfg) + manifest, err := addBigBangManifests(pkg.IsAirGap(), tmpPaths.Temp, cfg) if err != nil { return c, err } @@ -453,9 +461,9 @@ func findBBResources(t string) (gitRepos map[string]string, helmReleaseDeps map[ } // addBigBangManifests creates the manifests component for deploying Big Bang. -func addBigBangManifests(YOLO bool, manifestDir string, cfg *extensions.BigBang) (v1alpha1.ZarfManifest, error) { +func addBigBangManifests(airgap bool, manifestDir string, cfg *extensions.BigBang) (v1beta1.ZarfManifest, error) { // Create a manifest component that we add to the zarf package for bigbang. - manifest := v1alpha1.ZarfManifest{ + manifest := v1beta1.ZarfManifest{ Name: bb, Namespace: bb, } @@ -484,7 +492,7 @@ func addBigBangManifests(YOLO bool, manifestDir string, cfg *extensions.BigBang) var hrValues []fluxHelmCtrl.ValuesReference // If YOLO mode is enabled, do not include the zarf-credentials secret - if !YOLO { + if airgap { // Create the zarf-credentials secret manifest. if err := addManifest("bb-ext-zarf-credentials.yaml", manifestZarfCredentials(cfg.Version)); err != nil { return manifest, err diff --git a/src/extensions/bigbang/flux.go b/src/extensions/bigbang/flux.go index 2acdee4f99..f3064b9290 100644 --- a/src/extensions/bigbang/flux.go +++ b/src/extensions/bigbang/flux.go @@ -12,8 +12,8 @@ import ( "github.com/defenseunicorns/pkg/helpers/v2" fluxHelmCtrl "github.com/fluxcd/helm-controller/api/v2beta1" - "github.com/zarf-dev/zarf/src/api/v1alpha1" "github.com/zarf-dev/zarf/src/api/v1alpha1/extensions" + "github.com/zarf-dev/zarf/src/api/v1beta1" "github.com/zarf-dev/zarf/src/internal/packager/kustomize" "github.com/zarf-dev/zarf/src/pkg/utils" "helm.sh/helm/v3/pkg/chartutil" @@ -43,14 +43,10 @@ func (h HelmReleaseDependency) Dependencies() []string { } // getFlux Creates a component to deploy Flux. -func getFlux(baseDir string, cfg *extensions.BigBang) (manifest v1alpha1.ZarfManifest, images []string, err error) { +func getFlux(baseDir string, cfg extensions.BigBang) (manifest v1beta1.ZarfManifest, images []string, err error) { localPath := path.Join(baseDir, "bb-ext-flux.yaml") kustomizePath := path.Join(baseDir, "kustomization.yaml") - if cfg.Repo == "" { - cfg.Repo = bbRepo - } - remotePath := fmt.Sprintf("%s//base/flux?ref=%s", cfg.Repo, cfg.Version) fluxKustomization := krustytypes.Kustomization{ @@ -72,7 +68,7 @@ func getFlux(baseDir string, cfg *extensions.BigBang) (manifest v1alpha1.ZarfMan } // Add the flux.yaml file to the component manifests. - manifest = v1alpha1.ZarfManifest{ + manifest = v1beta1.ZarfManifest{ Name: "flux-system", Namespace: "flux-system", Files: []string{localPath}, diff --git a/src/internal/packager/helm/common.go b/src/internal/packager/helm/common.go index 8d20e84483..b93b666d93 100644 --- a/src/internal/packager/helm/common.go +++ b/src/internal/packager/helm/common.go @@ -15,6 +15,7 @@ import ( "time" "github.com/zarf-dev/zarf/src/api/v1alpha1" + "github.com/zarf-dev/zarf/src/api/v1beta1" "github.com/zarf-dev/zarf/src/config" "github.com/zarf-dev/zarf/src/pkg/cluster" "github.com/zarf-dev/zarf/src/pkg/message" @@ -51,7 +52,7 @@ type Helm struct { type Modifier func(*Helm) // New returns a new Helm config struct. -func New(chart v1alpha1.ZarfChart, chartPath string, valuesPath string, mods ...Modifier) *Helm { +func New(chart v1beta1.ZarfChart, chartPath string, valuesPath string, mods ...Modifier) *Helm { h := &Helm{ chart: chart, chartPath: chartPath, diff --git a/src/pkg/packager/creator/normal.go b/src/pkg/packager/creator/normal.go index 847a22003e..84ae3289c7 100644 --- a/src/pkg/packager/creator/normal.go +++ b/src/pkg/packager/creator/normal.go @@ -19,6 +19,7 @@ import ( "github.com/defenseunicorns/pkg/oci" "github.com/mholt/archiver/v3" "github.com/zarf-dev/zarf/src/api/v1alpha1" + "github.com/zarf-dev/zarf/src/api/v1beta1" "github.com/zarf-dev/zarf/src/config" "github.com/zarf-dev/zarf/src/config/lang" "github.com/zarf-dev/zarf/src/extensions/bigbang" @@ -86,7 +87,7 @@ func (pc *PackageCreator) LoadPackageDefinition(ctx context.Context, src *layout warnings = append(warnings, templateWarnings...) // After templates are filled process any create extensions - pkg.Components, err = pc.processExtensions(ctx, pkg.Components, src, pkg.Metadata.YOLO) + pkg.Components, err = pc.processExtensions(ctx, pkg, src) if err != nil { return v1alpha1.ZarfPackage{}, nil, err } @@ -330,17 +331,17 @@ func (pc *PackageCreator) Output(ctx context.Context, dst *layout.PackagePaths, return nil } -func (pc *PackageCreator) processExtensions(ctx context.Context, components []v1alpha1.ZarfComponent, layout *layout.PackagePaths, isYOLO bool) (processedComponents []v1alpha1.ZarfComponent, err error) { +func (pc *PackageCreator) processExtensions(ctx context.Context, pkg v1beta1.ZarfPackage, layout *layout.PackagePaths) (processedComponents []v1alpha1.ZarfComponent, err error) { // Create component paths and process extensions for each component. - for _, c := range components { + for idx, c := range pkg.Components { componentPaths, err := layout.Components.Create(c) if err != nil { return nil, err } // Big Bang - if c.Extensions.BigBang != nil { - if c, err = bigbang.Run(ctx, isYOLO, componentPaths, c); err != nil { + if pkg.GetDeprecatedExtensions(idx).BigBang != nil { + if c, err = bigbang.Run(ctx, componentPaths, pkg, idx); err != nil { return nil, fmt.Errorf("unable to process bigbang extension: %w", err) } }