forked from rook/rook
core: provide option to specify secret name
When cephClient CR is created by User, the Rook is creating an User and creating an secret with its own predefined name + CR name, With this we are allowing user to specify the secretName Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
@@ -592,6 +592,32 @@ string
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>secretName</code><br/>
|
||||
<em>
|
||||
string
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>SecretName is the name of the secret created for this ceph client.
|
||||
If not specified, the default name is “rook-ceph-client-” as a prefix to the CR name.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>removeSecret</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
|
||||
If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>caps</code><br/>
|
||||
<em>
|
||||
map[string]string
|
||||
@@ -4661,6 +4687,32 @@ string
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>secretName</code><br/>
|
||||
<em>
|
||||
string
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>SecretName is the name of the secret created for this ceph client.
|
||||
If not specified, the default name is “rook-ceph-client-” as a prefix to the CR name.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>removeSecret</code><br/>
|
||||
<em>
|
||||
bool
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
|
||||
If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>caps</code><br/>
|
||||
<em>
|
||||
map[string]string
|
||||
|
||||
@@ -1293,6 +1293,19 @@ spec:
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
name:
|
||||
type: string
|
||||
removeSecret:
|
||||
description: |-
|
||||
RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
|
||||
If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
|
||||
type: boolean
|
||||
secretName:
|
||||
description: |-
|
||||
SecretName is the name of the secret created for this ceph client.
|
||||
If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: SecretName is immutable and cannot be changed
|
||||
rule: self == oldSelf
|
||||
required:
|
||||
- caps
|
||||
type: object
|
||||
|
||||
@@ -1292,6 +1292,19 @@ spec:
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
name:
|
||||
type: string
|
||||
removeSecret:
|
||||
description: |-
|
||||
RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
|
||||
If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
|
||||
type: boolean
|
||||
secretName:
|
||||
description: |-
|
||||
SecretName is the name of the secret created for this ceph client.
|
||||
If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
|
||||
type: string
|
||||
x-kubernetes-validations:
|
||||
- message: SecretName is immutable and cannot be changed
|
||||
rule: self == oldSelf
|
||||
required:
|
||||
- caps
|
||||
type: object
|
||||
|
||||
@@ -3079,6 +3079,16 @@ type CephClientList struct {
|
||||
type ClientSpec struct {
|
||||
// +optional
|
||||
Name string `json:"name,omitempty"`
|
||||
// SecretName is the name of the secret created for this ceph client.
|
||||
// If not specified, the default name is "rook-ceph-client-" as a prefix to the CR name.
|
||||
// +kubebuilder:validation:XValidation:message="SecretName is immutable and cannot be changed",rule="self == oldSelf"
|
||||
// +optional
|
||||
SecretName string `json:"secretName,omitempty"`
|
||||
|
||||
// RemoveSecret indicates whether the current secret for this ceph client should be removed or not.
|
||||
// If true, the K8s secret will be deleted, but the cephx keyring will remain until the CR is deleted.
|
||||
// +optional
|
||||
RemoveSecret bool `json:"removeSecret,omitempty"`
|
||||
// +kubebuilder:pruning:PreserveUnknownFields
|
||||
Caps map[string]string `json:"caps"`
|
||||
}
|
||||
|
||||
@@ -399,5 +399,8 @@ func generateStatusInfo(client *cephv1.CephClient) map[string]string {
|
||||
}
|
||||
|
||||
func generateCephUserSecretName(client *cephv1.CephClient) string {
|
||||
if client.Spec.SecretName != "" {
|
||||
return client.Spec.SecretName // return the secret name as requested by user.
|
||||
}
|
||||
return fmt.Sprintf("rook-ceph-client-%s", client.Name)
|
||||
}
|
||||
|
||||
@@ -312,5 +312,21 @@ func TestBuildUpdateStatusInfo(t *testing.T) {
|
||||
|
||||
statusInfo := generateStatusInfo(cephClient)
|
||||
assert.NotEmpty(t, statusInfo["secretName"])
|
||||
assert.Equal(t, "rook-ceph-client-client-ocp", statusInfo["secretName"])
|
||||
assert.Equal(t, generateCephUserSecretName(cephClient), statusInfo["secretName"])
|
||||
}
|
||||
|
||||
func TestCustomSecretname(t *testing.T) {
|
||||
secretName := "test-secret"
|
||||
cephClient := &cephv1.CephClient{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "client-ocp",
|
||||
},
|
||||
Spec: cephv1.ClientSpec{
|
||||
SecretName: secretName,
|
||||
},
|
||||
}
|
||||
|
||||
statusInfo := generateStatusInfo(cephClient)
|
||||
assert.NotEmpty(t, statusInfo["secretName"])
|
||||
assert.Equal(t, secretName, statusInfo["secretName"])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user