Skip to content

Commit

Permalink
Merge pull request #1196 from hoyho/feat/pvc_annotation_secret
Browse files Browse the repository at this point in the history
feat: support PVC annotation template for provisioner secret
  • Loading branch information
k8s-ci-robot authored Apr 24, 2024
2 parents d511a50 + 0e262ef commit 6918c44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 1 addition & 6 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,7 @@ func (p *csiProvisioner) prepareProvision(ctx context.Context, claim *v1.Persist
}

// Resolve provision secret credentials.
provisionerSecretRef, err := getSecretReference(provisionerSecretParams, sc.Parameters, pvName, &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: claim.Name,
Namespace: claim.Namespace,
},
})
provisionerSecretRef, err := getSecretReference(provisionerSecretParams, sc.Parameters, pvName, claim)
if err != nil {
return nil, controller.ProvisioningNoChange, err
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,23 @@ func TestGetSecretReference(t *testing.T) {
},
expectErr: true,
},
"template - valid PVC annotations for Provision and Delete": {
secretParams: provisionerSecretParams,
params: map[string]string{
prefixedProvisionerSecretNamespaceKey: "static-${pvc.namespace}",
prefixedProvisionerSecretNameKey: "static-${pvc.name}-${pvc.annotations['akey']}",
},
pvName: "pvname",
pvc: &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "pvcnamespace",
Annotations: map[string]string{"akey": "avalue"},
},
},
expectErr: false,
expectRef: &v1.SecretReference{Name: "static-name-avalue", Namespace: "static-pvcnamespace"},
},
"template - valid nodepublish secret ref": {
secretParams: nodePublishSecretParams,
params: map[string]string{
Expand Down

0 comments on commit 6918c44

Please sign in to comment.