github.com/gophercloud/gophercloud@v1.11.0/openstack/baremetal/noauth/requests.go (about)

     1  package noauth
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gophercloud/gophercloud"
     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  	if err != nil {
    33  		return nil, err
    34  	}
    35  
    36  	sc.Type = "baremetal"
    37  
    38  	return sc, nil
    39  }