@@ -51,6 +51,7 @@ import (
5151type (
5252 RuntimeInstallOptions struct {
5353 RuntimeName string
54+ Version * semver.Version
5455 gsCloneOpts * git.CloneOptions
5556 insCloneOpts * git.CloneOptions
5657 KubeFactory kube.Factory
@@ -91,6 +92,7 @@ func NewRuntimeCommand() *cobra.Command {
9192
9293func NewRuntimeInstallCommand () * cobra.Command {
9394 var (
95+ versionStr string
9496 f kube.Factory
9597 insCloneOpts * git.CloneOptions
9698 gsCloneOpts * git.CloneOptions
@@ -127,20 +129,33 @@ func NewRuntimeInstallCommand() *cobra.Command {
127129 gsCloneOpts .Parse ()
128130 },
129131 RunE : func (cmd * cobra.Command , args []string ) error {
132+ var (
133+ version * semver.Version
134+ err error
135+ )
130136 ctx := cmd .Context ()
131137 if len (args ) < 1 {
132138 log .G (ctx ).Fatal ("must enter runtime name" )
133139 }
134140
141+ if versionStr != "" {
142+ version , err = semver .NewVersion (versionStr )
143+ if err != nil {
144+ return err
145+ }
146+ }
147+
135148 return RunRuntimeInstall (ctx , & RuntimeInstallOptions {
136149 RuntimeName : args [0 ],
150+ Version : version ,
137151 gsCloneOpts : gsCloneOpts ,
138152 insCloneOpts : insCloneOpts ,
139153 KubeFactory : f ,
140154 })
141155 },
142156 }
143157
158+ cmd .Flags ().StringVar (& versionStr , "version" , "" , "The runtime version to install, defaults to latest" )
144159 insCloneOpts = git .AddFlags (cmd , & git.AddFlagsOptions {
145160 Prefix : "install" ,
146161 CreateIfNotExist : true ,
@@ -158,13 +173,13 @@ func NewRuntimeInstallCommand() *cobra.Command {
158173}
159174
160175func RunRuntimeInstall (ctx context.Context , opts * RuntimeInstallOptions ) error {
161- rt , err := runtime .Download (nil , opts .RuntimeName )
176+ rt , err := runtime .Download (opts . Version , opts .RuntimeName )
162177 if err != nil {
163178 return fmt .Errorf ("failed to download runtime definition: %w" , err )
164179 }
165180
166181 err = apcmd .RunRepoBootstrap (ctx , & apcmd.RepoBootstrapOptions {
167- AppSpecifier : rt .Spec .BootstrapSpecifier ,
182+ AppSpecifier : rt .Spec .FullSpecifier () ,
168183 Namespace : opts .RuntimeName ,
169184 KubeFactory : opts .KubeFactory ,
170185 CloneOptions : opts .insCloneOpts ,
@@ -183,7 +198,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
183198
184199 for _ , component := range rt .Spec .Components {
185200 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 {
187202 return fmt .Errorf ("failed to create '%s' application: %w" , component .Name , err )
188203 }
189204 }
@@ -327,7 +342,8 @@ func RunRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
327342
328343func NewRuntimeUpgradeCommand () * cobra.Command {
329344 var (
330- cloneOpts * git.CloneOptions
345+ versionStr string
346+ cloneOpts * git.CloneOptions
331347 )
332348
333349 cmd := & cobra.Command {
@@ -351,14 +367,20 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
351367 cloneOpts .Parse ()
352368 },
353369 RunE : func (cmd * cobra.Command , args []string ) error {
354- var version * semver.Version
370+ var (
371+ version * semver.Version
372+ err error
373+ )
355374 ctx := cmd .Context ()
356375 if len (args ) < 1 {
357376 log .G (ctx ).Fatal ("must enter runtime name" )
358377 }
359378
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+ }
362384 }
363385
364386 return RunRuntimeUpgrade (ctx , & RuntimeUpgradeOptions {
@@ -369,6 +391,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
369391 },
370392 }
371393
394+ cmd .Flags ().StringVar (& versionStr , "version" , "" , "The runtime version to upgrade to, defaults to latest" )
372395 cloneOpts = git .AddFlags (cmd , & git.AddFlagsOptions {
373396 FS : memfs .New (),
374397 })
@@ -415,7 +438,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
415438
416439 for _ , component := range newComponents {
417440 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 {
419442 return fmt .Errorf ("failed to create '%s' application: %w" , component .Name , err )
420443 }
421444 }
@@ -455,7 +478,7 @@ func createComponentsReporter(ctx context.Context, cloneOpts *git.CloneOptions,
455478 Type : application .AppTypeDirectory ,
456479 URL : cloneOpts .URL () + "/" + resPath ,
457480 }
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 {
459482 return err
460483 }
461484
@@ -835,7 +858,7 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon
835858 Type : application .AppTypeDirectory ,
836859 URL : insCloneOpts .URL () + insFs .Join (insFs .Root (), resPath ),
837860 }
838- if err = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName ); err != nil {
861+ if err = appDef .CreateApp (ctx , nil , insCloneOpts , runtimeName , nil ); err != nil {
839862 return fmt .Errorf ("failed to create git-source: %w" , err )
840863 }
841864
0 commit comments