@@ -51,6 +51,7 @@ import (
51
51
type (
52
52
RuntimeInstallOptions struct {
53
53
RuntimeName string
54
+ Version * semver.Version
54
55
gsCloneOpts * git.CloneOptions
55
56
insCloneOpts * git.CloneOptions
56
57
KubeFactory kube.Factory
@@ -91,6 +92,7 @@ func NewRuntimeCommand() *cobra.Command {
91
92
92
93
func NewRuntimeInstallCommand () * cobra.Command {
93
94
var (
95
+ versionStr string
94
96
f kube.Factory
95
97
insCloneOpts * git.CloneOptions
96
98
gsCloneOpts * git.CloneOptions
@@ -127,20 +129,33 @@ func NewRuntimeInstallCommand() *cobra.Command {
127
129
gsCloneOpts .Parse ()
128
130
},
129
131
RunE : func (cmd * cobra.Command , args []string ) error {
132
+ var (
133
+ version * semver.Version
134
+ err error
135
+ )
130
136
ctx := cmd .Context ()
131
137
if len (args ) < 1 {
132
138
log .G (ctx ).Fatal ("must enter runtime name" )
133
139
}
134
140
141
+ if versionStr != "" {
142
+ version , err = semver .NewVersion (versionStr )
143
+ if err != nil {
144
+ return err
145
+ }
146
+ }
147
+
135
148
return RunRuntimeInstall (ctx , & RuntimeInstallOptions {
136
149
RuntimeName : args [0 ],
150
+ Version : version ,
137
151
gsCloneOpts : gsCloneOpts ,
138
152
insCloneOpts : insCloneOpts ,
139
153
KubeFactory : f ,
140
154
})
141
155
},
142
156
}
143
157
158
+ cmd .Flags ().StringVar (& versionStr , "version" , "" , "The runtime version to install, defaults to latest" )
144
159
insCloneOpts = git .AddFlags (cmd , & git.AddFlagsOptions {
145
160
Prefix : "install" ,
146
161
CreateIfNotExist : true ,
@@ -158,13 +173,13 @@ func NewRuntimeInstallCommand() *cobra.Command {
158
173
}
159
174
160
175
func RunRuntimeInstall (ctx context.Context , opts * RuntimeInstallOptions ) error {
161
- rt , err := runtime .Download (nil , opts .RuntimeName )
176
+ rt , err := runtime .Download (opts . Version , opts .RuntimeName )
162
177
if err != nil {
163
178
return fmt .Errorf ("failed to download runtime definition: %w" , err )
164
179
}
165
180
166
181
err = apcmd .RunRepoBootstrap (ctx , & apcmd.RepoBootstrapOptions {
167
- AppSpecifier : rt .Spec .BootstrapSpecifier ,
182
+ AppSpecifier : rt .Spec .FullSpecifier () ,
168
183
Namespace : opts .RuntimeName ,
169
184
KubeFactory : opts .KubeFactory ,
170
185
CloneOptions : opts .insCloneOpts ,
@@ -183,7 +198,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
183
198
184
199
for _ , component := range rt .Spec .Components {
185
200
log .G (ctx ).Infof ("creating component '%s'" , component .Name )
186
- if err = component .CreateApp (ctx , opts .KubeFactory , opts .insCloneOpts , opts .RuntimeName ); err != nil {
201
+ if err = component .CreateApp (ctx , opts .KubeFactory , opts .insCloneOpts , opts .RuntimeName , rt . Spec . Version ); err != nil {
187
202
return fmt .Errorf ("failed to create '%s' application: %w" , component .Name , err )
188
203
}
189
204
}
@@ -327,7 +342,8 @@ func RunRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
327
342
328
343
func NewRuntimeUpgradeCommand () * cobra.Command {
329
344
var (
330
- cloneOpts * git.CloneOptions
345
+ versionStr string
346
+ cloneOpts * git.CloneOptions
331
347
)
332
348
333
349
cmd := & cobra.Command {
@@ -351,14 +367,20 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
351
367
cloneOpts .Parse ()
352
368
},
353
369
RunE : func (cmd * cobra.Command , args []string ) error {
354
- var version * semver.Version
370
+ var (
371
+ version * semver.Version
372
+ err error
373
+ )
355
374
ctx := cmd .Context ()
356
375
if len (args ) < 1 {
357
376
log .G (ctx ).Fatal ("must enter runtime name" )
358
377
}
359
378
360
- if len (args ) > 1 {
361
- version = semver .MustParse (args [1 ])
379
+ if versionStr != "" {
380
+ version , err = semver .NewVersion (versionStr )
381
+ if err != nil {
382
+ return err
383
+ }
362
384
}
363
385
364
386
return RunRuntimeUpgrade (ctx , & RuntimeUpgradeOptions {
@@ -369,6 +391,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
369
391
},
370
392
}
371
393
394
+ cmd .Flags ().StringVar (& versionStr , "version" , "" , "The runtime version to upgrade to, defaults to latest" )
372
395
cloneOpts = git .AddFlags (cmd , & git.AddFlagsOptions {
373
396
FS : memfs .New (),
374
397
})
@@ -415,7 +438,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
415
438
416
439
for _ , component := range newComponents {
417
440
log .G (ctx ).Infof ("Creating app '%s'" , component .Name )
418
- if err = component .CreateApp (ctx , nil , opts .CloneOpts , opts .RuntimeName ); err != nil {
441
+ if err = component .CreateApp (ctx , nil , opts .CloneOpts , opts .RuntimeName , newRt . Spec . Version ); err != nil {
419
442
return fmt .Errorf ("failed to create '%s' application: %w" , component .Name , err )
420
443
}
421
444
}
@@ -455,7 +478,7 @@ func createComponentsReporter(ctx context.Context, cloneOpts *git.CloneOptions,
455
478
Type : application .AppTypeDirectory ,
456
479
URL : cloneOpts .URL () + "/" + resPath ,
457
480
}
458
- if err := appDef .CreateApp (ctx , opts .KubeFactory , cloneOpts , opts .RuntimeName ); err != nil {
481
+ if err := appDef .CreateApp (ctx , opts .KubeFactory , cloneOpts , opts .RuntimeName , nil ); err != nil {
459
482
return err
460
483
}
461
484
@@ -835,7 +858,7 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon
835
858
Type : application .AppTypeDirectory ,
836
859
URL : insCloneOpts .URL () + insFs .Join (insFs .Root (), resPath ),
837
860
}
838
- if err = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName ); err != nil {
861
+ if err = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName , nil ); err != nil {
839
862
return fmt .Errorf ("failed to create git-source: %w" , err )
840
863
}
841
864
0 commit comments