/
triggerauthentication_types.go
138 lines (110 loc) · 3.8 KB
/
triggerauthentication_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// TriggerAuthenticationSpec defines the various ways to authenticate
// +k8s:openapi-gen=true
type TriggerAuthenticationSpec struct {
// +optional
PodIdentity AuthPodIdentity `json:"podIdentity"`
// +optional
// +listType
SecretTargetRef []AuthSecretTargetRef `json:"secretTargetRef"`
// +optional
// +listType
Env []AuthEnvironment `json:"env"`
// +optional
HashiCorpVault HashiCorpVault `json:"hashiCorpVault"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TriggerAuthentication defines how a trigger can authenticate
// +k8s:openapi-gen=true
// +kubebuilder:resource:path=triggerauthentications,scope=Namespaced
type TriggerAuthentication struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TriggerAuthenticationSpec `json:"spec"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TriggerAuthenticationList contains a list of TriggerAuthentication
type TriggerAuthenticationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []TriggerAuthentication `json:"items"`
}
// PodIdentityProvider contains the list of providers
type PodIdentityProvider string
const (
PodIdentityProviderNone PodIdentityProvider = "none"
PodIdentityProviderAzure = "azure"
PodIdentityProviderGCP = "gcp"
PodIdentityProviderSpiffe = "spiffe"
PodIdentityProviderAwsEKS = "aws-eks"
PodIdentityProviderAwsKiam = "aws-kiam"
)
const (
PodIdentityAnnotationEKS = "eks.amazonaws.com/role-arn"
PodIdentityAnnotationKiam = "iam.amazonaws.com/role"
)
// AuthPodIdentity allows users to select the platform native identity
// mechanism
// +k8s:openapi-gen=true
type AuthPodIdentity struct {
Provider PodIdentityProvider `json:"provider"`
}
// AuthSecretTargetRef is used to authenticate using a reference to a secret
// +k8s:openapi-gen=true
type AuthSecretTargetRef struct {
Parameter string `json:"parameter"`
Name string `json:"name"`
Key string `json:"key"`
}
// AuthEnvironment is used to authenticate using environment variables
// in the destination deployment spec
// +k8s:openapi-gen=true
type AuthEnvironment struct {
Parameter string `json:"parameter"`
Name string `json:"name"`
// +optional
ContainerName string `json:"containerName"`
}
// HashiCorpVault is used to authenticate using Hashicorp Vault
// +k8s:openapi-gen=true
type HashiCorpVault struct {
Address string `json:"address"`
Authentication VaultAuthentication `json:"authentication"`
// +listType
Secrets []VaultSecret `json:"secrets"`
// +optional
Credential Credential `json:"credential"`
// +optional
Role string `json:"role"`
// +optional
Mount string `json:"mount"`
}
// Credential defines the Hashicorp Vault credentials depending on the authentication method
// +k8s:openapi-gen=true
type Credential struct {
// +optional
Token string `json:"token"`
// +optional
ServiceAccount string `json:"serviceAccount"`
}
// VaultAuthentication contains the list of Hashicorp Vault authentication methods
type VaultAuthentication string
// Client authenticating to Vault
const (
VaultAuthenticationToken VaultAuthentication = "token"
VaultAuthenticationKubernetes = "kubernetes"
// VaultAuthenticationAWS = "aws"
)
// VaultSecret defines the mapping between the path of the secret in Vault to the parameter
// +k8s:openapi-gen=true
type VaultSecret struct {
Parameter string `json:"parameter"`
Path string `json:"path"`
Key string `json:"key"`
}
func init() {
SchemeBuilder.Register(&TriggerAuthentication{}, &TriggerAuthenticationList{})
}