-
Notifications
You must be signed in to change notification settings - Fork 818
Add missing pvname #250
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
base: master
Are you sure you want to change the base?
Add missing pvname #250
Changes from 3 commits
b48ecac
7a1baca
b47ac8e
faed42f
92d3dd7
a398074
20f7a85
fb780fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ import ( | |
|
|
||
| const ( | ||
| provisionerNameKey = "PROVISIONER_NAME" | ||
| defaultPathPattern = "${.PVC.namespace}-${.PVC.name}-${.PVC.pvname}" | ||
| mountPath = "/persistentvolumes" | ||
| ) | ||
|
|
||
| type nfsProvisioner struct { | ||
|
|
@@ -73,10 +75,6 @@ func (meta *pvcMetadata) stringParser(str string) string { | |
| return str | ||
| } | ||
|
|
||
| const ( | ||
| mountPath = "/persistentvolumes" | ||
| ) | ||
|
|
||
| var _ controller.Provisioner = &nfsProvisioner{} | ||
|
|
||
| func (p *nfsProvisioner) Provision(ctx context.Context, options controller.ProvisionOptions) (*v1.PersistentVolume, controller.ProvisioningState, error) { | ||
|
|
@@ -85,31 +83,27 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi | |
| } | ||
| glog.V(4).Infof("nfs provisioner: VolumeOptions %v", options) | ||
|
|
||
| pvcNamespace := options.PVC.Namespace | ||
| pvcName := options.PVC.Name | ||
|
|
||
| pvName := strings.Join([]string{pvcNamespace, pvcName, options.PVName}, "-") | ||
|
|
||
| metadata := &pvcMetadata{ | ||
| data: map[string]string{ | ||
| "name": pvcName, | ||
| "namespace": pvcNamespace, | ||
| "name": options.PVC.Name, | ||
| "namespace": options.PVC.Namespace, | ||
| "pvname": options.PVName, | ||
| }, | ||
| labels: options.PVC.Labels, | ||
| annotations: options.PVC.Annotations, | ||
| } | ||
|
|
||
| fullPath := filepath.Join(mountPath, pvName) | ||
| path := filepath.Join(p.path, pvName) | ||
|
|
||
| pathPattern, exists := options.StorageClass.Parameters["pathPattern"] | ||
| if exists { | ||
| customPath := metadata.stringParser(pathPattern) | ||
| if customPath != "" { | ||
| path = filepath.Join(p.path, customPath) | ||
| fullPath = filepath.Join(mountPath, customPath) | ||
| } | ||
| if !exists { | ||
robkooper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pathPattern = defaultPathPattern | ||
| } | ||
|
|
||
| parsedPath := metadata.stringParser(pathPattern) | ||
| if parsedPath == "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty parsedPath means that the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
| return nil, controller.ProvisioningFinished, errors.New("unable to parse pathPattern: " + pathPattern) | ||
| } | ||
| path := filepath.Join(p.path, parsedPath) | ||
| fullPath := filepath.Join(mountPath, parsedPath) | ||
|
|
||
| glog.V(4).Infof("creating path %s", fullPath) | ||
| if err := os.MkdirAll(fullPath, 0o777); err != nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.