diff --git a/src/config/config.go b/src/config/config.go index f0772e6e..83866f84 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -52,12 +52,6 @@ const ( // EnvVarPrefix is the prefix for environment variables to override bundle helm variables EnvVarPrefix = "UDS_" - // ZarfPackageNameAnnotation is the annotation key for the value that specifies the zarf package name - ZarfPackageNameAnnotation = "zarf.package.name" - - // UDSPackageNameAnnotation is the annotation key for the value that specifies the name given to a zarf package in the uds-bundle.yaml - UDSPackageNameAnnotation = "uds.package.name" - // CachedLogs is a file containing cached logs CachedLogs = "recent-logs" ) diff --git a/src/pkg/bundle/common.go b/src/pkg/bundle/common.go index d6a2548e..6bebef29 100644 --- a/src/pkg/bundle/common.go +++ b/src/pkg/bundle/common.go @@ -77,8 +77,8 @@ func (b *Bundle) ClearPaths() { } // ValidateBundleResources validates the bundle's metadata and package references -func (b *Bundle) ValidateBundleResources(bundle *types.UDSBundle, spinner *message.Spinner) error { - // TODO: need to validate arch of local OS +func (b *Bundle) ValidateBundleResources(spinner *message.Spinner) error { + bundle := &b.bundle if bundle.Metadata.Architecture == "" { // ValidateBundle was erroneously called before CalculateBuildInfo if err := b.CalculateBuildInfo(); err != nil { @@ -157,15 +157,7 @@ func (b *Bundle) ValidateBundleResources(bundle *types.UDSBundle, spinner *messa if b.cfg.CreateOpts.Output != "" { return fmt.Errorf("detected local Zarf package: %s, outputting to an OCI registry is not supported when using local Zarf packages", pkg.Name) } - var fullPkgName string - if pkg.Name == "init" { - fullPkgName = fmt.Sprintf("zarf-%s-%s-%s.tar.zst", pkg.Name, bundle.Metadata.Architecture, pkg.Ref) - } else { - // For local zarf packages, we get the package name using the package name provided in the bundle, since the zarf package artifact - // uses the actual zarf package name, these names must match - fullPkgName = fmt.Sprintf("zarf-package-%s-%s-%s.tar.zst", pkg.Name, bundle.Metadata.Architecture, pkg.Ref) - } - path := filepath.Join(pkg.Path, fullPkgName) + path := getPkgPath(pkg, bundle.Metadata.Architecture) bundle.Packages[idx].Path = path } @@ -219,6 +211,24 @@ func (b *Bundle) ValidateBundleResources(bundle *types.UDSBundle, spinner *messa return nil } +func getPkgPath(pkg types.Package, arch string) string { + var fullPkgName string + var path string + if strings.HasSuffix(pkg.Path, ".tar.zst") { + // use the provided pkg tarball + path = pkg.Path + } else if pkg.Name == "init" { + // Zarf init pkgs have a specific naming convention + fullPkgName = fmt.Sprintf("zarf-%s-%s-%s.tar.zst", pkg.Name, arch, pkg.Ref) + path = filepath.Join(pkg.Path, fullPkgName) + } else { + // infer the name of the local Zarf pkg + fullPkgName = fmt.Sprintf("zarf-package-%s-%s-%s.tar.zst", pkg.Name, arch, pkg.Ref) + path = filepath.Join(pkg.Path, fullPkgName) + } + return path +} + // CalculateBuildInfo calculates the build info for the bundle func (b *Bundle) CalculateBuildInfo() error { now := time.Now() diff --git a/src/pkg/bundle/common_test.go b/src/pkg/bundle/common_test.go index 3f17b88a..7cdc3669 100644 --- a/src/pkg/bundle/common_test.go +++ b/src/pkg/bundle/common_test.go @@ -5,6 +5,7 @@ import ( "github.com/defenseunicorns/uds-cli/src/types" zarfTypes "github.com/defenseunicorns/zarf/src/types" + "github.com/stretchr/testify/require" ) func Test_validateBundleVars(t *testing.T) { @@ -145,3 +146,54 @@ func Test_validateOverrides(t *testing.T) { }) } } + +func Test_getPkgPath(t *testing.T) { + type args struct { + pkg types.Package + arch string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "init full path", + args: args{ + pkg: types.Package{Name: "init", Ref: "0.0.1", Path: "../fake/path/custom-init.tar.zst"}, + arch: "fake64", + }, + want: "../fake/path/custom-init.tar.zst", + }, + { + name: "init directory only path", + args: args{ + pkg: types.Package{Name: "init", Ref: "0.0.1", Path: "../fake/path"}, + arch: "fake64", + }, + want: "../fake/path/zarf-init-fake64-0.0.1.tar.zst", + }, + { + name: "full path", + args: args{ + pkg: types.Package{Name: "nginx", Ref: "0.0.1", Path: "./fake/zarf-package-nginx-fake64-0.0.1.tar.zst"}, + arch: "fake64", + }, + want: "./fake/zarf-package-nginx-fake64-0.0.1.tar.zst", + }, + { + name: "directory only path", + args: args{ + pkg: types.Package{Name: "nginx", Ref: "0.0.1", Path: "/fake"}, + arch: "fake64", + }, + want: "/fake/zarf-package-nginx-fake64-0.0.1.tar.zst", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + path := getPkgPath(tt.args.pkg, tt.args.arch) + require.Equal(t, tt.want, path) + }) + } +} diff --git a/src/pkg/bundle/create.go b/src/pkg/bundle/create.go index f801f31d..b8d64653 100644 --- a/src/pkg/bundle/create.go +++ b/src/pkg/bundle/create.go @@ -44,7 +44,7 @@ func (b *Bundle) Create() error { defer validateSpinner.Stop() // validate bundle / verify access to all repositories - if err := b.ValidateBundleResources(&b.bundle, validateSpinner); err != nil { + if err := b.ValidateBundleResources(validateSpinner); err != nil { return err } diff --git a/src/pkg/bundle/deploy.go b/src/pkg/bundle/deploy.go index e6bed04e..0b971872 100644 --- a/src/pkg/bundle/deploy.go +++ b/src/pkg/bundle/deploy.go @@ -128,7 +128,7 @@ func deployPackages(packages []types.Package, resume bool, b *Bundle) error { // Automatically confirm the package deployment zarfConfig.CommonOptions.Confirm = true - source, err := sources.New(b.cfg.DeployOpts.Source, b.cfg.DeployOpts.ZarfPackageNameMap[pkg.Name], opts, sha, nsOverrides) + source, err := sources.New(b.cfg.DeployOpts.Source, pkg.Name, opts, sha, nsOverrides) if err != nil { return err } @@ -328,12 +328,6 @@ func (b *Bundle) PreDeployValidation() (string, string, string, error) { return "", "", "", err } - // Maps name given to zarf package in the bundle to the actual name of the zarf package - zarfPackageNameMap, err := provider.ZarfPackageNameMap() - if err != nil { - return "", "", "", err - } - b.cfg.DeployOpts.ZarfPackageNameMap = zarfPackageNameMap bundleName := b.bundle.Metadata.Name return bundleName, string(bundleYAML), source, err } diff --git a/src/pkg/bundle/provider.go b/src/pkg/bundle/provider.go index 6a5cef1d..7f510350 100644 --- a/src/pkg/bundle/provider.go +++ b/src/pkg/bundle/provider.go @@ -45,9 +45,6 @@ type Provider interface { // getBundleManifest gets the bundle's root manifest getBundleManifest() (*oci.Manifest, error) - - // ZarfPackageNameMap returns a map of the zarf package name specified in the uds-bundle.yaml to the actual zarf package name - ZarfPackageNameMap() (map[string]string, error) } // NewBundleProvider returns a new bundler Provider based on the source type diff --git a/src/pkg/bundle/remote.go b/src/pkg/bundle/remote.go index 545ddd95..c0b22b86 100644 --- a/src/pkg/bundle/remote.go +++ b/src/pkg/bundle/remote.go @@ -24,7 +24,6 @@ import ( zarfUtils "github.com/defenseunicorns/zarf/src/pkg/utils" "github.com/defenseunicorns/zarf/src/pkg/utils/helpers" "github.com/defenseunicorns/zarf/src/pkg/zoci" - goyaml "github.com/goccy/go-yaml" "github.com/mholt/archiver/v4" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2" @@ -335,34 +334,3 @@ func CheckOCISourcePath(source string) (string, error) { } return source, nil } - -// ZarfPackageNameMap returns the uds bundle zarf package name to actual zarf package name mappings from the oci provider -func (op *ociProvider) ZarfPackageNameMap() (map[string]string, error) { - rootManifest, err := op.getBundleManifest() - if err != nil { - return nil, err - } - - loaded, err := op.LoadBundleMetadata() - if err != nil { - return nil, err - } - - b, err := os.ReadFile(loaded[config.BundleYAML]) - if err != nil { - return nil, err - } - - var bundle types.UDSBundle - if err := goyaml.Unmarshal(b, &bundle); err != nil { - return nil, err - } - - nameMap := make(map[string]string) - for _, pkg := range bundle.Packages { - sha := strings.Split(pkg.Ref, "@sha256:")[1] // this is where we use the SHA appended to the Zarf pkg inside the bundle - manifestDesc := rootManifest.Locate(sha) - nameMap[manifestDesc.Annotations[config.UDSPackageNameAnnotation]] = manifestDesc.Annotations[config.ZarfPackageNameAnnotation] - } - return nameMap, nil -} diff --git a/src/pkg/bundle/remove.go b/src/pkg/bundle/remove.go index 04cfcf87..21a152b2 100644 --- a/src/pkg/bundle/remove.go +++ b/src/pkg/bundle/remove.go @@ -52,12 +52,6 @@ func (b *Bundle) Remove() error { return err } - // Maps name given to zarf package in the bundle to the actual name of the zarf package - zarfPackageNameMap, err := provider.ZarfPackageNameMap() - if err != nil { - return err - } - // Check if --packages flag is set and zarf packages have been specified var packagesToRemove []types.Package @@ -73,25 +67,20 @@ func (b *Bundle) Remove() error { if len(userSpecifiedPackages) != len(packagesToRemove) { return fmt.Errorf("invalid zarf packages specified by --packages") } - return removePackages(packagesToRemove, b, zarfPackageNameMap) + return removePackages(packagesToRemove, b) } - return removePackages(b.bundle.Packages, b, zarfPackageNameMap) + return removePackages(b.bundle.Packages, b) } -func removePackages(packagesToRemove []types.Package, b *Bundle, zarfPackageNameMap map[string]string) error { +func removePackages(packagesToRemove []types.Package, b *Bundle) error { // Get deployed packages deployedPackageNames := GetDeployedPackageNames() for i := len(packagesToRemove) - 1; i >= 0; i-- { pkg := packagesToRemove[i] - zarfPackageName := pkg.Name - // use the name map if it has been set (remote pkgs where the pkg name isn't consistent) - if _, ok := zarfPackageNameMap[pkg.Name]; ok { - zarfPackageName = zarfPackageNameMap[pkg.Name] - } - if slices.Contains(deployedPackageNames, zarfPackageName) { + if slices.Contains(deployedPackageNames, pkg.Name) { opts := zarfTypes.ZarfPackageOptions{ PackageSource: b.cfg.RemoveOpts.Source, } @@ -104,7 +93,7 @@ func removePackages(packagesToRemove []types.Package, b *Bundle, zarfPackageName } sha := strings.Split(pkg.Ref, "sha256:")[1] - source, err := sources.New(b.cfg.RemoveOpts.Source, zarfPackageName, opts, sha, nil) + source, err := sources.New(b.cfg.RemoveOpts.Source, pkg.Name, opts, sha, nil) if err != nil { return err } diff --git a/src/pkg/bundle/tarball.go b/src/pkg/bundle/tarball.go index 1213dfd6..4c39d235 100644 --- a/src/pkg/bundle/tarball.go +++ b/src/pkg/bundle/tarball.go @@ -19,7 +19,6 @@ import ( "github.com/defenseunicorns/zarf/src/pkg/oci" zarfUtils "github.com/defenseunicorns/zarf/src/pkg/utils" "github.com/defenseunicorns/zarf/src/pkg/utils/helpers" - "github.com/defenseunicorns/zarf/src/pkg/zoci" av3 "github.com/mholt/archiver/v3" av4 "github.com/mholt/archiver/v4" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -327,22 +326,3 @@ func (tp *tarballBundleProvider) PublishBundle(bundle types.UDSBundle, remote *o progressBar.Successf("Published %s", remote.Repo().Reference) return nil } - -// ZarfPackageNameMap gets zarf package name mappings from tarball provider -func (tp *tarballBundleProvider) ZarfPackageNameMap() (map[string]string, error) { - bundleRootManifest, err := tp.getBundleManifest() - if err != nil { - return nil, err - } - - nameMap := make(map[string]string) - for _, layer := range bundleRootManifest.Layers { - if layer.MediaType == zoci.ZarfLayerMediaTypeBlob { - // only the uds bundle layer will have AnnotationTitle set - if layer.Annotations[ocispec.AnnotationTitle] != config.BundleYAML { - nameMap[layer.Annotations[config.UDSPackageNameAnnotation]] = layer.Annotations[config.ZarfPackageNameAnnotation] - } - } - } - return nameMap, nil -} diff --git a/src/pkg/bundler/fetcher/local.go b/src/pkg/bundler/fetcher/local.go index fac4ae41..7b1b4fcc 100644 --- a/src/pkg/bundler/fetcher/local.go +++ b/src/pkg/bundler/fetcher/local.go @@ -34,7 +34,7 @@ type localFetcher struct { extractDst string } -// Fetch fetches a Zarf pkg and puts it into a local bundle +// Fetch fetches a local Zarf pkg and puts it into a local bundle func (f *localFetcher) Fetch() ([]ocispec.Descriptor, error) { fetchSpinner := message.NewProgressSpinner("Fetching package %s", f.pkg.Name) defer fetchSpinner.Stop() diff --git a/src/pkg/bundler/fetcher/remote.go b/src/pkg/bundler/fetcher/remote.go index 5870a970..61ec21bb 100644 --- a/src/pkg/bundler/fetcher/remote.go +++ b/src/pkg/bundler/fetcher/remote.go @@ -37,8 +37,6 @@ type remoteFetcher struct { // Fetch fetches a Zarf pkg and puts it into a local bundle func (f *remoteFetcher) Fetch() ([]ocispec.Descriptor, error) { fetchSpinner := message.NewProgressSpinner("Fetching package %s", f.pkg.Name) - zarfPackageName := "" - zarfRootLayerAdded := false defer fetchSpinner.Stop() layerDescs, err := f.layersToLocalBundle(fetchSpinner, f.cfg.PkgIter+1, f.cfg.NumPkgs) @@ -58,22 +56,12 @@ func (f *remoteFetcher) Fetch() ([]ocispec.Descriptor, error) { if err != nil { return nil, err } + // ensure media type is Zarf blob for layers in the bundle's root manifest layerDesc.MediaType = zoci.ZarfLayerMediaTypeBlob - // add package name annotations - annotations := make(map[string]string) - layerDesc.Annotations = annotations - layerDesc.Annotations[config.UDSPackageNameAnnotation] = f.pkg.Name - - // If zarf package name has been obtained from zarf config, set the zarf package name annotation - // This block of code will only be triggered if the zarf config is processed before the zarf image manifest - if zarfPackageName != "" { - layerDesc.Annotations[config.ZarfPackageNameAnnotation] = zarfPackageName - } - + // add layer to bundle's root manifest f.cfg.BundleRootManifest.Layers = append(f.cfg.BundleRootManifest.Layers, layerDesc) - zarfRootLayerAdded = true } else if layerDesc.MediaType == zoci.ZarfConfigMediaType { // read in and unmarshal zarf config jsonData, err := os.ReadFile(filepath.Join(f.cfg.TmpDstDir, config.BlobsDir, layerDesc.Digest.Encoded())) @@ -85,14 +73,9 @@ func (f *remoteFetcher) Fetch() ([]ocispec.Descriptor, error) { if err != nil { return nil, err } - zarfPackageName = zarfConfigData.Annotations[ocispec.AnnotationTitle] - // Check if zarf image manifest has been added to root manifest already, if so add zarfPackageName annotation - // This block of code will only be triggered if the zarf image manifest is processed before the zarf config - if zarfRootLayerAdded { - f.cfg.BundleRootManifest.Layers[f.cfg.PkgIter].Annotations[config.ZarfPackageNameAnnotation] = zarfPackageName - } } } + fetchSpinner.Successf("Fetched package: %s", f.pkg.Name) return layerDescs, nil } @@ -178,7 +161,7 @@ func (f *remoteFetcher) remoteToLocal(layersToCopy []ocispec.Descriptor) ([]ocis } } } else { - // need to grab pkg root manifest manually bc we didn't use oras.Copy() + // need to grab pkg root manifest and config manually bc we didn't use oras.Copy() pkgManifestDesc, err := utils.ToOCIStore(f.pkgRootManifest, ocispec.MediaTypeImageManifest, f.cfg.Store) if err != nil { return nil, err diff --git a/src/pkg/bundler/pusher/remote.go b/src/pkg/bundler/pusher/remote.go index 68313305..be6ee7a8 100644 --- a/src/pkg/bundler/pusher/remote.go +++ b/src/pkg/bundler/pusher/remote.go @@ -41,7 +41,6 @@ func NewPkgPusher(pkg types.Package, cfg Config) RemotePusher { // Push pushes a Zarf pkg to a remote bundle func (p *RemotePusher) Push() (ocispec.Descriptor, error) { - ctx := context.TODO() zarfManifestDesc, err := p.PushManifest() if err != nil { return ocispec.Descriptor{}, err @@ -52,15 +51,6 @@ func (p *RemotePusher) Push() (ocispec.Descriptor, error) { url := fmt.Sprintf("%s:%s", p.pkg.Repository, p.pkg.Ref) message.Debugf("Pushed %s sub-manifest into %s: %s", url, p.cfg.RemoteDst.Repo().Reference, message.JSONValue(zarfManifestDesc)) - // add package name annotations to zarf manifest - zarfYamlFile, err := p.cfg.RemoteSrc.FetchZarfYAML(ctx) - if err != nil { - return ocispec.Descriptor{}, err - } - zarfManifestDesc.Annotations = make(map[string]string) - zarfManifestDesc.Annotations[config.UDSPackageNameAnnotation] = p.pkg.Name - zarfManifestDesc.Annotations[config.ZarfPackageNameAnnotation] = zarfYamlFile.Metadata.Name - pushSpinner := message.NewProgressSpinner("") defer pushSpinner.Stop() diff --git a/src/pkg/sources/remote.go b/src/pkg/sources/remote.go index 14fb050c..698b7969 100644 --- a/src/pkg/sources/remote.go +++ b/src/pkg/sources/remote.go @@ -90,6 +90,8 @@ func (r *RemoteBundle) LoadPackage(dst *layout.PackagePaths, filter filters.Comp } } addNamespaceOverrides(&pkg, r.nsOverrides) + // ensure we're using the correct package name as specified by the bundle + pkg.Metadata.Name = r.PkgName return pkg, nil, err } @@ -151,6 +153,8 @@ func (r *RemoteBundle) LoadPackageMetadata(dst *layout.PackagePaths, _ bool, _ b dst.SetFromLayers([]ocispec.Descriptor{pkgManifestDesc, checksumLayer}) err = sources.ValidatePackageIntegrity(dst, pkg.Metadata.AggregateChecksum, true) + // ensure we're using the correct package name as specified by the bundle + pkg.Metadata.Name = r.PkgName return pkg, nil, err } diff --git a/src/pkg/sources/tarball.go b/src/pkg/sources/tarball.go index 83507e76..426e62aa 100644 --- a/src/pkg/sources/tarball.go +++ b/src/pkg/sources/tarball.go @@ -94,6 +94,8 @@ func (t *TarballBundle) LoadPackage(dst *layout.PackagePaths, filter filters.Com } addNamespaceOverrides(&pkg, t.nsOverrides) packageSpinner.Successf("Loaded bundled Zarf package: %s", t.PkgName) + // ensure we're using the correct package name as specified by the bundle + pkg.Metadata.Name = t.PkgName return pkg, nil, err } @@ -187,6 +189,8 @@ func (t *TarballBundle) LoadPackageMetadata(dst *layout.PackagePaths, _ bool, _ } err = sourceArchive.Close() + // ensure we're using the correct package name as specified by the bundle + pkg.Metadata.Name = t.PkgName return pkg, nil, err } diff --git a/src/test/bundles/07-helm-overrides/duplicate/uds-bundle.yaml b/src/test/bundles/07-helm-overrides/duplicate/uds-bundle.yaml new file mode 100644 index 00000000..37858a81 --- /dev/null +++ b/src/test/bundles/07-helm-overrides/duplicate/uds-bundle.yaml @@ -0,0 +1,28 @@ +kind: UDSBundle +metadata: + name: duplicates + description: testing a bundle with duplicate packages in specified namespaces + version: 0.0.1 + +packages: + - name: helm-overrides + repository: localhost:888/helm-overrides + ref: 0.0.1 + overrides: + podinfo-component: + unicorn-podinfo: + namespace: override-ns + values: + - path: "podinfo.replicaCount" + value: 1 + + - name: helm-overrides-duplicate + repository: localhost:888/helm-overrides + ref: 0.0.1 + overrides: + podinfo-component: + unicorn-podinfo: + namespace: another-override-ns + values: + - path: "podinfo.replicaCount" + value: 1 diff --git a/src/test/bundles/07-helm-overrides/namespace/uds-bundle.yaml b/src/test/bundles/07-helm-overrides/namespace/uds-bundle.yaml deleted file mode 100644 index 2daeaf59..00000000 --- a/src/test/bundles/07-helm-overrides/namespace/uds-bundle.yaml +++ /dev/null @@ -1,17 +0,0 @@ -kind: UDSBundle -metadata: - name: override-namespace - description: testing a bundle with a specified namespace - version: 0.0.1 - -packages: - - name: helm-overrides - path: "../../../packages/helm" - ref: 0.0.1 - overrides: - podinfo-component: - unicorn-podinfo: - namespace: "override-namespace" - values: - - path: "podinfo.replicaCount" - value: 1 diff --git a/src/test/e2e/variable_test.go b/src/test/e2e/variable_test.go index f0626ac7..69e8466e 100644 --- a/src/test/e2e/variable_test.go +++ b/src/test/e2e/variable_test.go @@ -157,37 +157,46 @@ func TestBundleWithHelmOverrides(t *testing.T) { remove(t, bundlePath) } -func TestBundleWithOverridenNamespace(t *testing.T) { +func TestBundleWithDupPkgs(t *testing.T) { deployZarfInit(t) - e2e.HelmDepUpdate(t, "src/test/packages/helm/unicorn-podinfo") - e2e.CreateZarfPkg(t, "src/test/packages/helm", false) - name := "override-namespace" - bundleDir := "src/test/bundles/07-helm-overrides/namespace" - bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-%s-%s-0.0.1.tar.zst", name, e2e.Arch)) e2e.SetupDockerRegistry(t, 888) defer e2e.TeardownRegistry(t, 888) + zarfPkgPath := "src/test/packages/helm" + e2e.HelmDepUpdate(t, fmt.Sprintf("%s/unicorn-podinfo", zarfPkgPath)) + e2e.CreateZarfPkg(t, zarfPkgPath, false) + name := "duplicates" + pkg := filepath.Join(zarfPkgPath, fmt.Sprintf("zarf-package-helm-overrides-%s-0.0.1.tar.zst", e2e.Arch)) + zarfPublish(t, pkg, "localhost:888") + bundleDir := "src/test/bundles/07-helm-overrides/duplicate" + bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-%s-%s-0.0.1.tar.zst", name, e2e.Arch)) + + createLocal(t, bundleDir, e2e.Arch) + // remove namespace after tests defer func() { - cmd := strings.Split("zarf tools kubectl delete ns override-namespace", " ") + cmd := strings.Split("zarf tools kubectl delete ns override-ns another-override-ns", " ") _, _, _ = e2e.UDS(cmd...) }() - createLocal(t, bundleDir, e2e.Arch) + // helper fn to check the different namespaces for the deployment + checkDeployments := func(t *testing.T) { + for _, ns := range []string{"override-ns", "another-override-ns"} { + cmd := strings.Split(fmt.Sprintf("zarf tools kubectl get deploy -n %s -o=jsonpath='{.items[*].metadata.name}'", ns), " ") + deployment, _, _ := e2e.UDS(cmd...) + require.Equal(t, "'unicorn-podinfo'", deployment) + } + } - t.Run("test namespace override in local bundle", func(t *testing.T) { + t.Run("test namespace override + dup pkgs in local bundle", func(t *testing.T) { deploy(t, bundlePath) - cmd := strings.Split("zarf tools kubectl get deploy -n override-namespace unicorn-podinfo -o=jsonpath='{.metadata.name}'", " ") - deployments, _, _ := e2e.UDS(cmd...) - require.Contains(t, deployments, "unicorn-podinfo") + checkDeployments(t) remove(t, bundlePath) }) - t.Run("test namespace override in remote bundle", func(t *testing.T) { + t.Run("test namespace override + dup pkgs in remote bundle", func(t *testing.T) { publishInsecure(t, bundlePath, "localhost:888") deployInsecure(t, fmt.Sprintf("localhost:888/%s:0.0.1", name)) - cmd := strings.Split("zarf tools kubectl get deploy -n override-namespace unicorn-podinfo -o=jsonpath='{.metadata.name}'", " ") - deployments, _, _ := e2e.UDS(cmd...) - require.Contains(t, deployments, "unicorn-podinfo") + checkDeployments(t) removeInsecure(t, fmt.Sprintf("localhost:888/%s:0.0.1", name)) }) } diff --git a/src/types/bundle.go b/src/types/bundle.go index 1a6ad320..3e7ef9e8 100644 --- a/src/types/bundle.go +++ b/src/types/bundle.go @@ -15,6 +15,7 @@ type UDSBundle struct { // Package represents a Zarf package in a UDS bundle type Package struct { Name string `json:"name" jsonschema:"name=Name of the Zarf package"` + Description string `json:"description,omitempty" jsonschema:"description=Description of the Zarf package"` Repository string `json:"repository,omitempty" jsonschema:"description=The repository to import the package from"` Path string `json:"path,omitempty" jsonschema:"description=The local path to import the package from"` Ref string `json:"ref" jsonschema:"description=Ref (tag) of the Zarf package"` diff --git a/src/types/options.go b/src/types/options.go index 1b2f41f4..d2a5cbdc 100644 --- a/src/types/options.go +++ b/src/types/options.go @@ -31,10 +31,9 @@ type BundleDeployOptions struct { PublicKeyPath string SetVariables map[string]string `json:"setVariables" jsonschema:"description=Key-Value map of variable names and their corresponding values that will be used by Zarf packages in a bundle"` // Variables and SharedVariables are read in from uds-config.yaml - Variables map[string]map[string]interface{} `yaml:"variables,omitempty"` - SharedVariables map[string]interface{} `yaml:"shared,omitempty"` - ZarfPackageNameMap map[string]string `yaml:"-" json:"-"` - Retries int `yaml:"retries"` + Variables map[string]map[string]interface{} `yaml:"variables,omitempty"` + SharedVariables map[string]interface{} `yaml:"shared,omitempty"` + Retries int `yaml:"retries"` } // BundleInspectOptions is the options for the bundler.Inspect() function diff --git a/uds.schema.json b/uds.schema.json index fbef1ff4..ac1e39f9 100644 --- a/uds.schema.json +++ b/uds.schema.json @@ -109,6 +109,10 @@ "name": { "type": "string" }, + "description": { + "type": "string", + "description": "Description of the Zarf package" + }, "repository": { "type": "string", "description": "The repository to import the package from"