Skip to content

Commit

Permalink
refactoring client
Browse files Browse the repository at this point in the history
  • Loading branch information
Mia-Cross committed Jun 14, 2023
1 parent dab001c commit 4a943d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions pkg/nodeidentity/scaleway/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ type nodeIdentifier struct {

// New creates and returns a nodeidentity.Identifier for Nodes running on Scaleway
func New(CacheNodeidentityInfo bool) (nodeidentity.Identifier, error) {
profile, err := scaleway.CreateValidScalewayProfile()
if err != nil {
return nil, err
}
scwClient, err := scw.NewClient(
scw.WithUserAgent("kubernetes-kops/"+kopsv.Version),
scw.WithEnv(),
scw.WithProfile(profile),
scw.WithUserAgent(scaleway.KopsUserAgentPrefix+kopsv.Version),
)
if err != nil {
return nil, err
return nil, fmt.Errorf("creating client for Scaleway NodeIdentifier: %w", err)
}

return &nodeIdentifier{
Expand Down
8 changes: 6 additions & 2 deletions protokube/pkg/protokube/scaleway_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ func NewScwCloudProvider() (*ScwCloudProvider, error) {
privateIP := metadata.PrivateIP
klog.V(4).Infof("Found first private net IP of the running server: %q", privateIP)

profile, err := scaleway.CreateValidScalewayProfile()
if err != nil {
return nil, err
}
scwClient, err := scw.NewClient(
scw.WithProfile(profile),
scw.WithUserAgent(scaleway.KopsUserAgentPrefix+kopsv.Version),
scw.WithEnv(),
scw.WithDefaultZone(zone),
scw.WithDefaultRegion(region),
)
if err != nil {
return nil, fmt.Errorf("error creating client: %w", err)
return nil, fmt.Errorf("error creating client for Protokube: %w", err)
}

instanceAPI := instance.NewAPI(scwClient)
Expand Down

0 comments on commit 4a943d8

Please sign in to comment.