Skip to content

Commit

Permalink
ztp: remove prepending var to path
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsoccupied committed Mar 10, 2022
1 parent 20e975d commit 539b32f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions ztp/siteconfig-generator/siteConfig/siteConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:], "/", "-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
diskPartition:
- device: /dev/sda
partitions:
- mount_point: imageregistry
- mount_point: /var/imageregistry
size: 102500
start: 344844
`
Expand Down

0 comments on commit 539b32f

Please sign in to comment.