Skip to content

Commit

Permalink
add cacert/ verify handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Sep 7, 2019
1 parent 20a5e6d commit a0ea732
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 12 additions & 2 deletions pkg/cmd/config_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (o *ImportConfigOptions) Run() error {
tenantNameRegEx := regexp.MustCompile("OS_TENANT_NAME=['\"](.*)['\"]")
projectIDRegEx := regexp.MustCompile("OS_PROJECT_ID=['\"](.*)['\"]")
authUrlRegEx := regexp.MustCompile("OS_AUTH_URL=['\"](.*)['\"]")
caCertRegEx := regexp.MustCompile("OS_CACERT=['\"](.*)['\"]")

clouds := clouds{}
clouds.Clouds = map[string]cloud{}
Expand All @@ -108,6 +109,7 @@ func (o *ImportConfigOptions) Run() error {
tenantNameMatch := tenantNameRegEx.FindSubmatch(content)
projectIDMatch := projectIDRegEx.FindSubmatch(content)
authUrlMatch := authUrlRegEx.FindSubmatch(content)
caCertMatch := caCertRegEx.FindSubmatch(content)

if len(usernameMatch) != 2 {
return fmt.Errorf("error matching username regex")
Expand Down Expand Up @@ -138,9 +140,15 @@ func (o *ImportConfigOptions) Run() error {
auth.DomainName = string(userDomainMatch[1])
}

clouds.Clouds[string(context)] = cloud{
newCloud := cloud{
Auth: auth,
}
if len(caCertMatch) != 2 {
newCloud.Verify = false
} else {
newCloud.CaCert = string(caCertMatch[1])
}
clouds.Clouds[string(context)] = newCloud
}
}

Expand All @@ -162,7 +170,9 @@ type clouds struct {
Clouds map[string]cloud `yaml:"clouds"`
}
type cloud struct {
Auth cloudAuth `yaml:"auth"`
Auth cloudAuth `yaml:"auth"`
Verify bool `yaml:"verify"`
CaCert string `yaml:"cacert"`
}

type cloudAuth struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ type novaAttachVolume struct {
}

type novaAttachment struct {
ID string ` json:"id"`
Device string ` json:"device"`
ServerID string ` json:"serverId"`
VolumeID string ` json:"volumeId"`
ID string ` json:"id,omitempty"`
Device string ` json:"device,omitempty"`
ServerID string ` json:"serverId,omitempty"`
VolumeID string ` json:"volumeId,omitempty"`
}

func DetachVolumeCinder(osProvider *gophercloud.ProviderClient, volumeID string, force bool) error {
Expand Down

0 comments on commit a0ea732

Please sign in to comment.