Skip to content

Commit

Permalink
#208. config: Add SetComponents method to update the components in th…
Browse files Browse the repository at this point in the history
…e private config. package/create.Create: Add logic to expand locally imported components within the parent build config. types: Add Import field to Zarf.Component as expirement (expected to change).
  • Loading branch information
mike-winberry committed Feb 25, 2022
1 parent e59c02a commit c602e49
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func GetComponents() []types.ZarfComponent {
return config.Components
}

func SetComponents(components []types.ZarfComponent) {
config.Components = components
}

func GetBuildData() types.ZarfBuildData {
return config.Build
}
Expand Down
17 changes: 16 additions & 1 deletion cli/internal/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,26 @@ func Create() {
packageName := config.GetPackageName()
dataInjections := config.GetDataInjections()
seedImages := config.GetSeedImages()
components := config.GetComponents()
components := []types.ZarfComponent{}
configFile := tempPath.base + "/zarf.yaml"

config.SetAcrch()

for _, component := range config.GetComponents() {
if len(component.Import) > 0 {
importedPackage := types.ZarfPackage{}
utils.ReadYaml(component.Import+"zarf.yaml", &importedPackage)
seedImages = append(seedImages, importedPackage.Seed...)
for _, composedComponent := range importedPackage.Components {
composedComponent.Name = importedPackage.Metadata.Name + "-" + composedComponent.Name
components = append(components, composedComponent)
}
} else {
components = append(components, component)
}
}
config.SetComponents(components)

// Save the transformed config
if err := config.BuildConfig(configFile); err != nil {
message.Fatalf(err, "Unable to write the %s file", configFile)
Expand Down
3 changes: 3 additions & 0 deletions cli/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type ZarfComponent struct {

// Scripts are custom commands that run before or after package deployment
Scripts ZarfComponentScripts `yaml:"scripts,omitempty"`

// Import refers to another zarf.yml package.
Import string `yaml:"import,omitempty"`
}

// ZarfManifest defines raw manifests Zarf will deploy as a helm chart
Expand Down
15 changes: 15 additions & 0 deletions examples/flux/template/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
registryCredentials:
- registry: "registry1.dso.mil"
username: "zarf-git-user"
password: "###ZARF_REGISTRY_AUTH_PULL###"
- registry: "docker.io"
username: "zarf-git-user"
password: "###ZARF_REGISTRY_AUTH_PULL###"
- registry: "registry.dso.mil"
username: "zarf-git-user"
password: "###ZARF_REGISTRY_AUTH_PULL###"

flux:
interval: 1m
rollback:
cleanupOnFail: false
20 changes: 20 additions & 0 deletions examples/flux/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: ZarfPackageConfig
metadata:
name: flux
description: "Zarf flux package."

components:
- name: baseline
required: true
secretName: "private-registry"
manifests:
- name: flux-installer
# This will be built on the package create side and deployed as a regular manifest on package deploy
kustomizations:
- https://repo1.dso.mil/platform-one/big-bang/bigbang.git//base/flux?ref=1.17.0
images:
# Flux images
- registry1.dso.mil/ironbank/fluxcd/helm-controller:v0.11.0
- registry1.dso.mil/ironbank/fluxcd/kustomize-controller:v0.13.0
- registry1.dso.mil/ironbank/fluxcd/notification-controller:v0.15.0
- registry1.dso.mil/ironbank/fluxcd/source-controller:v0.14.0
3 changes: 3 additions & 0 deletions examples/game/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ metadata:
description: "Demo Zarf appliance mode with some dos games"

components:
- name: flux
required: false
import: '../flux/'
- name: baseline
required: true
manifests:
Expand Down

0 comments on commit c602e49

Please sign in to comment.