56
56
gsCloneOpts * git.CloneOptions
57
57
insCloneOpts * git.CloneOptions
58
58
KubeFactory kube.Factory
59
+ commonConfig * runtime.CommonConfig
59
60
}
60
61
61
62
RuntimeUninstallOptions struct {
@@ -66,9 +67,10 @@ type (
66
67
}
67
68
68
69
RuntimeUpgradeOptions struct {
69
- RuntimeName string
70
- Version * semver.Version
71
- CloneOpts * git.CloneOptions
70
+ RuntimeName string
71
+ Version * semver.Version
72
+ CloneOpts * git.CloneOptions
73
+ commonConfig * runtime.CommonConfig
72
74
}
73
75
)
74
76
@@ -152,6 +154,9 @@ func NewRuntimeInstallCommand() *cobra.Command {
152
154
gsCloneOpts : gsCloneOpts ,
153
155
insCloneOpts : insCloneOpts ,
154
156
KubeFactory : f ,
157
+ commonConfig : & runtime.CommonConfig {
158
+ CodefreshBaseURL : cfConfig .GetCurrentContext ().URL ,
159
+ },
155
160
})
156
161
},
157
162
}
@@ -210,7 +215,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
210
215
}
211
216
}
212
217
213
- if err = persistRuntime (ctx , opts .insCloneOpts , rt ); err != nil {
218
+ if err = persistRuntime (ctx , opts .insCloneOpts , rt , opts . commonConfig ); err != nil {
214
219
return fmt .Errorf ("failed to create codefresh-cm: %w" , err )
215
220
}
216
221
@@ -222,7 +227,8 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
222
227
return fmt .Errorf ("failed to create demo workflowTemplate: %w" , err )
223
228
}
224
229
225
- if err = createGitSource (ctx , opts .insCloneOpts , opts .gsCloneOpts , store .Get ().GitSourceName , opts .RuntimeName ); err != nil {
230
+ if err = createGitSource (ctx , opts .insCloneOpts , opts .gsCloneOpts , store .Get ().GitSourceName , opts .RuntimeName ,
231
+ opts .commonConfig .CodefreshBaseURL ); err != nil {
226
232
return fmt .Errorf ("failed to create `%s`: %w" , store .Get ().GitSourceName , err )
227
233
}
228
234
@@ -408,6 +414,9 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
408
414
RuntimeName : args [0 ],
409
415
Version : version ,
410
416
CloneOpts : cloneOpts ,
417
+ commonConfig : & runtime.CommonConfig {
418
+ CodefreshBaseURL : cfConfig .GetCurrentContext ().URL ,
419
+ },
411
420
})
412
421
},
413
422
}
@@ -444,7 +453,7 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
444
453
return fmt .Errorf ("must upgrade to version > %s" , curRt .Spec .Version )
445
454
}
446
455
447
- newComponents , err := curRt .Upgrade (fs , newRt )
456
+ newComponents , err := curRt .Upgrade (fs , newRt , opts . commonConfig )
448
457
if err != nil {
449
458
return fmt .Errorf ("failed to upgrade runtime: %w" , err )
450
459
}
@@ -463,13 +472,13 @@ func RunRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
463
472
return nil
464
473
}
465
474
466
- func persistRuntime (ctx context.Context , cloneOpts * git.CloneOptions , rt * runtime.Runtime ) error {
475
+ func persistRuntime (ctx context.Context , cloneOpts * git.CloneOptions , rt * runtime.Runtime , rtConf * runtime. CommonConfig ) error {
467
476
r , fs , err := cloneOpts .GetRepo (ctx )
468
477
if err != nil {
469
478
return err
470
479
}
471
480
472
- if err = rt .Save (fs , fs .Join (apstore .Default .BootsrtrapDir , store .Get ().RuntimeFilename )); err != nil {
481
+ if err = rt .Save (fs , fs .Join (apstore .Default .BootsrtrapDir , store .Get ().RuntimeFilename ), rtConf ); err != nil {
473
482
return err
474
483
}
475
484
@@ -516,7 +525,8 @@ func createComponentsReporter(ctx context.Context, cloneOpts *git.CloneOptions,
516
525
return err
517
526
}
518
527
519
- if err := createSensor (repofs , store .Get ().ComponentsReporterName , resPath , opts .RuntimeName , store .Get ().ComponentsReporterName ); err != nil {
528
+ if err := createSensor (repofs , store .Get ().ComponentsReporterName , resPath , opts .RuntimeName ,
529
+ store .Get ().ComponentsReporterName , opts .commonConfig .CodefreshBaseURL ); err != nil {
520
530
return err
521
531
}
522
532
@@ -668,13 +678,13 @@ func createEventSource(repofs fs.FS, path, namespace string) error {
668
678
return repofs .WriteYamls (repofs .Join (path , "event-source.yaml" ), eventSource )
669
679
}
670
680
671
- func createSensor (repofs fs.FS , name , path , namespace , eventSourceName string ) error {
681
+ func createSensor (repofs fs.FS , name , path , namespace , eventSourceName , cfBaseURL string ) error {
672
682
sensor := eventsutil .CreateSensor (& eventsutil.CreateSensorOptions {
673
683
Name : name ,
674
684
Namespace : namespace ,
675
685
EventSourceName : eventSourceName ,
676
686
EventBusName : store .Get ().EventBusName ,
677
- TriggerURL : cfConfig . GetCurrentContext (). URL + store .Get ().EventReportingEndpoint ,
687
+ TriggerURL : cfBaseURL + store .Get ().EventReportingEndpoint ,
678
688
Triggers : []string {
679
689
"components" ,
680
690
"runtime" ,
@@ -725,7 +735,7 @@ func createDemoWorkflowTemplate(ctx context.Context, gsCloneOpts *git.CloneOptio
725
735
return err
726
736
}
727
737
728
- func createGitSource (ctx context.Context , insCloneOpts * git.CloneOptions , gsCloneOpts * git.CloneOptions , gsName , runtimeName string ) error {
738
+ func createGitSource (ctx context.Context , insCloneOpts * git.CloneOptions , gsCloneOpts * git.CloneOptions , gsName , runtimeName , cfBaseURL string ) error {
729
739
var err error
730
740
731
741
insRepo , insFs , err := insCloneOpts .GetRepo (ctx )
@@ -830,7 +840,7 @@ func createGitSource(ctx context.Context, insCloneOpts *git.CloneOptions, gsClon
830
840
Namespace : runtimeName ,
831
841
EventSourceName : eventSourceName ,
832
842
EventBusName : store .Get ().EventBusName ,
833
- TriggerURL : cfConfig . GetCurrentContext (). URL + store .Get ().EventReportingEndpoint ,
843
+ TriggerURL : cfBaseURL + store .Get ().EventReportingEndpoint ,
834
844
Triggers : []string {
835
845
// "clusterWorkflowTemplate",
836
846
"workflowTemplate" ,
0 commit comments