From a7cee10e7db41e99e08411de5b7c56951b4fa7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Tue, 24 Oct 2023 15:45:54 +0200 Subject: [PATCH] Better highlight usage of skipPhases for devs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- cli/internal/cmd/apply.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/cli/internal/cmd/apply.go b/cli/internal/cmd/apply.go index 9552143968..44a394d763 100644 --- a/cli/internal/cmd/apply.go +++ b/cli/internal/cmd/apply.go @@ -40,6 +40,8 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" ) +// phases that can be skipped during apply. +// New phases should also be added to [formatSkipPhases]. const ( // skipInfrastructurePhase skips the Terraform apply of the apply process. skipInfrastructurePhase skipPhase = "infrastructure" @@ -57,6 +59,19 @@ const ( skipK8sPhase skipPhase = "k8s" ) +// formatSkipPhases returns a formatted string of all phases that can be skipped. +func formatSkipPhases() string { + return fmt.Sprintf("{ %s }", strings.Join([]string{ + string(skipInfrastructurePhase), + string(skipInitPhase), + string(skipAttestationConfigPhase), + string(skipCertSANsPhase), + string(skipHelmPhase), + string(skipImagePhase), + string(skipK8sPhase), + }, " | ")) +} + // skipPhase is a phase of the upgrade process that can be skipped. type skipPhase string @@ -79,18 +94,6 @@ func (s *skipPhases) add(phases ...skipPhase) { } } -func printAllPhases() string { - return fmt.Sprintf("{ %s }", strings.Join([]string{ - string(skipInfrastructurePhase), - string(skipInitPhase), - string(skipAttestationConfigPhase), - string(skipCertSANsPhase), - string(skipHelmPhase), - string(skipImagePhase), - string(skipK8sPhase), - }, " | ")) -} - // NewApplyCmd creates the apply command. func NewApplyCmd() *cobra.Command { cmd := &cobra.Command{ @@ -109,7 +112,7 @@ func NewApplyCmd() *cobra.Command { cmd.Flags().Duration("timeout", 5*time.Minute, "change helm upgrade timeout\n"+ "Might be useful for slow connections or big clusters.") cmd.Flags().StringSlice("skip-phases", nil, "comma-separated list of upgrade phases to skip\n"+ - fmt.Sprintf("one or multiple of %s", printAllPhases())) + fmt.Sprintf("one or multiple of %s", formatSkipPhases())) must(cmd.Flags().MarkHidden("timeout"))