@@ -61,17 +61,16 @@ import (
61
61
62
62
type (
63
63
RuntimeInstallOptions struct {
64
- RuntimeName string
65
- RuntimeToken string
66
- IngressHost string
67
- Insecure bool
68
- Version * semver.Version
69
- GsCloneOpts * git.CloneOptions
70
- InsCloneOpts * git.CloneOptions
71
- KubeFactory kube.Factory
72
- CommonConfig * runtime.CommonConfig
64
+ RuntimeName string
65
+ RuntimeToken string
66
+ IngressHost string
67
+ Insecure bool
68
+ Version * semver.Version
69
+ GsCloneOpts * git.CloneOptions
70
+ InsCloneOpts * git.CloneOptions
71
+ KubeFactory kube.Factory
72
+ CommonConfig * runtime.CommonConfig
73
73
}
74
-
75
74
RuntimeUninstallOptions struct {
76
75
RuntimeName string
77
76
Timeout time.Duration
@@ -209,24 +208,27 @@ func NewRuntimeInstallCommand() *cobra.Command {
209
208
func getComponents (rt * runtime.Runtime , opts * RuntimeInstallOptions ) []string {
210
209
var componentNames []string
211
210
for _ , component := range rt .Spec .Components {
212
- componentNames = append (componentNames , fmt .Sprintf ("%s-%s" , opts .RuntimeName , component .Name ))
211
+ componentFullName := fmt .Sprintf ("%s-%s" , opts .RuntimeName , component .Name )
212
+ componentNames = append (componentNames , componentFullName )
213
213
}
214
214
215
215
// should find a more dynamic way to get these additional components
216
216
additionalComponents := []string {"events-reporter" , "workflow-reporter" }
217
217
for _ , additionalComponentName := range additionalComponents {
218
- componentNames = append (componentNames , fmt .Sprintf ("%s-%s" , opts .RuntimeName , additionalComponentName ))
218
+ componentFullName := fmt .Sprintf ("%s-%s" , opts .RuntimeName , additionalComponentName )
219
+ componentNames = append (componentNames , componentFullName )
219
220
}
220
- componentNames = append (componentNames , "argo-cd" )
221
+ argoCDFullName := store .Get ().ArgoCD
222
+ componentNames = append (componentNames , argoCDFullName )
221
223
222
224
return componentNames
223
225
}
224
226
225
- func createRuntimeOnPlatform (ctx context.Context , runtimeName string , server string , runtimeVersion string , ingressHost string , componentNames [] string ) (string , error ) {
226
- runtimeCreationResponse , err := cfConfig .NewClient ().V2 ().Runtime ().Create (ctx , runtimeName , server , runtimeVersion , ingressHost , componentNames )
227
+ func createRuntimeOnPlatform (ctx context.Context , opts * model. RuntimeInstallationArgs ) (string , error ) {
228
+ runtimeCreationResponse , err := cfConfig .NewClient ().V2 ().Runtime ().Create (ctx , opts )
227
229
228
- if runtimeCreationResponse . ErrorMessage != nil {
229
- return runtimeCreationResponse . NewAccessToken , fmt .Errorf ("failed to create a new runtime: %s. Error: %w" , * runtimeCreationResponse . ErrorMessage , err )
230
+ if err != nil {
231
+ return "" , fmt .Errorf ("failed to create a new runtime: %s. Error: %w" , opts . RuntimeName , err )
230
232
}
231
233
232
234
return runtimeCreationResponse .NewAccessToken , nil
@@ -254,7 +256,13 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
254
256
255
257
componentNames := getComponents (rt , opts )
256
258
257
- token , err := createRuntimeOnPlatform (ctx , opts .RuntimeName , server , runtimeVersion , opts .IngressHost , componentNames )
259
+ token , err := createRuntimeOnPlatform (ctx , & model.RuntimeInstallationArgs {
260
+ RuntimeName : opts .RuntimeName ,
261
+ Cluster : server ,
262
+ RuntimeVersion : runtimeVersion ,
263
+ IngressHost : & opts .IngressHost ,
264
+ ComponentNames : componentNames ,
265
+ })
258
266
259
267
if err != nil {
260
268
return fmt .Errorf ("failed to create a new runtime: %w" , err )
@@ -326,11 +334,11 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
326
334
fullGsPath := opts .GsCloneOpts .FS .Join (opts .GsCloneOpts .FS .Root (), gsPath )[1 :]
327
335
328
336
if err = RunGitSourceCreate (ctx , & GitSourceCreateOptions {
329
- InsCloneOpts : opts .InsCloneOpts ,
330
- GsCloneOpts : opts .GsCloneOpts ,
331
- GsName : store .Get ().GitSourceName ,
332
- RuntimeName : opts .RuntimeName ,
333
- FullGsPath : fullGsPath ,
337
+ InsCloneOpts : opts .InsCloneOpts ,
338
+ GsCloneOpts : opts .GsCloneOpts ,
339
+ GsName : store .Get ().GitSourceName ,
340
+ RuntimeName : opts .RuntimeName ,
341
+ FullGsPath : fullGsPath ,
334
342
}); err != nil {
335
343
return fmt .Errorf ("failed to create `%s`: %w" , store .Get ().GitSourceName , err )
336
344
}
0 commit comments