From 6843a36236f5cf4b72d4f1ceff6f28f2db102f4a Mon Sep 17 00:00:00 2001 From: Amit Watve Date: Tue, 2 Feb 2021 14:48:44 -0800 Subject: [PATCH] move out strategy to it's own type --- pkg/build/options.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/build/options.go b/pkg/build/options.go index 42d70f75..0a23d527 100644 --- a/pkg/build/options.go +++ b/pkg/build/options.go @@ -20,6 +20,15 @@ import ( "fmt" ) +type buildStrategy string + +const ( + // bazelStrategy builds and (optionally) stages using bazel + bazelStrategy buildStrategy = "bazel" + // makeStrategy builds using make and (optionally) stages using krel + makeStrategy buildStrategy = "make" +) + type Options struct { Strategy string `flag:"~strategy" desc:"Determines the build strategy to use either make or bazel."` StageLocation string `flag:"~stage" desc:"Upload binaries to gs://bucket/ci/job-suffix if set"` @@ -36,7 +45,7 @@ func (o *Options) Validate() error { func (o *Options) implementationFromStrategy() error { switch o.Strategy { - case "bazel": + case string(bazelStrategy): bazel := &Bazel{ RepoRoot: o.RepoRoot, StageLocation: o.StageLocation, @@ -44,7 +53,7 @@ func (o *Options) implementationFromStrategy() error { } o.Builder = bazel o.Stager = bazel - case "make": + case string(makeStrategy): o.Builder = &MakeBuilder{ RepoRoot: o.RepoRoot, }