feat(clustertool): actually fully block genconfig unless first init is finished
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func InitFiles() error {
|
||||
removeRunAgainFile()
|
||||
ageGen()
|
||||
genRootFiles()
|
||||
genBaseFiles()
|
||||
@@ -145,6 +146,7 @@ func genBaseFiles() error {
|
||||
clusterEnvPresent = true
|
||||
log.Debug().Msg("Detected existing cluster, continuing")
|
||||
} else if os.IsNotExist(err) {
|
||||
createRunAgainFile()
|
||||
log.Warn().Msg("New cluster detected, creating clusterenv.yaml\n Please fill out ClusterEnv.yaml and run init again!")
|
||||
} else {
|
||||
log.Fatal().Err(err).Msgf("Error checking clusterenv file: %s", err)
|
||||
@@ -166,6 +168,38 @@ func genBaseFiles() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create the "RUNAGAIN" file
|
||||
func createRunAgainFile() {
|
||||
file, err := os.Create("RUNAGAIN")
|
||||
if err != nil {
|
||||
log.Err(err).Msg("error creating runagain file...")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// Remove the "RUNAGAIN" file if it exists
|
||||
func removeRunAgainFile() error {
|
||||
if CheckRunAgainFileExists() {
|
||||
err := os.Remove("RUNAGAIN")
|
||||
if err != nil {
|
||||
log.Err(err).Msg("error removing runagain file...")
|
||||
return err
|
||||
}
|
||||
log.Debug().Msg("RUNAGAIN file removed.")
|
||||
} else {
|
||||
log.Debug().Msg("RUNAGAIN file does not exist.")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if the "RUNAGAIN" file exists
|
||||
func CheckRunAgainFileExists() bool {
|
||||
_, err := os.Stat("RUNAGAIN")
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
func UpdateBaseFiles() error {
|
||||
log.Info().Msg("Updating Base files for cluster: helper.ClusterPath")
|
||||
// Read filenames in source directory
|
||||
|
||||
Reference in New Issue
Block a user