Skip to content

Commit

Permalink
#208. UPDATE cli/config: Delete SetSeedImages method as it is no long…
Browse files Browse the repository at this point in the history
…er needed. UPDATE packager/compose: removed the logic working with SeedImages as it is not necessary for composition. UPDATE packager/create.go: seperate the GetComposedAssets call from the seed images. Set seedImages variable using the config.GetSeedImages() method.
  • Loading branch information
mike-winberry committed Mar 1, 2022
1 parent 116bc26 commit c5943ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
5 changes: 0 additions & 5 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ func GetSeedImages() []string {
}
}

// SetSeedImages sets the list of image string specified in the package.
func SetSeedImages(seedImages []string) {
config.Seed = seedImages
}

func GetPackageName() string {
metadata := GetMetaData()
if metadata.Uncompressed {
Expand Down
21 changes: 8 additions & 13 deletions cli/internal/packager/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,35 @@ import (
"github.com/defenseunicorns/zarf/cli/types"
)

func GetComposedAssets() (components []types.ZarfComponent, seedImages []string) {
func GetComposedAssets() (components []types.ZarfComponent) {
for _, component := range config.GetComponents() {
// Build components list by expanding imported components.
if hasSubPackage(&component) {
importedComponents, importedImages := getSubPackageAssets(component)
importedComponents := getSubPackageAssets(component)
components = append(components, importedComponents...)
seedImages = append(seedImages, importedImages...)

} else {
components = append(components, component)
}
}
// Update the parent package config with the expanded sub components and seed images.
// Update the parent package config with the expanded sub components.
// This is important when the deploy package is created.
config.SetComponents(components)
config.SetSeedImages(seedImages)
return components, seedImages
return components
}

// Get the sub package components/seed images to add to parent assets, recurses on sub imports.
func getSubPackageAssets(importComponent types.ZarfComponent) (components []types.ZarfComponent, seedImages []string) {
// Get the sub package components to add to parent assets, recurses on sub imports.
func getSubPackageAssets(importComponent types.ZarfComponent) (components []types.ZarfComponent) {
importedPackage := getSubPackage(&importComponent)
seedImages = importedPackage.Seed
for _, componentToCompose := range importedPackage.Components {
if hasSubPackage(&componentToCompose) {
subComp, subImage := getSubPackageAssets(componentToCompose)
components = append(components, subComp...)
seedImages = append(seedImages, subImage...)
components = append(components, getSubPackageAssets(componentToCompose)...)
} else {
prepComponentToCompose(&componentToCompose, importedPackage.Metadata.Name, importComponent.Import.Path)
components = append(components, componentToCompose)
}
}
return components, seedImages
return components
}

// Confirms inclusion of SubPackage. Need team input.
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func Create() {
tempPath := createPaths()
defer tempPath.clean()

components, seedImages := GetComposedAssets()
components := GetComposedAssets()
seedImages := config.GetSeedImages()
packageName := config.GetPackageName()
dataInjections := config.GetDataInjections()
configFile := tempPath.base + "/zarf.yaml"
Expand Down

0 comments on commit c5943ee

Please sign in to comment.