// GetKubernetesSecret return Azure credentials as a Kubernetes Secret
GetKubernetesSecret return Azure credentials as a Kubernetes Secret
// GetKubernetesSecret return Azure credentials as a Kubernetes Secret
func (c *AzureKeyVaultCredentials) GetKubernetesSecret(secretName string) (*corev1.Secret, error) {
	switch c.CredentialsType {
	case CredentialsTypeClientCredentials:
		c, err := c.envSettings.GetClientCredentials()
		if err != nil {
			return nil, err
		}
		return &corev1.Secret{
			ObjectMeta: metav1.ObjectMeta{
				Name: secretName,
			},
			StringData: map[string]string{
				"client-id":     c.ClientID,
				"client-secret": c.ClientSecret,
				"tenant-id":     c.TenantID,
			},
		}, nil
	case CredentialsTypeClientCertificate:
		c, err := c.envSettings.GetClientCertificate()
		if err != nil {
			return nil, err
		}
		return &corev1.Secret{
			ObjectMeta: metav1.ObjectMeta{
				Name: secretName,
			},
			StringData: map[string]string{
				"client-id":            c.ClientID,
				"client-cert-path":     c.CertificatePath,
				"client-cert-password": c.CertificatePassword,
				"tenant-id":            c.TenantID,
			},
		}, nil
	case CredentialsTypeClientUsernamePassword:
		c, err := c.envSettings.GetUsernamePassword()
		if err != nil {
			return nil, err
		}
		return &corev1.Secret{
			ObjectMeta: metav1.ObjectMeta{
				Name: secretName,
			},
			StringData: map[string]string{
				"client-id": c.ClientID,
				"username":  c.Username,
				"password":  c.Password,
				"tenant-id": c.TenantID,
			},
		}, nil
	default:
		return nil, fmt.Errorf("failed to get azure credentials, credential type %s unknown", c.CredentialsType)
	}
}
func ( c * AzureKeyVaultCredentials ) GetKubernetesSecret ( secretName string ) ( * corev1 . Secret , error ) { switch c . CredentialsType { case CredentialsTypeClientCredentials : c , err := c . envSettings . GetClientCredentials ( ) if err != nil { return nil , err } return & corev1 . Secret { ObjectMeta : metav1 . ObjectMeta { Name : secretName , } , StringData : map [ string ] string { " " : c . ClientID , " " : c . ClientSecret , " " : c . TenantID , } , } , nil case CredentialsTypeClientCertificate : c , err := c . envSettings . GetClientCertificate ( ) if err != nil { return nil , err } return & corev1 . Secret { ObjectMeta : metav1 . ObjectMeta { Name : secretName , } , StringData : map [ string ] string { " " : c . ClientID , " " : c . CertificatePath , " " : c . CertificatePassword , " " : c . TenantID , } , } , nil case CredentialsTypeClientUsernamePassword : c , err := c . envSettings . GetUsernamePassword ( ) if err != nil { return nil , err } return & corev1 . Secret { ObjectMeta : metav1 . ObjectMeta { Name : secretName , } , StringData : map [ string ] string { " " : c . ClientID , " " : c . Username , " " : c . Password , " " : c . TenantID , } , } , nil default : return nil , fmt . Errorf ( " " , c . CredentialsType ) } }
GetKubernetesSecret return Azure credentials as a Kubernetes Secret
GetKubernetesSecret return Azure credentials as a Kubernetes Secret