Skip to content

Commit 71f8df9

Browse files
committed
mantle: openstack: fix passing of openstack config file path
This is a followup to b5eb5d6. We need to set $OS_CLIENT_CONFIG_FILE to the value given by the user, which is the path to the clouds.yaml on their local system.
1 parent 1197aa4 commit 71f8df9

File tree

1 file changed

+13
-1
lines changed
  • mantle/platform/api/openstack

1 file changed

+13
-1
lines changed

mantle/platform/api/openstack/api.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var (
4949
type Options struct {
5050
*platform.Options
5151

52-
// Config file. Defaults to $HOME/.config/openstack.json.
52+
// Config file. The path to a clouds.yaml file.
5353
ConfigPath string
5454
// Profile name
5555
Profile string
@@ -81,6 +81,18 @@ type API struct {
8181
}
8282

8383
func New(opts *Options) (*API, error) {
84+
// The clientconfig library tries to find a clouds.yaml in:
85+
// 1. OS_CLIENT_CONFIG_FILE
86+
// 2. Current directory.
87+
// 3. unix-specific user_config_dir (~/.config/openstack/clouds.
88+
// 4. unix-specific site_config_dir (/etc/openstack/clouds.yaml)
89+
// See https://github.com/gophercloud/utils/blob/8677e053dcf1f05d0fa0a616094aace04690eb94/openstack/clientconfig/utils.go#L93-L112
90+
//
91+
// If the user provided a path to a config file set the
92+
// $OS_CLIENT_CONFIG_FILE env var to it.
93+
if opts.ConfigPath != "" {
94+
os.Setenv("OS_CLIENT_CONFIG_FILE", opts.ConfigPath)
95+
}
8496

8597
if opts.Profile == "" {
8698
opts.Profile = "openstack"

0 commit comments

Comments
 (0)