github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/vsphere/credentials.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package vsphere
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  
     9  	"github.com/juju/juju/cloud"
    10  	"github.com/juju/juju/environs"
    11  )
    12  
    13  const (
    14  	credAttrUser     = "user"
    15  	credAttrPassword = "password"
    16  	credAttrVMFolder = "vmfolder"
    17  )
    18  
    19  type environProviderCredentials struct{}
    20  
    21  // CredentialSchemas is part of the environs.ProviderCredentials interface.
    22  func (environProviderCredentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema {
    23  	return map[cloud.AuthType]cloud.CredentialSchema{
    24  		cloud.UserPassAuthType: {
    25  			{
    26  				Name: credAttrUser,
    27  				CredentialAttr: cloud.CredentialAttr{
    28  					Description: "The username to authenticate with.",
    29  				},
    30  			}, {
    31  				Name: credAttrPassword,
    32  				CredentialAttr: cloud.CredentialAttr{
    33  					Description: "The password to authenticate with.",
    34  					Hidden:      true,
    35  				},
    36  			}, {
    37  				Name: credAttrVMFolder,
    38  				CredentialAttr: cloud.CredentialAttr{
    39  					Description: "The folder to add VMs from the model.",
    40  					Optional:    true,
    41  				},
    42  			},
    43  		},
    44  	}
    45  }
    46  
    47  // DetectCredentials is part of the environs.ProviderCredentials interface.
    48  func (environProviderCredentials) DetectCredentials(cloudName string) (*cloud.CloudCredential, error) {
    49  	return nil, errors.NotFoundf("credentials")
    50  }
    51  
    52  // FinalizeCredential is part of the environs.ProviderCredentials interface.
    53  func (environProviderCredentials) FinalizeCredential(_ environs.FinalizeCredentialContext, args environs.FinalizeCredentialParams) (*cloud.Credential, error) {
    54  	return &args.Credential, nil
    55  }