mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
The fork was already ours everywhere that matters — our image, our IAM (dex is not deployed), hanzo kv behind what the env still called REDIS. Only the vocabulary was upstream's: ARGOCD_* across the Go, the manifests, the docs and the plugin contract, and mkdocs still titled 'Argo CD' pointing at argoproj/argo-cd. ARGOCD_ -> CD_ and REDIS_ -> KV_ across 345 files, plus the 8 e2e/cmp fixtures that assert the plugin env contract — those had to move with the binary, which now emits CD_APP_NAME where they expected ARGOCD_APP_NAME. Left alone deliberately, because renaming them would be wrong: - util/helm/testdata/redis/ and gitops-engine/.../statefulset*.yaml are fixtures for a THIRD-PARTY chart named redis, not our config - util/kustomize/testdata/ likewise - generated.proto regenerates from types.go, which is already clean go build ./... exit 0. LOCKSTEP: the live StatefulSet sets 47 ARGOCD_* names the binary no longer reads. universe 4a5375735 carries the matching manifest change; they deploy together or the controller falls back to defaults. Co-authored-by: Hanzo Dev <[email protected]>
151 lines
3.4 KiB
Go
151 lines
3.4 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func loadOpts(t *testing.T, opts string) {
|
|
t.Helper()
|
|
t.Setenv("CD_OPTS", opts)
|
|
assert.NoError(t, LoadFlags())
|
|
}
|
|
|
|
func loadInvalidOpts(t *testing.T, opts string) {
|
|
t.Helper()
|
|
t.Setenv("CD_OPTS", opts)
|
|
assert.Error(t, LoadFlags())
|
|
}
|
|
|
|
func TestNilOpts(t *testing.T) {
|
|
assert.Equal(t, "foo", GetFlag("foo", "foo"))
|
|
}
|
|
|
|
func TestEmptyOpts(t *testing.T) {
|
|
loadOpts(t, "")
|
|
|
|
assert.Equal(t, "foo", GetFlag("foo", "foo"))
|
|
}
|
|
|
|
func TestRubbishOpts(t *testing.T) {
|
|
loadInvalidOpts(t, "rubbish")
|
|
}
|
|
|
|
func TestBoolFlag(t *testing.T) {
|
|
loadOpts(t, "--foo")
|
|
|
|
assert.True(t, GetBoolFlag("foo"))
|
|
}
|
|
|
|
func TestBoolFlagAtStart(t *testing.T) {
|
|
loadOpts(t, "--foo --bar baz")
|
|
|
|
assert.True(t, GetBoolFlag("foo"))
|
|
}
|
|
|
|
func TestBoolFlagInMiddle(t *testing.T) {
|
|
loadOpts(t, "--bar baz --foo --qux")
|
|
|
|
assert.True(t, GetBoolFlag("foo"))
|
|
}
|
|
|
|
func TestBooleanFlagAtEnd(t *testing.T) {
|
|
loadOpts(t, "--bar baz --foo")
|
|
|
|
assert.True(t, GetBoolFlag("foo"))
|
|
}
|
|
|
|
func TestIntFlag(t *testing.T) {
|
|
loadOpts(t, "--foo 2")
|
|
|
|
assert.Equal(t, 2, GetIntFlag("foo", 0))
|
|
}
|
|
|
|
func TestIntFlagAtStart(t *testing.T) {
|
|
loadOpts(t, "--foo 2 --bar baz")
|
|
|
|
assert.Equal(t, 2, GetIntFlag("foo", 0))
|
|
}
|
|
|
|
func TestIntFlagInMiddle(t *testing.T) {
|
|
loadOpts(t, "--bar baz --foo 2 --qux")
|
|
|
|
assert.Equal(t, 2, GetIntFlag("foo", 0))
|
|
}
|
|
|
|
func TestIntFlagAtEnd(t *testing.T) {
|
|
loadOpts(t, "--bar baz --foo 2")
|
|
|
|
assert.Equal(t, 2, GetIntFlag("foo", 0))
|
|
}
|
|
|
|
func TestStringSliceFlag(t *testing.T) {
|
|
loadOpts(t, "--header='Content-Type: application/json; charset=utf-8,Strict-Transport-Security: max-age=31536000'")
|
|
strings := GetStringSliceFlag("header", []string{})
|
|
|
|
assert.Len(t, strings, 2)
|
|
assert.Equal(t, "Content-Type: application/json; charset=utf-8", strings[0])
|
|
assert.Equal(t, "Strict-Transport-Security: max-age=31536000", strings[1])
|
|
}
|
|
|
|
func TestStringSliceFlagAtStart(t *testing.T) {
|
|
loadOpts(t, "--header='Strict-Transport-Security: max-age=31536000' --bar baz")
|
|
strings := GetStringSliceFlag("header", []string{})
|
|
|
|
assert.Len(t, strings, 1)
|
|
assert.Equal(t, "Strict-Transport-Security: max-age=31536000", strings[0])
|
|
}
|
|
|
|
func TestStringSliceFlagInMiddle(t *testing.T) {
|
|
loadOpts(t, "--bar baz --header='Strict-Transport-Security: max-age=31536000' --qux")
|
|
strings := GetStringSliceFlag("header", []string{})
|
|
|
|
assert.Len(t, strings, 1)
|
|
assert.Equal(t, "Strict-Transport-Security: max-age=31536000", strings[0])
|
|
}
|
|
|
|
func TestStringSliceFlagAtEnd(t *testing.T) {
|
|
loadOpts(t, "--bar baz --header='Strict-Transport-Security: max-age=31536000'")
|
|
strings := GetStringSliceFlag("header", []string{})
|
|
|
|
assert.Len(t, strings, 1)
|
|
assert.Equal(t, "Strict-Transport-Security: max-age=31536000", strings[0])
|
|
}
|
|
|
|
func TestFlagAtStart(t *testing.T) {
|
|
loadOpts(t, "--foo bar")
|
|
|
|
assert.Equal(t, "bar", GetFlag("foo", ""))
|
|
}
|
|
|
|
func TestFlagInTheMiddle(t *testing.T) {
|
|
loadOpts(t, "--baz --foo bar --qux")
|
|
|
|
assert.Equal(t, "bar", GetFlag("foo", ""))
|
|
}
|
|
|
|
func TestFlagAtTheEnd(t *testing.T) {
|
|
loadOpts(t, "--baz --foo bar")
|
|
|
|
assert.Equal(t, "bar", GetFlag("foo", ""))
|
|
}
|
|
|
|
func TestFlagWithSingleQuotes(t *testing.T) {
|
|
loadOpts(t, "--foo 'bar baz'")
|
|
|
|
assert.Equal(t, "bar baz", GetFlag("foo", ""))
|
|
}
|
|
|
|
func TestFlagWithDoubleQuotes(t *testing.T) {
|
|
loadOpts(t, "--foo \"bar baz\"")
|
|
|
|
assert.Equal(t, "bar baz", GetFlag("foo", ""))
|
|
}
|
|
|
|
func TestFlagWithEqualSign(t *testing.T) {
|
|
loadOpts(t, "--foo=bar")
|
|
|
|
assert.Equal(t, "bar", GetFlag("foo", ""))
|
|
}
|