Skip to content

Commit

Permalink
Add support for Swift V1 Auth (#346)
Browse files Browse the repository at this point in the history
This adds support for Swift V1 Auth sharing all of the config options
with openstack. I've added a new option (--storage-openstack-auth) to
switch to V1 Auth.

This depends on chartmuseum/storage#45

Signed-off-by: jayme-github <[email protected]>
  • Loading branch information
jayme-github authored Jul 14, 2020
1 parent 88bc4a9 commit 136f489
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ chartmuseum --debug --port=8080 \
--storage-openstack-region="myregion"
```

For Swift V1 Auth you must set the following env vars:
- `ST_AUTH`
- `ST_USER`
- `ST_KEY`

```bash
chartmuseum --debug --port=8080 \
--storage="openstack" \
--storage-openstack-auth="v1" \
--storage-openstack-container="mycontainer" \
--storage-openstack-prefix=""
```


#### Using with Oracle Cloud Infrastructure Object Storage

Make sure your environment is properly setup to access `my-ocs-bucket`.
Expand Down
28 changes: 21 additions & 7 deletions cmd/chartmuseum/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,27 @@ func alibabaBackendFromConfig(conf *config.Config) storage.Backend {
}

func openstackBackendFromConfig(conf *config.Config) storage.Backend {
crashIfConfigMissingVars(conf, []string{"storage.openstack.container", "storage.openstack.region"})
return storage.NewOpenstackOSBackend(
conf.GetString("storage.openstack.container"),
conf.GetString("storage.openstack.prefix"),
conf.GetString("storage.openstack.region"),
conf.GetString("storage.openstack.cacert"),
)
var backend storage.Backend
switch conf.GetString("storage.openstack.auth") {
case "v1":
crashIfConfigMissingVars(conf, []string{"storage.openstack.container"})
backend = storage.NewOpenstackOSBackendV1Auth(
conf.GetString("storage.openstack.container"),
conf.GetString("storage.openstack.prefix"),
conf.GetString("storage.openstack.cacert"),
)
case "auto":
crashIfConfigMissingVars(conf, []string{"storage.openstack.container", "storage.openstack.region"})
backend = storage.NewOpenstackOSBackend(
conf.GetString("storage.openstack.container"),
conf.GetString("storage.openstack.prefix"),
conf.GetString("storage.openstack.region"),
conf.GetString("storage.openstack.cacert"),
)
default:
crash("Unsupported OpenStack auth protocol: ", conf.GetString("storage.openstack.auth"))
}
return backend
}

func baiduBackendFromConfig(conf *config.Config) storage.Backend {
Expand Down
9 changes: 9 additions & 0 deletions pkg/config/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ var configVars = map[string]configVar{
EnvVar: "STORAGE_OPENSTACK_CACERT",
},
},
"storage.openstack.auth": {
Type: stringType,
Default: "auto",
CLIFlag: cli.StringFlag{
Name: "storage-openstack-auth",
Usage: "the OpenStack auth protocol to use. Set \"v1\" for v1 or \"auto\" for v2 and v3",
EnvVar: "STORAGE_OPENSTACK_AUTH",
},
},
"storage.baidu.prefix": {
Type: stringType,
Default: "",
Expand Down

0 comments on commit 136f489

Please sign in to comment.