Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add file type variables to bundles #631

Merged
merged 33 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf334e6
feat: add file type variables to bundles
TristanHoladay May 22, 2024
fbf8229
add FileVariables to BundleDeployOptions.
TristanHoladay May 22, 2024
3a63013
adding loadFileContents() to loadVariables().
TristanHoladay May 22, 2024
0b6f219
add file handling from loadVariables()
TristanHoladay May 23, 2024
1e271cd
fix deploy_test call of loadVariables()
TristanHoladay May 23, 2024
405327e
test for zarf var setting; adding file handling to processOverrideVar…
TristanHoladay May 24, 2024
d5b375b
small refactor; attempting helm.FileValues (bad format errors)
TristanHoladay May 24, 2024
5c97215
cleanup helm file handling; base64 test pub key.
TristanHoladay May 28, 2024
9a835a3
lint fixes
TristanHoladay May 28, 2024
7dd839b
merge main and resolve; refactor file var handling
TristanHoladay May 29, 2024
39d2187
fix loadViperConfig duplicate; fix file handling in override add
TristanHoladay May 29, 2024
cd23c1a
refactor ChartVariableType; refactor tests.
TristanHoladay May 29, 2024
bec07c9
lint fix
TristanHoladay May 29, 2024
a2fe420
file path handling made more reusable; fixed tests.
TristanHoladay May 29, 2024
dc8613c
Merge branch 'main' into add-file-type-var
TristanHoladay May 29, 2024
3a407ec
fix typo in test
TristanHoladay May 29, 2024
a5afc3e
Merge branch 'main' into add-file-type-var
TristanHoladay May 29, 2024
513ed8e
lint fix'
TristanHoladay May 29, 2024
daf9076
add docs; make test less brittle.
TristanHoladay May 29, 2024
05080fa
add to docs; rename test
TristanHoladay May 29, 2024
a2b4276
move formAndCheckFilePath and annotate
TristanHoladay May 30, 2024
2d11b46
file handling and docs refactors
TristanHoladay May 31, 2024
bc7d4d0
handle different value source paths.
TristanHoladay Jun 3, 2024
18b13ec
refactor tests.
TristanHoladay Jun 3, 2024
ee2e768
update schema and fix test conflicts
TristanHoladay Jun 3, 2024
3c420ce
change ValueSource to Source to remove confusion with type.
TristanHoladay Jun 3, 2024
6d2914a
fix wrong property name in unit test
TristanHoladay Jun 3, 2024
d72cde9
revert e2e secret test removals
TristanHoladay Jun 3, 2024
33daef1
clean up tests from previous iterations
TristanHoladay Jun 4, 2024
861f15f
lifted unit tests up to processOverrideVariables
TristanHoladay Jun 4, 2024
85a5ad3
check override map in unit test for correct FileValues
TristanHoladay Jun 4, 2024
e995e65
Update src/pkg/bundle/deploy_test.go
TristanHoladay Jun 5, 2024
9b457c9
switch Equals to Equal
TristanHoladay Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update schema and fix test conflicts
  • Loading branch information
TristanHoladay committed Jun 3, 2024
commit ee2e768b80f3f8d5d1876466f0b9df28894ed881
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ packages:
description: "Set the message for podinfo's UI"
- name: SECRET_VAL
path: "testSecret"
type: file
description: "testing a secret value"
- name: SECURITY_CTX
path: "podinfo.securityContext"
Expand Down
19 changes: 6 additions & 13 deletions src/test/e2e/variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,20 @@ func TestBundleWithEnvVarHelmOverrides(t *testing.T) {
deployZarfInit(t)
e2e.HelmDepUpdate(t, "src/test/packages/helm/unicorn-podinfo")
e2e.CreateZarfPkg(t, "src/test/packages/helm", false)

// create and deploy bundle
bundleDir := "src/test/bundles/07-helm-overrides"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-helm-overrides-%s-0.0.1.tar.zst", e2e.Arch))

color := "purple"
b64Secret := "dGhhdCBhaW50IG15IHRydWNr"
err := os.Setenv("UDS_CONFIG", filepath.Join("src/test/bundles/07-helm-overrides", "uds-config.yaml"))
err := os.Setenv("UDS_CONFIG", filepath.Join(bundleDir, "uds-config.yaml"))
require.NoError(t, err)
err = os.Setenv("UDS_UI_COLOR", color)
require.NoError(t, err)
err = os.Setenv("UDS_UI_MSG", "im set by an env var")
require.NoError(t, err)
err = os.Setenv("UDS_SECRET_VAL", b64Secret)
require.NoError(t, err)

// create and deploy bundle
bundleDir := "src/test/bundles/07-helm-overrides"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-helm-overrides-%s-0.0.1.tar.zst", e2e.Arch))
createLocal(t, bundleDir, e2e.Arch)
deploy(t, bundlePath)

Expand All @@ -286,13 +286,6 @@ func TestBundleWithEnvVarHelmOverrides(t *testing.T) {
require.NoError(t, err)
})

t.Run("check override secret val", func(t *testing.T) {
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
cmd := strings.Split("z tools kubectl get secret test-secret -n podinfo -o jsonpath=\"{.data.test}\"", " ")
secretValue, _, err := e2e.UDS(cmd...)
require.Equal(t, fmt.Sprintf("\"%s\"", b64Secret), secretValue)
require.NoError(t, err)
})

t.Run("ensure --set overrides take precedence over env vars", func(t *testing.T) {
deployCmd := fmt.Sprintf("deploy %s --set UI_COLOR=orange --set helm-overrides.ui_msg=foo --confirm", bundlePath)
_, _, err := e2e.UDS(strings.Split(deployCmd, " ")...)
Expand Down
2 changes: 1 addition & 1 deletion src/types/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type BundleChartVariable struct {
Description string `json:"description,omitempty" jsonschema:"name=Description of the variable"`
Default interface{} `json:"default,omitempty" jsonschema:"name=The default value to set"`
Type ChartVariableType `json:"type,omitempty" jsonschema:"description=The type of value to be processed,enum=raw,enum=file"`
ValueSource string
ValueSource string `json:"source,omitempty" jsonschema:"description=Where the value is set from"`
}

// BundleVariableImport represents variables in the bundle
Expand Down
4 changes: 4 additions & 0 deletions uds.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
],
"type": "string",
"description": "The type of value to be processed"
},
"source": {
"type": "string",
"description": "Where the value is set from"
}
},
"additionalProperties": false,
Expand Down
Loading