Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for storageClass.withPathSuffix #125

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/nfs-subdir-external-provisioner/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: 4.0.2
description: nfs-subdir-external-provisioner is an automatic provisioner that used your *already configured* NFS server, automatically creating Persistent Volumes.
name: nfs-subdir-external-provisioner
home: https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner
version: 4.0.12
version: 4.0.13
kubeVersion: ">=1.9.0-0"
sources:
- https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner
Expand Down
3 changes: 2 additions & 1 deletion charts/nfs-subdir-external-provisioner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ The following tables lists the configurable parameters of this chart and their d
| `storageClass.provisionerName` | Name of the provisionerName | null |
| `storageClass.archiveOnDelete` | Archive PVC when deleting | `true` |
| `storageClass.onDelete` | Strategy on PVC deletion. Overrides archiveOnDelete when set to lowercase values 'delete' or 'retain' | null |
| `storageClass.pathPattern` | Specifies a template for the directory name | null |
| `storageClass.pathPattern` | Specifies a template for the directory name. Ignored if `storageClass.pathPattern` is set to false | null |
| `storageClass.withPathSuffix` | Specifies if a suffix is added to the path. | `true` |
| `storageClass.accessModes` | Set access mode for PV | `ReadWriteOnce` |
| `storageClass.annotations` | Set additional annotations for the StorageClass | `{}` |
| `leaderElection.enabled` | Enables or disables leader election | `true` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ allowVolumeExpansion: {{ .Values.storageClass.allowVolumeExpansion }}
reclaimPolicy: {{ .Values.storageClass.reclaimPolicy }}
parameters:
archiveOnDelete: "{{ .Values.storageClass.archiveOnDelete }}"
withPathSuffix: "{{ .Values.storageClass.withPathSuffix }}"
{{- if .Values.storageClass.pathPattern }}
pathPattern: "{{ .Values.storageClass.pathPattern }}"
{{- end }}
Expand Down
6 changes: 6 additions & 0 deletions charts/nfs-subdir-external-provisioner/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ storageClass:
# Ignored if value not set.
onDelete:

# If the directory path should have a suffix to nfs.path
# If true, it will use either storageClass.pathPattern or ${namespace}-${pvcName}-${pvName}
# If false, it will not add any suffix to nfs.path regardless of storageClass.pathPattern
withPathSuffix: true

# Specifies a template for creating a directory path via PVC metadata's such as labels, annotations, name or namespace.
# Ignored if value not set.
# If storageClass.withPathSuffix is false, pathPattern will be ignored even if it is set
pathPattern:

# Set access mode - ReadWriteOnce, ReadOnlyMany or ReadWriteMany
Expand Down
15 changes: 14 additions & 1 deletion cmd/nfs-subdir-external-provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,20 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
path := filepath.Join(p.path, pvName)

pathPattern, exists := options.StorageClass.Parameters["pathPattern"]
if exists {
withPathSuffix, existsWithPathSuffix := options.StorageClass.Parameters["withPathSuffix"]
// default is true
withPathSuffixBool := true
if existsWithPathSuffix {
var err error
withPathSuffixBool, err = strconv.ParseBool(withPathSuffix)
if err != nil {
return nil, controller.ProvisioningFinished, fmt.Errorf("storageClass.withPathSuffix is not a boolean value")
}
}
if !withPathSuffixBool {
path = p.path
fullPath = mountPath
} else if exists {
customPath := metadata.stringParser(pathPattern)
if customPath != "" {
path = filepath.Join(p.path, customPath)
Expand Down