|
|
@ -288,7 +288,9 @@ func assertGoldenFile(goldenFile string) assertFunc {
|
|
|
|
// is pre-processed with the specified templateValues.
|
|
|
|
// is pre-processed with the specified templateValues.
|
|
|
|
func assertGoldenTemplateFile(goldenFile string, templateValues map[string]string) assertFunc {
|
|
|
|
func assertGoldenTemplateFile(goldenFile string, templateValues map[string]string) assertFunc {
|
|
|
|
goldenFileContents, fileErr := os.ReadFile(goldenFile)
|
|
|
|
goldenFileContents, fileErr := os.ReadFile(goldenFile)
|
|
|
|
return func(output string, err error) error {
|
|
|
|
return assert(
|
|
|
|
|
|
|
|
assertSuccess(),
|
|
|
|
|
|
|
|
func(output string, err error) error {
|
|
|
|
if fileErr != nil {
|
|
|
|
if fileErr != nil {
|
|
|
|
return fmt.Errorf("Error reading golden file '%s': %s", goldenFile, fileErr)
|
|
|
|
return fmt.Errorf("Error reading golden file '%s': %s", goldenFile, fileErr)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -317,7 +319,7 @@ func assertGoldenTemplateFile(goldenFile string, templateValues map[string]strin
|
|
|
|
return fmt.Errorf("Mismatch from golden file '%s': %v", goldenFile, assertErr)
|
|
|
|
return fmt.Errorf("Mismatch from golden file '%s': %v", goldenFile, assertErr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type TestClusterMode int
|
|
|
|
type TestClusterMode int
|
|
|
@ -341,7 +343,6 @@ type cmdTestCase struct {
|
|
|
|
|
|
|
|
|
|
|
|
func (cmd *cmdTestCase) runTestCmd(t *testing.T) {
|
|
|
|
func (cmd *cmdTestCase) runTestCmd(t *testing.T) {
|
|
|
|
actual, testErr := executeCommand(cmd.args)
|
|
|
|
actual, testErr := executeCommand(cmd.args)
|
|
|
|
|
|
|
|
|
|
|
|
// If the cmd error is a change, discard it
|
|
|
|
// If the cmd error is a change, discard it
|
|
|
|
if isChangeError(testErr) {
|
|
|
|
if isChangeError(testErr) {
|
|
|
|
testErr = nil
|
|
|
|
testErr = nil
|
|
|
@ -383,15 +384,51 @@ func executeCommand(cmd string) (string, error) {
|
|
|
|
return result, err
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// resetCmdArgs resets the flags for various cmd
|
|
|
|
|
|
|
|
// Note: this will also clear default value of the flags set in init()
|
|
|
|
func resetCmdArgs() {
|
|
|
|
func resetCmdArgs() {
|
|
|
|
|
|
|
|
*kubeconfigArgs.Namespace = rootArgs.defaults.Namespace
|
|
|
|
|
|
|
|
alertArgs = alertFlags{}
|
|
|
|
|
|
|
|
alertProviderArgs = alertProviderFlags{}
|
|
|
|
|
|
|
|
bootstrapArgs = NewBootstrapFlags()
|
|
|
|
|
|
|
|
bServerArgs = bServerFlags{}
|
|
|
|
|
|
|
|
buildKsArgs = buildKsFlags{}
|
|
|
|
|
|
|
|
checkArgs = checkFlags{}
|
|
|
|
createArgs = createFlags{}
|
|
|
|
createArgs = createFlags{}
|
|
|
|
|
|
|
|
deleteArgs = deleteFlags{}
|
|
|
|
|
|
|
|
diffKsArgs = diffKsFlags{}
|
|
|
|
|
|
|
|
exportArgs = exportFlags{}
|
|
|
|
getArgs = GetFlags{}
|
|
|
|
getArgs = GetFlags{}
|
|
|
|
|
|
|
|
gitArgs = gitFlags{}
|
|
|
|
|
|
|
|
githubArgs = githubFlags{}
|
|
|
|
|
|
|
|
gitlabArgs = gitlabFlags{}
|
|
|
|
|
|
|
|
helmReleaseArgs = helmReleaseFlags{
|
|
|
|
|
|
|
|
reconcileStrategy: "ChartVersion",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
imagePolicyArgs = imagePolicyFlags{}
|
|
|
|
|
|
|
|
imageRepoArgs = imageRepoFlags{}
|
|
|
|
|
|
|
|
imageUpdateArgs = imageUpdateFlags{}
|
|
|
|
|
|
|
|
kustomizationArgs = NewKustomizationFlags()
|
|
|
|
|
|
|
|
receiverArgs = receiverFlags{}
|
|
|
|
|
|
|
|
resumeArgs = ResumeFlags{}
|
|
|
|
|
|
|
|
rhrArgs = reconcileHelmReleaseFlags{}
|
|
|
|
|
|
|
|
rksArgs = reconcileKsFlags{}
|
|
|
|
|
|
|
|
secretGitArgs = NewSecretGitFlags()
|
|
|
|
|
|
|
|
secretHelmArgs = secretHelmFlags{}
|
|
|
|
|
|
|
|
secretTLSArgs = secretTLSFlags{}
|
|
|
|
|
|
|
|
sourceBucketArgs = sourceBucketFlags{}
|
|
|
|
|
|
|
|
sourceGitArgs = newSourceGitFlags()
|
|
|
|
sourceHelmArgs = sourceHelmFlags{}
|
|
|
|
sourceHelmArgs = sourceHelmFlags{}
|
|
|
|
sourceOCIRepositoryArgs = sourceOCIRepositoryFlags{}
|
|
|
|
sourceOCIRepositoryArgs = sourceOCIRepositoryFlags{}
|
|
|
|
sourceGitArgs = sourceGitFlags{}
|
|
|
|
suspendArgs = SuspendFlags{}
|
|
|
|
sourceBucketArgs = sourceBucketFlags{}
|
|
|
|
tenantArgs = tenantFlags{}
|
|
|
|
secretGitArgs = NewSecretGitFlags()
|
|
|
|
traceArgs = traceFlags{}
|
|
|
|
*kubeconfigArgs.Namespace = rootArgs.defaults.Namespace
|
|
|
|
treeKsArgs = TreeKsFlags{}
|
|
|
|
|
|
|
|
uninstallArgs = uninstallFlags{}
|
|
|
|
|
|
|
|
versionArgs = versionFlags{
|
|
|
|
|
|
|
|
output: "yaml",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func isChangeError(err error) bool {
|
|
|
|
func isChangeError(err error) bool {
|
|
|
|