Skip to content

Commit f4ed47e

Browse files
spuiukphlogistonjohn
authored andcommitted
resources: Add code to use Spec.Storage.PVC.path
We use this to mount the path within a pvc. Signed-off-by: Sachin Prabhu <[email protected]>
1 parent e39cbb3 commit f4ed47e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

internal/planner/configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ func (pl *Planner) Update() (changed bool, err error) {
101101
}
102102
pl.ConfigState.Shares[shareKey] = share
103103
changed = true
104+
} else if share.Options["path"] != pl.Paths().Share() {
105+
// Update path if changed
106+
share.Options["path"] = pl.Paths().Share()
104107
}
105108
cfgKey := pl.instanceID()
106109
cfg, found := pl.ConfigState.Configs[cfgKey]

internal/planner/paths.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ func (planner *Planner) Paths() *Paths {
3030
return &Paths{planner}
3131
}
3232

33+
// ShareMountPath returns the mount path.
34+
func (p *Paths) ShareMountPath() string {
35+
return path.Join("/mnt", string(p.planner.SmbShare.UID))
36+
}
37+
3338
// Share path.
3439
func (p *Paths) Share() string {
35-
return path.Join("/mnt", string(p.planner.SmbShare.UID))
40+
sharepath := p.planner.SmbShare.Spec.Storage.Pvc.Path
41+
if sharepath != "" {
42+
return path.Join(p.ShareMountPath(), "/", sharepath)
43+
}
44+
return p.ShareMountPath()
3645
}
3746

3847
// ContainerConfigs returns a slice containing all configuration

internal/resources/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func shareVolumeAndMount(planner *pln.Planner, pvcName string) volMount {
6666
}
6767
// mount
6868
vmnt.mount = corev1.VolumeMount{
69-
MountPath: planner.Paths().Share(),
69+
MountPath: planner.Paths().ShareMountPath(),
7070
Name: pvcVolName,
7171
}
7272
return vmnt

0 commit comments

Comments
 (0)