From 539b32fb8eca8f9c0acf2815737757eb380327b5 Mon Sep 17 00:00:00 2001 From: Nahian Pathan Date: Mon, 28 Feb 2022 12:33:44 -0500 Subject: [PATCH] ztp: remove prepending var to path --- ztp/siteconfig-generator/siteConfig/siteConfig.go | 10 ++-------- .../siteConfig/siteConfigBuilder_test.go | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ztp/siteconfig-generator/siteConfig/siteConfig.go b/ztp/siteconfig-generator/siteConfig/siteConfig.go index a3c5ba6f54..152335fe32 100644 --- a/ztp/siteconfig-generator/siteConfig/siteConfig.go +++ b/ztp/siteconfig-generator/siteConfig/siteConfig.go @@ -258,6 +258,8 @@ func (prt *Partitions) UnmarshalYAML(unmarshal func(interface{}) error) error { err = fmt.Errorf("choose an appropritate disk size. must be greater than 0") } + // run a clean to ensure path is not malformed + defaults.MountPoint = path.Clean(defaults.MountPoint) // it's a required field if defaults.MountPoint == "" { err = fmt.Errorf("must provide a path for mount_point. e.g /var/path") @@ -266,14 +268,6 @@ func (prt *Partitions) UnmarshalYAML(unmarshal func(interface{}) error) error { if !(path.IsAbs(defaults.MountPoint)) { defaults.MountPoint = path.Join("/", defaults.MountPoint) } - // https://docs.openshift.com/container-platform/4.9/installing/installing_bare_metal/installing-bare-metal.html#installation-user-infra-machines-advanced_vardisk_installing-bare-metal - // starts at var - if !(strings.HasPrefix(defaults.MountPoint, "/var")) { - defaults.MountPoint = path.Join("/var", defaults.MountPoint) - } else { - // run a clean to ensure path is not malformed - defaults.MountPoint = path.Clean(defaults.MountPoint) - } // generate label from path defaults.Label = strings.ReplaceAll(defaults.MountPoint[1:], "/", "-") diff --git a/ztp/siteconfig-generator/siteConfig/siteConfigBuilder_test.go b/ztp/siteconfig-generator/siteConfig/siteConfigBuilder_test.go index fe52e8bd0e..8a0606a8df 100644 --- a/ztp/siteconfig-generator/siteConfig/siteConfigBuilder_test.go +++ b/ztp/siteconfig-generator/siteConfig/siteConfigBuilder_test.go @@ -69,7 +69,7 @@ spec: diskPartition: - device: /dev/sda partitions: - - mount_point: imageregistry + - mount_point: /var/imageregistry size: 102500 start: 344844 `