@@ -27,8 +27,7 @@ import (
2727)
2828
2929var (
30- w io.Writer
31- availableVersions []string
30+ w io.Writer
3231)
3332
3433// Install is the commandline for 'init' sub command
@@ -55,7 +54,6 @@ type Install struct {
5554
5655func init () {
5756 w = os .Stdout
58- availableVersions = []string {"v0.3.1" , "v0.4.0" , "latest" }
5957}
6058
6159// NewInstall returns an initialized Init instance
@@ -86,7 +84,7 @@ ofn install --async
8684ofn install --region-cn --all
8785
8886# Install a specific version of OpenFunction (default is v0.4.0)
89- ofn install --all --version v0.3.1
87+ ofn install --all --version v0.4.0
9088
9189# See more at: https://github.com/OpenFunction/cli/blob/main/docs/install.md
9290` ,
@@ -116,7 +114,7 @@ ofn install --all --version v0.3.1
116114 cmd .Flags ().BoolVar (& i .RegionCN , "region-cn" , false , "For users who have limited access to gcr.io or github.com." )
117115 cmd .Flags ().BoolVar (& i .DryRun , "dry-run" , false , "Used to prompt for the components and their versions to be installed by the current command." )
118116 cmd .Flags ().BoolVar (& i .WithUpgrade , "upgrade" , false , "Upgrade components to target version while installing." )
119- cmd .Flags ().StringVar (& i .OpenFunctionVersion , "version" , "v0.4.0" , "Used to specify the version of OpenFunction to be installed. The permitted versions are: v0.3.1, v0.4.0, latest. " )
117+ cmd .Flags ().StringVar (& i .OpenFunctionVersion , "version" , "v0.4.0" , "Used to specify the version of OpenFunction to be installed." )
120118 cmd .Flags ().DurationVar (& i .Timeout , "timeout" , 5 * time .Minute , "Set timeout time. Default is 5 minutes." )
121119 // In order to avoid too many options causing misunderstandings among users,
122120 // we have hidden the following parameters,
@@ -132,6 +130,10 @@ ofn install --all --version v0.3.1
132130func (i * Install ) ValidateArgs (cmd * cobra.Command , args []string ) error {
133131 ti := util .NewTaskInformer ("" )
134132
133+ if i .OpenFunctionVersion == common .LatestVersion {
134+ return nil
135+ }
136+
135137 v , err := version .ParseGeneric (i .OpenFunctionVersion )
136138 if err != nil {
137139 return errors .New (ti .TaskFail (fmt .Sprintf (
@@ -245,15 +247,15 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
245247 done ()
246248 }()
247249
248- grp1 , g1ctx := errgroup .WithContext (ctx )
250+ grp , gctx := errgroup .WithContext (ctx )
249251
250252 start := time .Now ()
251253
252254 if i .WithDapr {
253255 // If Dapr already exists and --upgrade is not specified, skip this step.
254256 if ! inventoryExist [inventory .DaprName ] || i .WithUpgrade {
255- grp1 .Go (func () error {
256- return i .installDapr (g1ctx , operator )
257+ grp .Go (func () error {
258+ return i .installDapr (gctx , operator )
257259 })
258260 } else {
259261 fmt .Fprintln (w , ti .SkipTask (inventory .DaprName ))
@@ -263,8 +265,8 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
263265 if i .WithKeda {
264266 // If Keda already exists and --upgrade is not specified, skip this step.
265267 if ! inventoryExist [inventory .KedaName ] || i .WithUpgrade {
266- grp1 .Go (func () error {
267- return i .installKeda (g1ctx , cl , operator )
268+ grp .Go (func () error {
269+ return i .installKeda (gctx , cl , operator )
268270 })
269271 } else {
270272 fmt .Fprintln (w , ti .SkipTask ("Keda" ))
@@ -274,25 +276,25 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
274276 if i .WithKnative {
275277 // If Knative Serving already exists and --upgrade is not specified, skip this step.
276278 if ! inventoryExist [inventory .KnativeServingName ] || i .WithUpgrade {
277- grp1 .Go (func () error {
278- return i .installKnativeServing (g1ctx , cl , operator )
279+ grp .Go (func () error {
280+ return i .installKnativeServing (gctx , cl , operator )
279281 })
280282 } else {
281283 fmt .Fprintln (w , ti .SkipTask (inventory .KnativeServingName ))
282284 }
283285 }
284286
285287 if i .WithShipWright {
286- grp1 .Go (func () error {
287- return i .installShipwright (g1ctx , cl , operator )
288+ grp .Go (func () error {
289+ return i .installShipwright (gctx , cl , operator )
288290 })
289291 }
290292
291293 if i .WithCertManager {
292294 // If Cert Manager already exists and --upgrade is not specified, skip this step.
293295 if ! inventoryExist [inventory .CertManagerName ] || i .WithUpgrade {
294- grp1 .Go (func () error {
295- return i .installCertManager (g1ctx , cl , operator )
296+ grp .Go (func () error {
297+ return i .installCertManager (gctx , cl , operator )
296298 })
297299 } else {
298300 fmt .Fprintln (w , ti .SkipTask (inventory .CertManagerName ))
@@ -302,25 +304,19 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
302304 if i .WithIngress {
303305 // If Ingress Nginx already exists and --upgrade is not specified, skip this step.
304306 if ! inventoryExist [inventory .IngressName ] || i .WithUpgrade {
305- grp1 .Go (func () error {
306- return i .installIngress (g1ctx , cl , operator )
307+ grp .Go (func () error {
308+ return i .installIngress (gctx , cl , operator )
307309 })
308310 } else {
309311 fmt .Fprintln (w , ti .SkipTask (inventory .IngressName ))
310312 }
311313 }
312314
313- if err := grp1 .Wait (); err != nil {
315+ if err := grp .Wait (); err != nil {
314316 return errors .New (ti .TaskFail (err .Error ()))
315317 }
316318
317- grp2 , g2ctx := errgroup .WithContext (ctx )
318-
319- grp2 .Go (func () error {
320- return i .installOpenFunction (g2ctx , cl , operator )
321- })
322-
323- if err := grp2 .Wait (); err != nil {
319+ if err := i .installOpenFunction (ctx , cl , operator ); err != nil {
324320 return errors .New (ti .TaskFail (err .Error ()))
325321 }
326322
@@ -330,6 +326,8 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
330326 if i .WithKnative {
331327 ti .TipsOnUsingKnative ()
332328 }
329+
330+ ti .PrintOpenFunction ()
333331 return nil
334332}
335333
@@ -354,14 +352,18 @@ func (i *Install) mergeConditions() {
354352 //if i.WithSyncRuntime {
355353 //}
356354
357- if i .openFunctionVersion .Major () == 0 && i .openFunctionVersion .Minor () == 3 {
358- i .WithIngress = false
359- i .WithCertManager = false
360- }
361-
362- if i .openFunctionVersion .Major () == 0 && i .openFunctionVersion .Minor () == 4 {
363- i .WithIngress = false
355+ if i .OpenFunctionVersion == common .LatestVersion {
364356 i .WithCertManager = true
357+ } else {
358+ if i .openFunctionVersion .Major () == 0 && i .openFunctionVersion .Minor () == 3 {
359+ i .WithIngress = false
360+ i .WithCertManager = false
361+ }
362+
363+ if i .openFunctionVersion .Major () == 0 && i .openFunctionVersion .Minor () == 4 {
364+ i .WithIngress = false
365+ i .WithCertManager = true
366+ }
365367 }
366368}
367369
0 commit comments