Documentation ¶
Overview ¶
Package auth provides Google oauth2 and Azure credential bindings for mantle.
Index ¶
- Constants
- func DecodeBOMFile(path string) ([]byte, error)
- func GoogleClient() (*http.Client, error)
- func GoogleClientFromJSONKey(jsonKey []byte, scope ...string) (*http.Client, error)
- func GoogleServiceClient() *http.Client
- func GoogleServiceTokenSource() oauth2.TokenSource
- func GoogleTokenSource() (oauth2.TokenSource, error)
- func GoogleTokenSourceFromJSONKey(jsonKey []byte, scope ...string) (oauth2.TokenSource, error)
- func ReadDOConfig(path string) (map[string]DOProfile, error)
- func ReadESXConfig(path string) (map[string]ESXProfile, error)
- func ReadOpenStackConfig(path string) (map[string]OpenStackProfile, error)
- func ReadPacketConfig(path string) (map[string]PacketProfile, error)
- type AzureEnvironment
- type AzureManagementCertificate
- type AzureProfile
- type AzureSubscription
- type DOProfile
- type ESXProfile
- type OpenStackProfile
- type Options
- type PacketProfile
Constants ¶
const ( AzureAuthPath = ".azure/credentials.json" AzureProfilePath = ".azure/azureProfile.json" )
const DOConfigPath = ".config/digitalocean.json"
const ESXConfigPath = ".config/esx.json"
const OpenStackConfigPath = ".config/openstack.json"
const PacketConfigPath = ".config/packet.json"
Variables ¶
This section is empty.
Functions ¶
func DecodeBOMFile ¶ added in v0.13.0
func GoogleClient ¶
GoogleClient provides an http.Client authorized with an oauth2 token that is automatically cached and refreshed from a file named '.mantle-cache-google.json'. This uses interactive oauth2 authorization and requires a user follow to follow a web link and paste in an authorization token.
func GoogleClientFromJSONKey ¶
GoogleClientFromJSONKey provides an http.Client authorized with an oauth2 token retrieved using a Google Developers service account's private JSON key file.
func GoogleServiceClient ¶
GoogleServiceClient fetchs a token from Google Compute Engine's metadata service. This should be used on GCE vms. The Default account is used.
func GoogleServiceTokenSource ¶
func GoogleServiceTokenSource() oauth2.TokenSource
GoogleServiceTokenSource provides an oauth2.TokenSource authorized in the same manner as GoogleServiceClient().
func GoogleTokenSource ¶
func GoogleTokenSource() (oauth2.TokenSource, error)
GoogleTokenSource provides an outh2.TokenSource authorized in the same manner as GoogleClient.
func GoogleTokenSourceFromJSONKey ¶
func GoogleTokenSourceFromJSONKey(jsonKey []byte, scope ...string) (oauth2.TokenSource, error)
GoogleTokenSourceFromJSONKey provides an oauth2.TokenSource authorized in the same manner as GoogleClientFromJSONKey.
func ReadDOConfig ¶ added in v0.8.0
ReadDOConfig decodes a DigitalOcean config file, which is a custom format used by Mantle to hold personal access tokens.
If path is empty, $HOME/.config/digitalocean.json is read.
func ReadESXConfig ¶ added in v0.7.0
func ReadESXConfig(path string) (map[string]ESXProfile, error)
ReadESXConfig decodes a ESX config file, which is a custom format used by Mantle to hold ESX server information.
If path is empty, $HOME/.config/esx.json is read.
func ReadOpenStackConfig ¶ added in v0.12.0
func ReadOpenStackConfig(path string) (map[string]OpenStackProfile, error)
ReadOpenStackConfig decodes an OpenStack config file, which is a custom format used by Mantle to hold OpenStack server information.
If path is empty, $HOME/.config/openstack.json is read.
func ReadPacketConfig ¶ added in v0.6.0
func ReadPacketConfig(path string) (map[string]PacketProfile, error)
ReadPacketConfig decodes a Packet config file, which is a custom format used by Mantle to hold API keys.
If path is empty, $HOME/.config/packet.json is read.
Types ¶
type AzureEnvironment ¶ added in v0.3.0
type AzureEnvironment struct { ActiveDirectoryEndpointURL string `json:"activeDirectoryEndpointUrl"` ActiveDirectoryGraphAPIVersion string `json:"activeDirectoryGraphApiVersion"` ActiveDirectoryGraphResourceID string `json:"activeDirectoryGraphResourceId"` ActiveDirectoryResourceID string `json:"activeDirectoryResourceId"` AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix string `json:"azureDataLakeAnalyticsCatalogAndJobEndpointSuffix"` AzureDataLakeStoreFileSystemEndpointSuffix string `json:"azureDataLakeStoreFileSystemEndpointSuffix"` GalleryEndpointURL string `json:"galleryEndpointUrl"` KeyVaultDNSSuffix string `json:"keyVaultDnsSuffix"` ManagementEndpointURL string `json:"managementEndpointUrl"` Name string `json:"name"` PortalURL string `json:"portalUrl"` PublishingProfileURL string `json:"publishingProfileUrl"` ResourceManagerEndpointURL string `json:"resourceManagerEndpointUrl"` SqlManagementEndpointURL string `json:"sqlManagementEndpointUrl"` SqlServerHostnameSuffix string `json:"sqlServerHostnameSuffix"` StorageEndpointSuffix string `json:"storageEndpointSuffix"` }
type AzureManagementCertificate ¶ added in v0.3.0
type AzureProfile ¶ added in v0.3.0
type AzureProfile struct { Environments []AzureEnvironment `json:"environments"` Subscriptions []AzureSubscription `json:"subscriptions"` }
AzureProfile represents a parsed Azure Profile Configuration File.
func ReadAzureProfile ¶ added in v0.3.0
func ReadAzureProfile(path string) (*AzureProfile, error)
ReadAzureProfile decodes an Azure Profile, as created by the Azure Cross-platform CLI.
If path is empty, $HOME/.azure/azureProfile.json is read.
func (*AzureProfile) AsOptions ¶ added in v0.3.0
func (ap *AzureProfile) AsOptions() []Options
AsOptions converts all subscriptions into a slice of Options. If there is an environment with a name matching the subscription, that environment's storage endpoint will be copied to the options.
func (*AzureProfile) SubscriptionOptions ¶ added in v0.3.0
func (ap *AzureProfile) SubscriptionOptions(name string) *Options
SubscriptionOptions returns the name subscription in the Azure profile as a Options struct. If the subscription name is "", the first subscription is returned. If there are no subscriptions or the named subscription is not found, SubscriptionOptions returns nil.
type AzureSubscription ¶ added in v0.3.0
type AzureSubscription struct { EnvironmentName string `json:"environmentName"` ID string `json:"id"` IsDefault bool `json:"isDefault"` ManagementCertificate AzureManagementCertificate `json:"managementCertificate"` ManagementEndpointURL string `json:"managementEndpointUrl"` Name string `json:"name"` RegisteredProviders []string `json:"registeredProviders"` State string `json:"state"` }
type DOProfile ¶ added in v0.8.0
type DOProfile struct {
AccessToken string `json:"token"`
}
DOProfile represents a parsed DigitalOcean profile. This is a custom format specific to Mantle.
type ESXProfile ¶ added in v0.7.0
type ESXProfile struct { Server string `json:"server"` User string `json:"user"` Password string `json:"password"` }
ESXProfile represents a parsed ESX profile. This is a custom format specific to Mantle.
type OpenStackProfile ¶ added in v0.12.0
type OpenStackProfile struct { AuthURL string `json:"auth_url"` TenantID string `json:"tenant_id"` TenantName string `json:"tenant_name"` Username string `json:"username"` Password string `json:"password"` //Optional Domain string `json:"user_domain"` FloatingIPPool string `json:"floating_ip_pool"` Region string `json:"region_name"` }
type Options ¶ added in v0.13.0
type Options struct { *platform.Options SubscriptionName string SubscriptionID string // Azure API endpoint. If unset, the Azure SDK default will be used. ManagementURL string ManagementCertificate []byte // Azure Storage API endpoint suffix. If unset, the Azure SDK default will be used. StorageEndpointSuffix string }
A version of the Options struct from platform/api/azure that only contains the ASM values. Otherwise there's a cyclical depdendence because platform/api/azure has to import auth to have access to the ReadAzureProfile function.
type PacketProfile ¶ added in v0.6.0
PacketProfile represents a parsed Packet profile. This is a custom format specific to Mantle.