@@ -27,8 +27,7 @@ import (
27
27
)
28
28
29
29
var (
30
- w io.Writer
31
- availableVersions []string
30
+ w io.Writer
32
31
)
33
32
34
33
// Install is the commandline for 'init' sub command
@@ -55,7 +54,6 @@ type Install struct {
55
54
56
55
func init () {
57
56
w = os .Stdout
58
- availableVersions = []string {"v0.3.1" , "v0.4.0" , "latest" }
59
57
}
60
58
61
59
// NewInstall returns an initialized Init instance
@@ -86,7 +84,7 @@ ofn install --async
86
84
ofn install --region-cn --all
87
85
88
86
# 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
90
88
91
89
# See more at: https://github.com/OpenFunction/cli/blob/main/docs/install.md
92
90
` ,
@@ -116,7 +114,7 @@ ofn install --all --version v0.3.1
116
114
cmd .Flags ().BoolVar (& i .RegionCN , "region-cn" , false , "For users who have limited access to gcr.io or github.com." )
117
115
cmd .Flags ().BoolVar (& i .DryRun , "dry-run" , false , "Used to prompt for the components and their versions to be installed by the current command." )
118
116
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." )
120
118
cmd .Flags ().DurationVar (& i .Timeout , "timeout" , 5 * time .Minute , "Set timeout time. Default is 5 minutes." )
121
119
// In order to avoid too many options causing misunderstandings among users,
122
120
// we have hidden the following parameters,
@@ -132,6 +130,10 @@ ofn install --all --version v0.3.1
132
130
func (i * Install ) ValidateArgs (cmd * cobra.Command , args []string ) error {
133
131
ti := util .NewTaskInformer ("" )
134
132
133
+ if i .OpenFunctionVersion == common .LatestVersion {
134
+ return nil
135
+ }
136
+
135
137
v , err := version .ParseGeneric (i .OpenFunctionVersion )
136
138
if err != nil {
137
139
return errors .New (ti .TaskFail (fmt .Sprintf (
@@ -245,15 +247,15 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
245
247
done ()
246
248
}()
247
249
248
- grp1 , g1ctx := errgroup .WithContext (ctx )
250
+ grp , gctx := errgroup .WithContext (ctx )
249
251
250
252
start := time .Now ()
251
253
252
254
if i .WithDapr {
253
255
// If Dapr already exists and --upgrade is not specified, skip this step.
254
256
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 )
257
259
})
258
260
} else {
259
261
fmt .Fprintln (w , ti .SkipTask (inventory .DaprName ))
@@ -263,8 +265,8 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
263
265
if i .WithKeda {
264
266
// If Keda already exists and --upgrade is not specified, skip this step.
265
267
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 )
268
270
})
269
271
} else {
270
272
fmt .Fprintln (w , ti .SkipTask ("Keda" ))
@@ -274,25 +276,25 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
274
276
if i .WithKnative {
275
277
// If Knative Serving already exists and --upgrade is not specified, skip this step.
276
278
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 )
279
281
})
280
282
} else {
281
283
fmt .Fprintln (w , ti .SkipTask (inventory .KnativeServingName ))
282
284
}
283
285
}
284
286
285
287
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 )
288
290
})
289
291
}
290
292
291
293
if i .WithCertManager {
292
294
// If Cert Manager already exists and --upgrade is not specified, skip this step.
293
295
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 )
296
298
})
297
299
} else {
298
300
fmt .Fprintln (w , ti .SkipTask (inventory .CertManagerName ))
@@ -302,25 +304,19 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
302
304
if i .WithIngress {
303
305
// If Ingress Nginx already exists and --upgrade is not specified, skip this step.
304
306
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 )
307
309
})
308
310
} else {
309
311
fmt .Fprintln (w , ti .SkipTask (inventory .IngressName ))
310
312
}
311
313
}
312
314
313
- if err := grp1 .Wait (); err != nil {
315
+ if err := grp .Wait (); err != nil {
314
316
return errors .New (ti .TaskFail (err .Error ()))
315
317
}
316
318
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 {
324
320
return errors .New (ti .TaskFail (err .Error ()))
325
321
}
326
322
@@ -330,6 +326,8 @@ func (i *Install) RunInstall(cl *k8s.Clientset, cmd *cobra.Command) error {
330
326
if i .WithKnative {
331
327
ti .TipsOnUsingKnative ()
332
328
}
329
+
330
+ ti .PrintOpenFunction ()
333
331
return nil
334
332
}
335
333
@@ -354,14 +352,18 @@ func (i *Install) mergeConditions() {
354
352
//if i.WithSyncRuntime {
355
353
//}
356
354
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 {
364
356
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
+ }
365
367
}
366
368
}
367
369
0 commit comments