Skip to content

Commit 2c43429

Browse files
added new fields (#211)
Signed-off-by: raffaelespazzoli <raffaele.spazzoli@gmail.com>
1 parent cce4a8e commit 2c43429

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

api/v1alpha1/kubernetessecretenginerole_types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,17 @@ func (r *KubernetesSecretEngineRole) IsValid() (bool, error) {
9494
type KubeSERole struct {
9595

9696
// AllowedKubernetesNamespaces The list of Kubernetes namespaces this role can generate credentials for. If set to "*" all namespaces are allowed.
97-
// +kubebuilder:validation:Required
97+
// +kubebuilder:validation:Optional
9898
// +listType=set
9999
// kubebuilder:validation:UniqueItems=true
100100
AllowedKubernetesNamespaces []string `json:"allowedKubernetesNamespaces,omitempty"`
101101

102+
// A label selector for Kubernetes namespaces in which credentials can be generated.
103+
// Accepts either a JSON or YAML object. The value should be of type LabelSelector as illustrated: "'{'matchLabels':{'stage':'prod','sa-generator':'vault'}}".
104+
// If set with allowed_kubernetes_namespaces, the conditions are ORed.
105+
// +kubebuilder:validation:Optional
106+
AllowedKubernetesNamespaceSelector string `json:"allowedKubernetesNamespaceSelector,omitempty"`
107+
102108
// DeafulTTL Specifies the TTL for the leases associated with this role. Accepts time suffixed strings ("1h") or an integer number of seconds. Defaults to system/engine default TTL time.
103109
// +kubebuilder:validation:Optional
104110
// +kubebuilder:default="0s"
@@ -109,6 +115,11 @@ type KubeSERole struct {
109115
// +kubebuilder:default="0s"
110116
MaxTTL metav1.Duration `json:"maxTTL,omitempty"`
111117

118+
// DefaultAudiences The default intended audiences for generated Kubernetes tokens, specified by a comma separated string. e.g "custom-audience-0,custom-audience-1".
119+
// If not set or set to "", the Kubernetes cluster default for audiences of service account tokens will be used.
120+
// +kubebuilder:validation:Optional
121+
DefaultAudiences string `json:"defaultAudiences,omitempty"`
122+
112123
// ServiceAccountName The pre-existing service account to generate tokens for. Mutually exclusive with all role parameters. If set, only a Kubernetes token will be created when credentials are requested. See the Kubernetes service account documentation for more details on service accounts.
113124
// +kubebuilder:validation:Optional
114125
ServiceAccountName string `json:"serviceAccountName,omitempty"`
@@ -143,8 +154,10 @@ type KubeSERole struct {
143154
func (i *KubeSERole) toMap() map[string]interface{} {
144155
payload := map[string]interface{}{}
145156
payload["allowed_kubernetes_namespaces"] = i.AllowedKubernetesNamespaces
157+
payload["allowed_kubernetes_namespace_selector"] = i.AllowedKubernetesNamespaceSelector
146158
payload["token_max_ttl"] = i.DefaultTTL
147159
payload["token_default_ttl"] = i.MaxTTL
160+
payload["token_default_audiences"] = i.DefaultAudiences
148161
payload["service_account_name"] = i.ServiceAccountName
149162
payload["kubernetes_role_name"] = i.KubernetesRoleName
150163
payload["kubernetes_role_type"] = i.KubernetesRoleType

config/crd/bases/redhatcop.redhat.io_kubernetessecretengineroles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ spec:
3737
description: KubernetesSecretEngineRoleSpec defines the desired state
3838
of KubernetesSecretEngineRole
3939
properties:
40+
allowedKubernetesNamespaceSelector:
41+
description: 'A label selector for Kubernetes namespaces in which
42+
credentials can be generated. Accepts either a JSON or YAML object.
43+
The value should be of type LabelSelector as illustrated: "''{''matchLabels'':{''stage'':''prod'',''sa-generator'':''vault''}}".
44+
If set with allowed_kubernetes_namespaces, the conditions are ORed.'
45+
type: string
4046
allowedKubernetesNamespaces:
4147
description: AllowedKubernetesNamespaces The list of Kubernetes namespaces
4248
this role can generate credentials for. If set to "*" all namespaces
@@ -128,6 +134,12 @@ spec:
128134
description: Timeout Timeout variable. The default value is 60s.
129135
type: string
130136
type: object
137+
defaultAudiences:
138+
description: DefaultAudiences The default intended audiences for generated
139+
Kubernetes tokens, specified by a comma separated string. e.g "custom-audience-0,custom-audience-1".
140+
If not set or set to "", the Kubernetes cluster default for audiences
141+
of service account tokens will be used.
142+
type: string
131143
defaultTTL:
132144
default: 0s
133145
description: DeafulTTL Specifies the TTL for the leases associated

0 commit comments

Comments
 (0)