Skip to content

Commit

Permalink
Merge pull request #5935 from nutanix-cloud-native/btstrp-ign-dir-fix
Browse files Browse the repository at this point in the history
Bug 2088660: Fix for absence folder for bootstrap ignition iso
  • Loading branch information
openshift-merge-robot authored May 25, 2022
2 parents 4a31317 + 80064b0 commit 62ed461
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/types/nutanix/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ func CreateBootstrapISO(infraID, userData string) (string, error) {
}

fullISOFile := BootISOImagePath(cacheDir, infraID)
fullISOFileDir, err := filepath.Abs(filepath.Dir(fullISOFile))
if err != nil {
return "", errors.Wrap(err, "unable to extract parent directory from bootstrap iso filepath")
}

_, err = os.Stat(fullISOFileDir)
if err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(fullISOFileDir, 0755)
if err != nil {
return "", errors.Wrap(err, fmt.Sprintf("failed to create %s", fullISOFileDir))
}
} else {
return "", errors.Wrap(err, fmt.Sprintf("cannot access %s", fullISOFileDir))
}
}

outputFile, err := os.OpenFile(fullISOFile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
return "", errors.Wrap(err, fmt.Sprintf("failed to create file: %s", err))
Expand Down

0 comments on commit 62ed461

Please sign in to comment.