Documentation ¶
Index ¶
- Constants
- Variables
- func CloudFromKubeConfigCluster(clusterName string, config *clientcmdapi.Config, params CloudParamaters) (cloud.Cloud, error)
- func CloudFromKubeConfigClusterReader(clusterName string, reader io.Reader, params CloudParamaters) (cloud.Cloud, error)
- func CloudFromKubeConfigContext(ctxName string, config *clientcmdapi.Config, params CloudParamaters) (cloud.Cloud, error)
- func CloudFromKubeConfigContextReader(ctxName string, reader io.Reader, params CloudParamaters) (cloud.Cloud, error)
- func CloudsFromKubeConfigContexts(config *clientcmdapi.Config) ([]cloud.Cloud, error)
- func CloudsFromKubeConfigContextsWithParams(params CloudParamaters, config *clientcmdapi.Config) ([]cloud.Cloud, error)
- func ConfigFromReader(reader io.Reader) (*clientcmdapi.Config, error)
- func CredentialFromAuthInfo(authName string, authInfo *clientcmdapi.AuthInfo) (cloud.Credential, error)
- func CredentialFromKubeConfig(authName string, config *clientcmdapi.Config) (cloud.Credential, error)
- func CredentialFromKubeConfigContext(ctxName string, config *clientcmdapi.Config) (cloud.Credential, error)
- func MigrateLegacyCredential(cred *cloud.Credential) (cloud.Credential, error)
- func PickContextByClusterName(config *clientcmdapi.Config, clusterName string) (string, error)
- func SupportedAuthTypes() cloud.AuthTypes
- func SupportedNonLegacyAuthTypes() cloud.AuthTypes
- type CloudParamaters
Constants ¶
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 ¶
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
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 ¶
SupportedAuthTypes returns a slice of supported auth types that the Kubernetes caas provider supports.
func SupportedNonLegacyAuthTypes ¶
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.