mirror of
https://github.com/siderolabs/talos.git
synced 2025-11-02 09:21:13 +01:00
fix: sanitize volume name better in static pod extra volumes
Volume name should be DNS name, so make sure we don't have any leading or trailing dashes in the generated volume name. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
5aa75e020e
commit
1a491ee85e
@ -144,7 +144,7 @@ func (suite *K8sControlPlaneSuite) TestReconcileExtraVolumes() {
|
||||
ExtraVolumesConfig: []v1alpha1.VolumeMountConfig{
|
||||
{
|
||||
VolumeHostPath: "/var/lib",
|
||||
VolumeMountPath: "/var/foo",
|
||||
VolumeMountPath: "/var/foo/",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -175,9 +175,9 @@ func (suite *K8sControlPlaneSuite) TestReconcileExtraVolumes() {
|
||||
|
||||
suite.Assert().Equal([]config.K8sExtraVolume{
|
||||
{
|
||||
Name: "-var-foo",
|
||||
Name: "var-foo",
|
||||
HostPath: "/var/lib",
|
||||
MountPath: "/var/foo",
|
||||
MountPath: "/var/foo/",
|
||||
ReadOnly: false,
|
||||
},
|
||||
}, apiServerCfg.ExtraVolumes)
|
||||
|
||||
@ -1312,7 +1312,7 @@ func (v VolumeMountConfig) MountPath() string {
|
||||
|
||||
// Name implements the config.VolumeMount interface.
|
||||
func (v VolumeMountConfig) Name() string {
|
||||
return strings.ReplaceAll(v.VolumeMountPath, "/", "-")
|
||||
return strings.Trim(strings.ReplaceAll(strings.ReplaceAll(v.VolumeMountPath, "/", "-"), "_", "-"), "-")
|
||||
}
|
||||
|
||||
// ReadOnly implements the config.VolumeMount interface.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user