Michal Kobus | f611358 | 2019-09-09 15:58:21 +0200 | [diff] [blame^] | 1 | package noauth |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "gerrit.mcp.mirantis.net/debian/gophercloud.git" |
| 7 | ) |
| 8 | |
| 9 | // EndpointOpts specifies a "noauth" Ironic Endpoint. |
| 10 | type EndpointOpts struct { |
| 11 | // IronicEndpoint [required] is currently only used with "noauth" Ironic. |
| 12 | // An Ironic endpoint with "auth_strategy=noauth" is necessary, for example: |
| 13 | // http://ironic.example.com:6385/v1. |
| 14 | IronicEndpoint string |
| 15 | } |
| 16 | |
| 17 | func initClientOpts(client *gophercloud.ProviderClient, eo EndpointOpts) (*gophercloud.ServiceClient, error) { |
| 18 | sc := new(gophercloud.ServiceClient) |
| 19 | if eo.IronicEndpoint == "" { |
| 20 | return nil, fmt.Errorf("IronicEndpoint is required") |
| 21 | } |
| 22 | |
| 23 | sc.Endpoint = gophercloud.NormalizeURL(eo.IronicEndpoint) |
| 24 | sc.ProviderClient = client |
| 25 | return sc, nil |
| 26 | } |
| 27 | |
| 28 | // NewBareMetalNoAuth creates a ServiceClient that may be used to access a |
| 29 | // "noauth" bare metal service. |
| 30 | func NewBareMetalNoAuth(eo EndpointOpts) (*gophercloud.ServiceClient, error) { |
| 31 | sc, err := initClientOpts(&gophercloud.ProviderClient{}, eo) |
| 32 | |
| 33 | // sc.Type = "baremetal" |
| 34 | |
| 35 | return sc, err |
| 36 | } |