@@ -51,6 +51,7 @@ import (
51
51
type (
52
52
RuntimeInstallOptions struct {
53
53
RuntimeName string
54
+ RuntimeToken string
54
55
Version * semver.Version
55
56
gsCloneOpts * git.CloneOptions
56
57
insCloneOpts * git.CloneOptions
@@ -177,6 +178,12 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
177
178
return fmt .Errorf ("failed to download runtime definition: %w" , err )
178
179
}
179
180
181
+ runtimeCreationResponse , err := cfConfig .NewClient ().ArgoRuntime ().Create (opts .RuntimeName )
182
+ if err != nil {
183
+ return fmt .Errorf ("failed to get a runtime creation response: %w" , err )
184
+ }
185
+ opts .RuntimeToken = runtimeCreationResponse .NewAccessToken
186
+
180
187
log .G (ctx ).WithField ("version" , rt .Spec .Version ).Infof ("installing runtime '%s'" , opts .RuntimeName )
181
188
err = apcmd .RunRepoBootstrap (ctx , & apcmd.RepoBootstrapOptions {
182
189
AppSpecifier : rt .Spec .FullSpecifier (),
@@ -473,7 +480,7 @@ func persistRuntime(ctx context.Context, cloneOpts *git.CloneOptions, rt *runtim
473
480
}
474
481
475
482
func createComponentsReporter (ctx context.Context , cloneOpts * git.CloneOptions , opts * RuntimeInstallOptions ) error {
476
- tokenSecret , err := getTokenSecret (opts .RuntimeName )
483
+ tokenSecret , err := getTokenSecret (opts .RuntimeName , opts . RuntimeToken )
477
484
if err != nil {
478
485
return fmt .Errorf ("failed to create codefresh token secret: %w" , err )
479
486
}
@@ -552,8 +559,7 @@ var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.Ap
552
559
return proj , appSet , nil
553
560
}
554
561
555
- func getTokenSecret (namespace string ) ([]byte , error ) {
556
- token := cfConfig .GetCurrentContext ().Token
562
+ func getTokenSecret (namespace string , token string ) ([]byte , error ) {
557
563
return yaml .Marshal (& v1.Secret {
558
564
TypeMeta : metav1.TypeMeta {
559
565
APIVersion : "v1" ,
0 commit comments