@@ -61,17 +61,16 @@ import (
6161
6262type (
6363 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
7373 }
74-
7574 RuntimeUninstallOptions struct {
7675 RuntimeName string
7776 Timeout time.Duration
@@ -209,24 +208,27 @@ func NewRuntimeInstallCommand() *cobra.Command {
209208func getComponents (rt * runtime.Runtime , opts * RuntimeInstallOptions ) []string {
210209 var componentNames []string
211210 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 )
213213 }
214214
215215 // should find a more dynamic way to get these additional components
216216 additionalComponents := []string {"events-reporter" , "workflow-reporter" }
217217 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 )
219220 }
220- componentNames = append (componentNames , "argo-cd" )
221+ argoCDFullName := store .Get ().ArgoCD
222+ componentNames = append (componentNames , argoCDFullName )
221223
222224 return componentNames
223225}
224226
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 )
227229
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 )
230232 }
231233
232234 return runtimeCreationResponse .NewAccessToken , nil
@@ -254,7 +256,13 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
254256
255257 componentNames := getComponents (rt , opts )
256258
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+ })
258266
259267 if err != nil {
260268 return fmt .Errorf ("failed to create a new runtime: %w" , err )
@@ -326,11 +334,11 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
326334 fullGsPath := opts .GsCloneOpts .FS .Join (opts .GsCloneOpts .FS .Root (), gsPath )[1 :]
327335
328336 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 ,
334342 }); err != nil {
335343 return fmt .Errorf ("failed to create `%s`: %w" , store .Get ().GitSourceName , err )
336344 }
0 commit comments