@@ -51,6 +51,7 @@ import (
5151type (
5252 RuntimeInstallOptions struct {
5353 RuntimeName string
54+ RuntimeToken string
5455 Version * semver.Version
5556 gsCloneOpts * git.CloneOptions
5657 insCloneOpts * git.CloneOptions
@@ -177,6 +178,12 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
177178 return fmt .Errorf ("failed to download runtime definition: %w" , err )
178179 }
179180
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+
180187 log .G (ctx ).WithField ("version" , rt .Spec .Version ).Infof ("installing runtime '%s'" , opts .RuntimeName )
181188 err = apcmd .RunRepoBootstrap (ctx , & apcmd.RepoBootstrapOptions {
182189 AppSpecifier : rt .Spec .FullSpecifier (),
@@ -473,7 +480,7 @@ func persistRuntime(ctx context.Context, cloneOpts *git.CloneOptions, rt *runtim
473480}
474481
475482func createComponentsReporter (ctx context.Context , cloneOpts * git.CloneOptions , opts * RuntimeInstallOptions ) error {
476- tokenSecret , err := getTokenSecret (opts .RuntimeName )
483+ tokenSecret , err := getTokenSecret (opts .RuntimeName , opts . RuntimeToken )
477484 if err != nil {
478485 return fmt .Errorf ("failed to create codefresh token secret: %w" , err )
479486 }
@@ -552,8 +559,7 @@ var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.Ap
552559 return proj , appSet , nil
553560}
554561
555- func getTokenSecret (namespace string ) ([]byte , error ) {
556- token := cfConfig .GetCurrentContext ().Token
562+ func getTokenSecret (namespace string , token string ) ([]byte , error ) {
557563 return yaml .Marshal (& v1.Secret {
558564 TypeMeta : metav1.TypeMeta {
559565 APIVersion : "v1" ,
0 commit comments