Skip to content

Commit

Permalink
fixes (#73)
Browse files Browse the repository at this point in the history
Wrong authentication handling fix

Bug fixes

Reviewed-by: Artem Lifshits
  • Loading branch information
anton-sidelnikov authored Mar 26, 2024
1 parent 9585db7 commit fce3dc5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion driver/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (d *Driver) initComputeV1() error {
return fmt.Errorf("failed to authenticate: %s", logHTTP500(err))
}
if err := d.client.InitECS(); err != nil {
return fmt.Errorf("failed to initialize Compute v2 service: %s", logHTTP500(err))
return fmt.Errorf("failed to initialize Compute v1 service: %s", logHTTP500(err))
}
return nil
}
Expand Down
3 changes: 0 additions & 3 deletions driver/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "otc-auth-url",
EnvVar: "OS_AUTH_URL",
Usage: "OpenTelekomCloud authentication URL",
Value: defaultAuthURL,
},
mcnflag.StringFlag{
Name: "otc-cacert",
Expand Down Expand Up @@ -61,7 +60,6 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "otc-region",
EnvVar: "OS_REGION",
Usage: "OpenTelekomCloud region name",
Value: defaultRegion,
},
mcnflag.StringFlag{
Name: "otc-access-key",
Expand All @@ -77,7 +75,6 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "otc-availability-zone",
EnvVar: "OS_AVAILABILITY_ZONE",
Usage: "OpenTelekomCloud availability zone",
Value: defaultAZ,
},
mcnflag.StringFlag{
Name: "otc-flavor-id",
Expand Down
16 changes: 12 additions & 4 deletions driver/opentelekomcloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ var (
subnetName = utils.RandomString(15, "subnet-")
instanceName = utils.RandomString(15, "machine-")
defaultFlags = map[string]interface{}{
"otc-cloud": "otc",
"otc-subnet-name": subnetName,
"otc-vpc-name": vpcName,
"otc-tags": "machine,test",
"otc-cloud": "otc",
"otc-subnet-name": subnetName,
"otc-vpc-name": vpcName,
"otc-tags": "machine,test",
"otc-availability-zone": defaultAz(),
}
testEnv = openstack.NewEnv("OS_")
)

func defaultAz() string {
if val := os.Getenv("OS_AVAILABILITY_ZONE"); val != "" {
return val
}
return "eu-de-01"
}

func newDriverFromFlags(driverFlags map[string]interface{}) (*Driver, error) {
driver := NewDriver(instanceName, "")

Expand Down
6 changes: 1 addition & 5 deletions driver/services/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ func (c *Client) Authenticate() error {
if c.Provider != nil && c.Provider.Token() != "" {
return nil
}
ao, err := openstack.AuthOptionsFromEnv()
if err != nil {
return err
}
providerClient, err := openstack.AuthenticatedClient(ao)
providerClient, err := openstack.AuthenticatedClientFromCloud(c.cloud)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion driver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
dockerPort = 2376
defaultSecurityGroup = "docker-machine-grp"
defaultAZ = "eu-de-01"
defaultFlavor = "s2.large.2"
defaultFlavor = "s3.xlarge.2"
defaultImage = "Standard_Ubuntu_20.04_latest"
defaultSSHUser = "ubuntu"
defaultSSHPort = 22
Expand Down

0 comments on commit fce3dc5

Please sign in to comment.