@@ -18,6 +18,7 @@ import (
1818 "context"
1919 "fmt"
2020 "os"
21+ "strconv"
2122 "strings"
2223 "sync"
2324 "time"
@@ -63,15 +64,16 @@ import (
6364
6465type (
6566 RuntimeInstallOptions struct {
66- RuntimeName string
67- RuntimeToken string
68- IngressHost string
69- Insecure bool
70- Version * semver.Version
71- GsCloneOpts * git.CloneOptions
72- InsCloneOpts * git.CloneOptions
73- KubeFactory kube.Factory
74- CommonConfig * runtime.CommonConfig
67+ RuntimeName string
68+ RuntimeToken string
69+ IngressHost string
70+ Insecure bool
71+ SampleInstall bool
72+ Version * semver.Version
73+ GsCloneOpts * git.CloneOptions
74+ InsCloneOpts * git.CloneOptions
75+ KubeFactory kube.Factory
76+ CommonConfig * runtime.CommonConfig
7577 }
7678 RuntimeUninstallOptions struct {
7779 RuntimeName string
@@ -113,12 +115,13 @@ func NewRuntimeCommand() *cobra.Command {
113115
114116func NewRuntimeInstallCommand () * cobra.Command {
115117 var (
116- runtimeName string
117- ingressHost string
118- versionStr string
119- f kube.Factory
120- insCloneOpts * git.CloneOptions
121- gsCloneOpts * git.CloneOptions
118+ runtimeName string
119+ ingressHost string
120+ versionStr string
121+ f kube.Factory
122+ insCloneOpts * git.CloneOptions
123+ gsCloneOpts * git.CloneOptions
124+ sampleInstall bool
122125 finalParameters map [string ]string
123126 )
124127
@@ -145,14 +148,14 @@ func NewRuntimeInstallCommand() *cobra.Command {
145148 if len (args ) > 0 {
146149 runtimeName = args [0 ]
147150 }
148-
151+
149152 if ! store .Get ().Silent && runtimeName == "" {
150153 err := getRuntimeNameFromUserInput (& runtimeName )
151154 if err != nil {
152155 return fmt .Errorf ("%w" , err )
153156 }
154157 }
155-
158+
156159 if runtimeName == "" {
157160 log .G (ctx ).Fatal ("must enter a runtime name" )
158161 }
@@ -167,13 +170,19 @@ func NewRuntimeInstallCommand() *cobra.Command {
167170 return fmt .Errorf ("%w" , err )
168171 }
169172
173+ err = askUserIfToInstallCodefreshSamples (cmd , & sampleInstall )
174+ if err != nil {
175+ return fmt .Errorf ("%w" , err )
176+ }
177+
170178 if gsCloneOpts .Auth .Password == "" {
171179 gsCloneOpts .Auth .Password = insCloneOpts .Auth .Password
172180 }
173181
174182 finalParameters = map [string ]string {
175- "Runtime name" : runtimeName ,
183+ "Runtime name" : runtimeName ,
176184 "Repository URL" : insCloneOpts .Repo ,
185+ "Installing sample resources" : strconv .FormatBool (sampleInstall ),
177186 }
178187
179188 insCloneOpts .Parse ()
@@ -218,13 +227,14 @@ func NewRuntimeInstallCommand() *cobra.Command {
218227 gsCloneOpts .Parse ()
219228
220229 return RunRuntimeInstall (ctx , & RuntimeInstallOptions {
221- RuntimeName : runtimeName ,
222- IngressHost : ingressHost ,
223- Version : version ,
224- Insecure : true ,
225- GsCloneOpts : gsCloneOpts ,
226- InsCloneOpts : insCloneOpts ,
227- KubeFactory : f ,
230+ RuntimeName : runtimeName ,
231+ IngressHost : ingressHost ,
232+ Version : version ,
233+ Insecure : true ,
234+ SampleInstall : sampleInstall ,
235+ GsCloneOpts : gsCloneOpts ,
236+ InsCloneOpts : insCloneOpts ,
237+ KubeFactory : f ,
228238 CommonConfig : & runtime.CommonConfig {
229239 CodefreshBaseURL : cfConfig .GetCurrentContext ().URL ,
230240 },
@@ -234,6 +244,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
234244
235245 cmd .Flags ().StringVar (& ingressHost , "ingress-host" , "" , "The ingress host" )
236246 cmd .Flags ().StringVar (& versionStr , "version" , "" , "The runtime version to install, defaults to latest" )
247+ cmd .Flags ().BoolVar (& sampleInstall , "sample-install" , true , "Installs sample resources, defaults to true" )
237248 cmd .Flags ().DurationVar (& store .Get ().WaitTimeout , "wait-timeout" , store .Get ().WaitTimeout , "How long to wait for the runtime components to be ready" )
238249
239250 insCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
@@ -366,7 +377,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
366377 GsCloneOpts : opts .GsCloneOpts ,
367378 GsName : store .Get ().GitSourceName ,
368379 RuntimeName : opts .RuntimeName ,
369- CreateDemoResources : true ,
380+ CreateDemoResources : opts . SampleInstall ,
370381 }); err != nil {
371382 return fmt .Errorf ("failed to create `%s`: %w" , store .Get ().GitSourceName , err )
372383 }
@@ -647,14 +658,14 @@ func NewRuntimeUninstallCommand() *cobra.Command {
647658 if err != nil {
648659 return fmt .Errorf ("%w" , err )
649660 }
650-
661+
651662 err = ensureGitToken (cmd , cloneOpts )
652663 if err != nil {
653664 return fmt .Errorf ("%w" , err )
654665 }
655-
666+
656667 finalParameters = map [string ]string {
657- "Runtime name" : runtimeName ,
668+ "Runtime name" : runtimeName ,
658669 "Repository URL" : cloneOpts .Repo ,
659670 }
660671
@@ -752,9 +763,9 @@ func deleteRuntimeFromPlatform(ctx context.Context, opts *RuntimeUninstallOption
752763
753764func NewRuntimeUpgradeCommand () * cobra.Command {
754765 var (
755- runtimeName string
756- versionStr string
757- cloneOpts * git.CloneOptions
766+ runtimeName string
767+ versionStr string
768+ cloneOpts * git.CloneOptions
758769 finalParameters map [string ]string
759770 )
760771
@@ -792,7 +803,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
792803 }
793804
794805 finalParameters = map [string ]string {
795- "Runtime name" : runtimeName ,
806+ "Runtime name" : runtimeName ,
796807 "Repository URL" : cloneOpts .Repo ,
797808 }
798809
0 commit comments