github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/joyent/credentials.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package joyent 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 credAttrSDCUser = "sdc-user" 15 credAttrSDCKeyID = "sdc-key-id" 16 credAttrPrivateKey = "private-key" 17 credAttrAlgorithm = "algorithm" 18 19 algorithmDefault = "rsa-sha256" 20 ) 21 22 type environProviderCredentials struct{} 23 24 // CredentialSchemas is part of the environs.ProviderCredentials interface. 25 func (environProviderCredentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema { 26 return map[cloud.AuthType]cloud.CredentialSchema{ 27 // TODO(axw) we need a more appropriate name for this authentication 28 // type. ssh? 29 cloud.UserPassAuthType: {{ 30 credAttrSDCUser, cloud.CredentialAttr{Description: "SmartDataCenter user ID"}, 31 }, { 32 credAttrSDCKeyID, cloud.CredentialAttr{Description: "SmartDataCenter key ID"}, 33 }, { 34 credAttrPrivateKey, cloud.CredentialAttr{ 35 Description: "Private key used to sign requests", 36 Hidden: true, 37 FileAttr: "private-key-path", 38 }, 39 }, { 40 credAttrAlgorithm, cloud.CredentialAttr{ 41 Description: "Algorithm used to generate the private key (default rsa-sha256)", 42 Optional: true, 43 Options: []interface{}{"rsa-sha256", "rsa-sha1", "rsa-sha224", "rsa-sha384", "rsa-sha512"}, 44 }, 45 }}, 46 } 47 } 48 49 // DetectCredentials is part of the environs.ProviderCredentials interface. 50 func (environProviderCredentials) DetectCredentials() (*cloud.CloudCredential, error) { 51 return nil, errors.NotFoundf("credentials") 52 } 53 54 // FinalizeCredential is part of the environs.ProviderCredentials interface. 55 func (environProviderCredentials) FinalizeCredential(_ environs.FinalizeCredentialContext, args environs.FinalizeCredentialParams) (*cloud.Credential, error) { 56 return &args.Credential, nil 57 }