cloud

package
v0.0.0-...-9ec3720 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CredAttrUsername is the attribute key for username credentials
	CredAttrUsername = "username"
	// CredAttrPassword is the attribute key for password credentials
	CredAttrPassword = "password"
	// CredAttrClientCertificateData is the attribute key for client certificate credentials
	CredAttrClientCertificateData = "ClientCertificateData"
	// CredAttrClientKeyData is the attribute key for client certificate key credentials
	CredAttrClientKeyData = "ClientKeyData"
	// CredAttrToken is the attribute key for outh2 token credentials
	CredAttrToken = "Token"
	// RBACLabelKeyName key id for rbac credential labels
	RBACLabelKeyName = "rbac-id"
)

Variables

View Source
var LegacyCredentialSchemas = map[cloud.AuthType]cloud.CredentialSchema{
	cloud.OAuth2WithCertAuthType: {
		{
			Name: CredAttrClientCertificateData,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes certificate data",
			},
		},
		{
			Name: CredAttrClientKeyData,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes private key data",
				Hidden:      true,
			},
		},
		{
			Name: CredAttrToken,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes token",
				Hidden:      true,
			},
		},
	},
	cloud.CertificateAuthType: {
		{
			Name: CredAttrClientCertificateData,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes certificate data",
			},
		},
		{
			Name: CredAttrToken,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes service account bearer token",
				Hidden:      true,
			},
		},
		{
			Name: RBACLabelKeyName,
			CredentialAttr: cloud.CredentialAttr{
				Optional:    true,
				Description: "the unique ID key name of the rbac resources",
			},
		},
	},
}

LegacyCredentialsSchemas represents legacy credentials schemas that Juju used to output but still need to be supported to maintain working Kubernetes support. These types should be liberally allowed as input but not used as new output from Juju. This change was introduced by tlm in juju 2.9

View Source
var SupportedCredentialSchemas = map[cloud.AuthType]cloud.CredentialSchema{
	cloud.UserPassAuthType: {
		{
			Name:           CredAttrUsername,
			CredentialAttr: cloud.CredentialAttr{Description: "The username to authenticate with."},
		}, {
			Name: CredAttrPassword,
			CredentialAttr: cloud.CredentialAttr{
				Description: "The password for the specified username.",
				Hidden:      true,
			},
		},
	},
	cloud.OAuth2AuthType: {
		{
			Name: CredAttrToken,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes token",
				Hidden:      true,
			},
		},
		{
			Name: RBACLabelKeyName,
			CredentialAttr: cloud.CredentialAttr{
				Optional:    true,
				Description: "the unique ID key name of the rbac resources",
			},
		},
	},
	cloud.ClientCertificateAuthType: {
		{
			Name: CredAttrClientCertificateData,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes certificate data",
			},
		},
		{
			Name: CredAttrClientKeyData,
			CredentialAttr: cloud.CredentialAttr{
				Description: "the kubernetes certificate key",
				Hidden:      true,
			},
		},
		{
			Name: RBACLabelKeyName,
			CredentialAttr: cloud.CredentialAttr{
				Optional:    true,
				Description: "the unique ID key name of the rbac resources",
			},
		},
	},
}

SupportedCredentialSchemas holds the schemas that the kubernetes caas provider supports.

Functions

func CloudFromKubeConfigCluster

func CloudFromKubeConfigCluster(
	clusterName string,
	config *clientcmdapi.Config,
	params CloudParamaters,
) (cloud.Cloud, error)

CloudFromKubeConfigCluster attempts to construct a Juju cloud object using the supplied Kubernetes config and the cluster name. This function attempts to find a context that it can leverage that uses the specificed cluster name. The first context using the cluster name is taken and if no options exists results in an error.

func CloudFromKubeConfigClusterReader

func CloudFromKubeConfigClusterReader(
	clusterName string,
	reader io.Reader,
	params CloudParamaters,
) (cloud.Cloud, error)

CloudFromKubeConfigClusterReader attempts to construct a Juju cloud object using the supplied raw Kubernetes config in reader and the cluster name. This function attempts to find a context that it can leverage that uses the specificed cluster name. The first context using the cluster name is taken and if no options exists results in an error.

func CloudFromKubeConfigContext

func CloudFromKubeConfigContext(
	ctxName string,
	config *clientcmdapi.Config,
	params CloudParamaters,
) (cloud.Cloud, error)

CloudFromKubeConfigContext generates a juju cloud based on the supplied context and config

func CloudFromKubeConfigContextReader

func CloudFromKubeConfigContextReader(
	ctxName string,
	reader io.Reader,
	params CloudParamaters,
) (cloud.Cloud, error)

CloudFromKubeConfigContextReader constructs a Juju cloud object using the supplied Kubernetes context name and parsing the raw Kubernetes config located in reader.

func CloudsFromKubeConfigContexts

func CloudsFromKubeConfigContexts(config *clientcmdapi.Config) ([]cloud.Cloud, error)

CloudsFromKubeConfigContexts generates a list of clouds from the supplied config context slice

func CloudsFromKubeConfigContextsWithParams

func CloudsFromKubeConfigContextsWithParams(
	params CloudParamaters,
	config *clientcmdapi.Config,
) ([]cloud.Cloud, error)

CloudsFromKubeConfigContextsWithParams generates a list of clouds from the supplied config context slice. Uses params to help seed values for the resulting clouds. Currently only description is taken from params attribute.

func ConfigFromReader

func ConfigFromReader(reader io.Reader) (*clientcmdapi.Config, error)

ConfigFromReader does the heavy lifting of transforming a reader object into a kubernetes api config

func CredentialFromAuthInfo

func CredentialFromAuthInfo(
	authName string,
	authInfo *clientcmdapi.AuthInfo,
) (cloud.Credential, error)

CredentialFromAuthInfo will generate a Juju credential based on the supplied Kubernetes AuthInfo

func CredentialFromKubeConfig

func CredentialFromKubeConfig(
	authName string,
	config *clientcmdapi.Config,
) (cloud.Credential, error)

CredentialFromKubeConfig generates a Juju credential from the supplied Kubernetes config

func CredentialFromKubeConfigContext

func CredentialFromKubeConfigContext(
	ctxName string,
	config *clientcmdapi.Config,
) (cloud.Credential, error)

CredentialFromKubeConfigContext generate a Juju credential from the supplied Kubernetes config context.

func MigrateLegacyCredential

func MigrateLegacyCredential(cred *cloud.Credential) (cloud.Credential, error)

func PickContextByClusterName

func PickContextByClusterName(
	config *clientcmdapi.Config,
	clusterName string,
) (string, error)

PickCOntextByClusterName finds the first available context in the supplied kube config that is using the clusterName. If not context's are found then a not found error is return with an empty context name.

func SupportedAuthTypes

func SupportedAuthTypes() cloud.AuthTypes

SupportedAuthTypes returns a slice of supported auth types that the Kubernetes caas provider supports.

func SupportedNonLegacyAuthTypes

func SupportedNonLegacyAuthTypes() cloud.AuthTypes

SupportedNonLegacyAuthTypes returns a slice of supported auth types that Kubernetes caas provider supports with legacy auth types removed.

Types

type CloudParamaters

type CloudParamaters struct {
	Name            string
	Description     string
	HostCloudRegion string
	Regions         []cloud.Region
}

CloudParameters describes basic properties that should be set on a Juju cloud.Cloud object. This struct exists to help form Cloud structs from Kubernetes config structs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL