diff --git a/cmd/flux/debug_helmrelease.go b/cmd/flux/debug_helmrelease.go index 4f6a9d8a..0bde73bc 100644 --- a/cmd/flux/debug_helmrelease.go +++ b/cmd/flux/debug_helmrelease.go @@ -86,6 +86,7 @@ func debugHelmReleaseCmdRun(cmd *cobra.Command, args []string) error { if err != nil { return err } + rootCmd.Println("# Status documentation: https://fluxcd.io/flux/components/helm/helmreleases/#helmrelease-status") rootCmd.Print(string(status)) if debugHelmReleaseArgs.showValues { rootCmd.Println("---") diff --git a/cmd/flux/debug_kustomization.go b/cmd/flux/debug_kustomization.go index 86050564..026b150c 100644 --- a/cmd/flux/debug_kustomization.go +++ b/cmd/flux/debug_kustomization.go @@ -18,6 +18,7 @@ package main import ( "context" + "errors" "fmt" "sort" "strings" @@ -89,11 +90,16 @@ func debugKustomizationCmdRun(cmd *cobra.Command, args []string) error { if err != nil { return err } + rootCmd.Println("# Status documentation: https://fluxcd.io/flux/components/kustomize/kustomizations/#kustomization-status") rootCmd.Print(string(status)) return nil } if debugKustomizationArgs.showVars { + if ks.Spec.PostBuild == nil { + return errors.New("no post build substitutions found") + } + ksObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(ks) if err != nil { return err @@ -106,6 +112,9 @@ func debugKustomizationCmdRun(cmd *cobra.Command, args []string) error { if len(ks.Spec.PostBuild.Substitute) > 0 { for k, v := range ks.Spec.PostBuild.Substitute { + // Remove new lines from the values as they are not supported. + // Replicates the controller behavior from + // https://github.com/fluxcd/pkg/blob/main/kustomize/kustomize_varsub.go finalVars[k] = strings.ReplaceAll(v, "\n", "") } } diff --git a/cmd/flux/testdata/debug_helmrelease/status.golden.yaml b/cmd/flux/testdata/debug_helmrelease/status.golden.yaml index 8f988e76..14c35c76 100644 --- a/cmd/flux/testdata/debug_helmrelease/status.golden.yaml +++ b/cmd/flux/testdata/debug_helmrelease/status.golden.yaml @@ -1 +1,2 @@ +# Status documentation: https://fluxcd.io/flux/components/helm/helmreleases/#helmrelease-status observedGeneration: -1 diff --git a/cmd/flux/testdata/debug_kustomization/status.golden.yaml b/cmd/flux/testdata/debug_kustomization/status.golden.yaml index 8f988e76..a71799aa 100644 --- a/cmd/flux/testdata/debug_kustomization/status.golden.yaml +++ b/cmd/flux/testdata/debug_kustomization/status.golden.yaml @@ -1 +1,2 @@ +# Status documentation: https://fluxcd.io/flux/components/kustomize/kustomizations/#kustomization-status observedGeneration: -1