Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func main() {

plugin_version := "0.2.3"
plugin_version := "0.3.0"

apiClientMeta := &pluginutil.APIClientMeta{}
flags := apiClientMeta.FlagSet()
Expand Down
20 changes: 20 additions & 0 deletions plugin/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package keystoneauth

import (
"fmt"
"log"

"github.com/fatih/structs"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
"github.com/parnurzeal/gorequest"
)

func pathConfig(b *backend) *framework.Path {
Expand Down Expand Up @@ -51,6 +54,23 @@ func (b *backend) pathConnectionWrite(
connURL := data.Get("connection_url").(string)
adminAuthToken := data.Get("admin_auth_token").(string)

request := gorequest.New()
resp, _, errs := request.Get("http://"+connURL+"/v3/users/").
Set("X-Auth-Token", adminAuthToken).
Set("Content-type", "application/json").
End()

if errs != nil {
return nil, fmt.Errorf("", errs[0])
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Can't connect to keystone, " +
"check configuration options :`connection_url` and `admin_auth_token`" +
" or authentication permissions for OpenStack Keystone")
} else {
log.Printf("Succesfully connected to: %s", connURL)
}

// Store it
entry, err := logical.StorageEntryJSON("config/connection", connectionConfig{
ConnectionURL: connURL,
Expand Down