@@ -15,6 +15,7 @@ import (
1515 "github.com/openshift/assisted-service/client/installer"
1616 "github.com/openshift/assisted-service/models"
1717 "github.com/openshift/installer/pkg/asset/agent/agentconfig"
18+ "github.com/openshift/installer/pkg/asset/agent/gencrypto"
1819 "github.com/openshift/installer/pkg/asset/agent/image"
1920 "github.com/openshift/installer/pkg/asset/agent/manifests"
2021 "github.com/openshift/installer/pkg/asset/installconfig"
@@ -32,7 +33,7 @@ type NodeZeroRestClient struct {
3233}
3334
3435// NewNodeZeroRestClient Initialize a new rest client to interact with the Agent Rest API on node zero.
35- func NewNodeZeroRestClient (ctx context.Context , rendezvousIP string , sshKey string ) (* NodeZeroRestClient , error ) {
36+ func NewNodeZeroRestClient (ctx context.Context , rendezvousIP , sshKey , token string ) (* NodeZeroRestClient , error ) {
3637 restClient := & NodeZeroRestClient {}
3738
3839 // Get SSH Keys which can be used to determine if Rest API failures are due to network connectivity issues
@@ -46,6 +47,9 @@ func NewNodeZeroRestClient(ctx context.Context, rendezvousIP string, sshKey stri
4647 Host : net .JoinHostPort (rendezvousIP , "8090" ),
4748 Path : client .DefaultBasePath ,
4849 }
50+
51+ config .AuthInfo = gencrypto .UserAuthHeaderWriter (token )
52+
4953 client := client .New (config )
5054
5155 restClient .Client = client
@@ -115,6 +119,27 @@ func FindRendezvouIPAndSSHKeyFromAssetStore(assetDir string) (string, string, er
115119 return rendezvousIP , sshKey , nil
116120}
117121
122+ // FindAuthTokenFromAssetStore returns the auth token.
123+ func FindAuthTokenFromAssetStore (assetDir string ) (string , error ) {
124+ authConfigAsset := & gencrypto.AuthConfig {}
125+
126+ assetStore , err := assetstore .NewStore (assetDir )
127+ if err != nil {
128+ return "" , errors .Wrap (err , "failed to create asset store" )
129+ }
130+
131+ authConfig , authConfigError := assetStore .Load (authConfigAsset )
132+
133+ if authConfigError != nil {
134+ logrus .Debug (errors .Wrapf (authConfigError , "failed to load %s" , authConfigAsset .Name ()))
135+ return "" , errors .New ("failed to load AuthConfig" )
136+ }
137+
138+ token := authConfig .(* gencrypto.AuthConfig ).Token
139+
140+ return token , nil
141+ }
142+
118143// IsRestAPILive Determine if the Agent Rest API on node zero has initialized
119144func (rest * NodeZeroRestClient ) IsRestAPILive () bool {
120145 // GET /v2/infraenvs
0 commit comments