@@ -18,6 +18,7 @@ import (
18
18
"context"
19
19
"fmt"
20
20
"os"
21
+ "strconv"
21
22
"strings"
22
23
"sync"
23
24
"time"
@@ -63,15 +64,16 @@ import (
63
64
64
65
type (
65
66
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
75
77
}
76
78
RuntimeUninstallOptions struct {
77
79
RuntimeName string
@@ -113,12 +115,13 @@ func NewRuntimeCommand() *cobra.Command {
113
115
114
116
func NewRuntimeInstallCommand () * cobra.Command {
115
117
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
122
125
finalParameters map [string ]string
123
126
)
124
127
@@ -145,14 +148,14 @@ func NewRuntimeInstallCommand() *cobra.Command {
145
148
if len (args ) > 0 {
146
149
runtimeName = args [0 ]
147
150
}
148
-
151
+
149
152
if ! store .Get ().Silent && runtimeName == "" {
150
153
err := getRuntimeNameFromUserInput (& runtimeName )
151
154
if err != nil {
152
155
return fmt .Errorf ("%w" , err )
153
156
}
154
157
}
155
-
158
+
156
159
if runtimeName == "" {
157
160
log .G (ctx ).Fatal ("must enter a runtime name" )
158
161
}
@@ -167,13 +170,19 @@ func NewRuntimeInstallCommand() *cobra.Command {
167
170
return fmt .Errorf ("%w" , err )
168
171
}
169
172
173
+ err = askUserIfToInstallCodefreshSamples (cmd , & sampleInstall )
174
+ if err != nil {
175
+ return fmt .Errorf ("%w" , err )
176
+ }
177
+
170
178
if gsCloneOpts .Auth .Password == "" {
171
179
gsCloneOpts .Auth .Password = insCloneOpts .Auth .Password
172
180
}
173
181
174
182
finalParameters = map [string ]string {
175
- "Runtime name" : runtimeName ,
183
+ "Runtime name" : runtimeName ,
176
184
"Repository URL" : insCloneOpts .Repo ,
185
+ "Installing sample resources" : strconv .FormatBool (sampleInstall ),
177
186
}
178
187
179
188
insCloneOpts .Parse ()
@@ -218,13 +227,14 @@ func NewRuntimeInstallCommand() *cobra.Command {
218
227
gsCloneOpts .Parse ()
219
228
220
229
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 ,
228
238
CommonConfig : & runtime.CommonConfig {
229
239
CodefreshBaseURL : cfConfig .GetCurrentContext ().URL ,
230
240
},
@@ -234,6 +244,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
234
244
235
245
cmd .Flags ().StringVar (& ingressHost , "ingress-host" , "" , "The ingress host" )
236
246
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" )
237
248
cmd .Flags ().DurationVar (& store .Get ().WaitTimeout , "wait-timeout" , store .Get ().WaitTimeout , "How long to wait for the runtime components to be ready" )
238
249
239
250
insCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
@@ -366,7 +377,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
366
377
GsCloneOpts : opts .GsCloneOpts ,
367
378
GsName : store .Get ().GitSourceName ,
368
379
RuntimeName : opts .RuntimeName ,
369
- CreateDemoResources : true ,
380
+ CreateDemoResources : opts . SampleInstall ,
370
381
}); err != nil {
371
382
return fmt .Errorf ("failed to create `%s`: %w" , store .Get ().GitSourceName , err )
372
383
}
@@ -647,14 +658,14 @@ func NewRuntimeUninstallCommand() *cobra.Command {
647
658
if err != nil {
648
659
return fmt .Errorf ("%w" , err )
649
660
}
650
-
661
+
651
662
err = ensureGitToken (cmd , cloneOpts )
652
663
if err != nil {
653
664
return fmt .Errorf ("%w" , err )
654
665
}
655
-
666
+
656
667
finalParameters = map [string ]string {
657
- "Runtime name" : runtimeName ,
668
+ "Runtime name" : runtimeName ,
658
669
"Repository URL" : cloneOpts .Repo ,
659
670
}
660
671
@@ -752,9 +763,9 @@ func deleteRuntimeFromPlatform(ctx context.Context, opts *RuntimeUninstallOption
752
763
753
764
func NewRuntimeUpgradeCommand () * cobra.Command {
754
765
var (
755
- runtimeName string
756
- versionStr string
757
- cloneOpts * git.CloneOptions
766
+ runtimeName string
767
+ versionStr string
768
+ cloneOpts * git.CloneOptions
758
769
finalParameters map [string ]string
759
770
)
760
771
@@ -792,7 +803,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
792
803
}
793
804
794
805
finalParameters = map [string ]string {
795
- "Runtime name" : runtimeName ,
806
+ "Runtime name" : runtimeName ,
796
807
"Repository URL" : cloneOpts .Repo ,
797
808
}
798
809
0 commit comments