Fix typos, update types and add comments
Signed-off-by: Clément Blaise <clementblaise@me.com>
This commit is contained in:
parent
f3cde1bfc8
commit
c2fac0f7b2
|
|
@ -129,17 +129,17 @@ func GetExtraResources(req *v1beta1.RunFunctionRequest) (map[string][]resource.E
|
|||
return out, nil
|
||||
}
|
||||
|
||||
// GetCredential from the supplied request.
|
||||
func GetCredential(req *v1beta1.RunFunctionRequest, name string) (resource.Credential, error) {
|
||||
// GetCredentials from the supplied request.
|
||||
func GetCredentials(req *v1beta1.RunFunctionRequest, name string) (resource.Credentials, error) {
|
||||
cred, exists := req.GetCredentials()[name]
|
||||
if !exists {
|
||||
return resource.Credential{}, errors.Errorf("%s: credential not found", name)
|
||||
return resource.Credentials{}, errors.Errorf("%s: credential not found", name)
|
||||
}
|
||||
|
||||
switch t := cred.GetSource().(type) {
|
||||
case *v1beta1.Credentials_CredentialData:
|
||||
return resource.Credential{Type: resource.CredentialsTypeData, Data: cred.GetCredentialData().GetData()}, nil
|
||||
return resource.Credentials{Type: resource.CredentialsTypeData, Data: cred.GetCredentialData().GetData()}, nil
|
||||
default:
|
||||
return resource.Credential{}, errors.Errorf("%s: not a supported credential source", t)
|
||||
return resource.Credentials{}, errors.Errorf("%s: not a supported credential source", t)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,17 +57,21 @@ type Extra struct {
|
|||
Resource *unstructured.Unstructured
|
||||
}
|
||||
|
||||
// CredentialsType is the type of credentials
|
||||
// CredentialsType is the type of credentials.
|
||||
type CredentialsType string
|
||||
|
||||
const (
|
||||
// CredentialsTypeData is a Credential which of type Data
|
||||
// CredentialsTypeData is a Credential of type Data.
|
||||
CredentialsTypeData = "Data"
|
||||
)
|
||||
|
||||
// Credential is a secret requested by a Function
|
||||
type Credential struct {
|
||||
// Credentials is a secret requested by a Function.
|
||||
type Credentials struct {
|
||||
// Type represents the type of credentials.
|
||||
Type CredentialsType
|
||||
|
||||
// Data is a map of key-value pairs where the keys are strings, and the values are byte slices
|
||||
// containing sensitive data.
|
||||
Data map[string][]byte
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue