Skip to content

Commit

Permalink
chore: automate Zarf upgrades in code
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd committed Nov 29, 2023
1 parent a2275bf commit 46fff19
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/actions/zarf/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ runs:
steps:
- uses: defenseunicorns/setup-zarf@main
with:
# renovate: datasource=github-tags depName=defenseunicorns/zarf versioning=semver
version: v0.31.1
# renovate: datasource=github-tags depName=defenseunicorns/zarf
version: v0.31.2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ __debug_bin
sboms
bundle-sboms
node_modules
checksums.txt
checksums.txt
*.tape
67 changes: 67 additions & 0 deletions override-styles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# current
overrides:
values:
- path: "podinfo-component/unicorn-podinfo/podinfo.replicaCount"
value: 2
valuesFiles:
- path: "podinfo-component/unicorn-podinfo/values.yaml"
variables:
- name: UI_COLOR
path: "podinfo-component/unicorn-podinfo/podinfo.ui.color"
description: "Set the color for podinfo's UI"
default: "blue"

---
# object (component: chart: override-type) <- but don't mix kebab and camel case
overrides:
podinfo-component:
unicorn-podinfo:
values:
- path: podinfo.ui.color
value: blue
valuesFiles:
- path: values.yaml
variables:
- name: UI_COLOR
path: podinfo.ui.color
description: "Set the color for podinfo's UI"
default: "blue"

---
# object (override-type: component: chart)
overrides:
values:
podinfo-component:
unicorn-podinfo:
- path: podinfo.ui.color
value: blue
valuesFiles:
podinfo-component:
unicorn-podinfo:
- path: values.yaml
variables:
podinfo-component:
unicorn-podinfo:
- name: UI_COLOR
path: podinfo.ui.color
description: "Set the color for podinfo's UI"
default: "blue"
---
# uds-config.yaml refactor
# current
bundle:
deploy:
zarf-packages:
helm:
set:
# overrides variables in uds-bundle.yaml
UI_COLOR: green
UI_MSG: "Hello Unicorn"
---
# suggested
deploy:
omit-env-vars: true
variables:
helm:
UI_COLOR: green
UI_MSG: "Hello Unicorn"
19 changes: 18 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,22 @@
"dependencyDashboardTitle": "Renovate Dashboard 🤖",
"rebaseWhen": "conflicted",
"commitBodyTable": true,
"suppressNotifications": ["prIgnoreNotification"]
"suppressNotifications": ["prIgnoreNotification"],
"postUpdateOptions": [
"gomodTidy"
],
"regexManagers": [
{
"fileMatch": [
"(^|/)uds-bundle.yaml$",
"(^|/)action.yaml$"
],
"matchStringsStrategy": "recursive",
"matchStrings": [
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?( registryUrl=(?<registryUrl>.*?))?\\s.*?version: (?<currentValue>.*)\\s",
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?( registryUrl=(?<registryUrl>.*?))?\\s.*?ref: (?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
]
}
8 changes: 5 additions & 3 deletions src/test/bundles/04-init/uds-bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
kind: UDSBundle
metadata:
name: all-the-inits
description: deploys both s local and remote init packages
description: deploys both local and remote init packages
version: 0.0.1

# contrived bundle to test local + remote Zarf inits
# cannot do uds remove on this pkg due to having the same name
zarf-packages:
- name: init
path: "../../packages"
ref: v0.31.1
# renovate: datasource=github-tags depName=defenseunicorns/zarf
ref: v0.31.2
optional-components:
- git-server
- name: init
# renovate: datasource=github-tags depName=defenseunicorns/zarf
repository: ghcr.io/defenseunicorns/packages/init
ref: v0.31.1
ref: v0.31.2
optional-components:
- git-server
16 changes: 13 additions & 3 deletions src/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"golang.org/x/mod/modfile"

"github.com/defenseunicorns/uds-cli/src/test"

Expand Down Expand Up @@ -90,16 +91,25 @@ func doAllTheThings(m *testing.M) (int, error) {

func deployZarfInit(t *testing.T) {
if !zarfInitDeployed() {
// todo: renovate this version or grab from deps
zarfVersion := "v0.31.1"
// get Zarf version from go.mod
b, err := os.ReadFile("go.mod")
require.NoError(t, err)
f, err := modfile.Parse("go.mod", b, nil)
require.NoError(t, err)
var zarfVersion string
for _, r := range f.Require {
if r.Mod.Path == "github.com/defenseunicorns/zarf" {
zarfVersion = r.Mod.Version
}
}
e2e.DownloadZarfInitPkg(t, zarfVersion)

bundleDir := "src/test/bundles/04-init"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-all-the-inits-%s-0.0.1.tar.zst", e2e.Arch))

// Create
cmd := strings.Split(fmt.Sprintf("create %s --confirm --insecure", bundleDir), " ")
_, _, err := e2e.UDS(cmd...)
_, _, err = e2e.UDS(cmd...)
require.NoError(t, err)

// Deploy
Expand Down

0 comments on commit 46fff19

Please sign in to comment.