3 // Availability indicates to whom a specific service endpoint is accessible:
4 // the internet at large, internal networks only, or only to administrators.
5 // Different identity services use different terminology for these. Identity v2
6 // lists them as different kinds of URLs within the service catalog ("adminURL",
7 // "internalURL", and "publicURL"), while v3 lists them as "Interfaces" in an
8 // endpoint's response.
9 type Availability string
12 // AvailabilityAdmin indicates that an endpoint is only available to
14 AvailabilityAdmin Availability = "admin"
16 // AvailabilityPublic indicates that an endpoint is available to everyone on
18 AvailabilityPublic Availability = "public"
20 // AvailabilityInternal indicates that an endpoint is only available within
21 // the cluster's internal network.
22 AvailabilityInternal Availability = "internal"
25 // EndpointOpts specifies search criteria used by queries against an
26 // OpenStack service catalog. The options must contain enough information to
27 // unambiguously identify one, and only one, endpoint within the catalog.
29 // Usually, these are passed to service client factory functions in a provider
30 // package, like "openstack.NewComputeV2()".
31 type EndpointOpts struct {
32 // Type [required] is the service type for the client (e.g., "compute",
33 // "object-store"). Generally, this will be supplied by the service client
34 // function, but a user-given value will be honored if provided.
37 // Name [optional] is the service name for the client (e.g., "nova") as it
38 // appears in the service catalog. Services can have the same Type but a
39 // different Name, which is why both Type and Name are sometimes needed.
42 // Region [required] is the geographic region in which the endpoint resides,
43 // generally specifying which datacenter should house your resources.
44 // Required only for services that span multiple regions.
47 // Availability [optional] is the visibility of the endpoint to be returned.
48 // Valid types include the constants AvailabilityPublic, AvailabilityInternal,
49 // or AvailabilityAdmin from this package.
51 // Availability is not required, and defaults to AvailabilityPublic. Not all
52 // providers or services offer all Availability options.
53 Availability Availability
57 EndpointLocator is an internal function to be used by provider implementations.
59 It provides an implementation that locates a single endpoint from a service
60 catalog for a specific ProviderClient based on user-provided EndpointOpts. The
61 provider then uses it to discover related ServiceClients.
63 type EndpointLocator func(EndpointOpts) (string, error)
65 // ApplyDefaults is an internal method to be used by provider implementations.
67 // It sets EndpointOpts fields if not already set, including a default type.
68 // Currently, EndpointOpts.Availability defaults to the public endpoint.
69 func (eo *EndpointOpts) ApplyDefaults(t string) {
73 if eo.Availability == "" {
74 eo.Availability = AvailabilityPublic