Skip to content

Commit

Permalink
ztp: check for missing mount point before processing it
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsoccupied committed Mar 10, 2022
1 parent 539b32f commit 7e2d93b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ztp/siteconfig-generator/siteConfig/siteConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ 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")
}
// run a clean to ensure path is not malformed
defaults.MountPoint = path.Clean(defaults.MountPoint)
// ensure path is absolute
if !(path.IsAbs(defaults.MountPoint)) {
defaults.MountPoint = path.Join("/", defaults.MountPoint)
Expand Down

0 comments on commit 7e2d93b

Please sign in to comment.