fix: correctly escape '.' in volume names
Volume name is derived from the mount path. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
108fd03a72
commit
0fd2aa08bd
@ -172,6 +172,10 @@ func (suite *K8sControlPlaneSuite) TestReconcileExtraVolumes() {
|
||||
VolumeHostPath: "/var/lib",
|
||||
VolumeMountPath: "/var/foo/",
|
||||
},
|
||||
{
|
||||
VolumeHostPath: "/var/lib/a.foo",
|
||||
VolumeMountPath: "/var/foo/b.foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -187,6 +191,12 @@ func (suite *K8sControlPlaneSuite) TestReconcileExtraVolumes() {
|
||||
MountPath: "/var/foo/",
|
||||
ReadOnly: false,
|
||||
},
|
||||
{
|
||||
Name: "var-foo-b-foo",
|
||||
HostPath: "/var/lib/a.foo",
|
||||
MountPath: "/var/foo/b.foo",
|
||||
ReadOnly: false,
|
||||
},
|
||||
}, apiServerCfg.ExtraVolumes,
|
||||
)
|
||||
}
|
||||
|
@ -1252,9 +1252,11 @@ func (v VolumeMountConfig) MountPath() string {
|
||||
return v.VolumeMountPath
|
||||
}
|
||||
|
||||
var volumeNameSanitizer = strings.NewReplacer("/", "-", "_", "-", ".", "-")
|
||||
|
||||
// Name implements the config.VolumeMount interface.
|
||||
func (v VolumeMountConfig) Name() string {
|
||||
return strings.Trim(strings.ReplaceAll(strings.ReplaceAll(v.VolumeMountPath, "/", "-"), "_", "-"), "-")
|
||||
return strings.Trim(volumeNameSanitizer.Replace(v.VolumeMountPath), "-")
|
||||
}
|
||||
|
||||
// ReadOnly implements the config.VolumeMount interface.
|
||||
|
Loading…
x
Reference in New Issue
Block a user