chore(combine-cr): creating the experiments.yaml file for new category automatically (#443)
Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>
This commit is contained in:
committed by
GitHub
parent
c6dafaa31a
commit
c9a37f4a3d
@@ -27,6 +27,12 @@ func main() {
|
|||||||
// set path of combined CR file path
|
// set path of combined CR file path
|
||||||
filePath := directory + "/experiments.yaml"
|
filePath := directory + "/experiments.yaml"
|
||||||
|
|
||||||
|
if isFileExist := IsFileExist(filePath); !isFileExist {
|
||||||
|
if err := TouchFile(filePath); err != nil {
|
||||||
|
log.Fatalf("unable to create the %v file, err: %v", filePath, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// initialize the empty file
|
// initialize the empty file
|
||||||
if err := InitializeFile(filePath); err != nil {
|
if err := InitializeFile(filePath); err != nil {
|
||||||
log.Fatalf("unable to initialize %v file, err: %v", filePath, err)
|
log.Fatalf("unable to initialize %v file, err: %v", filePath, err)
|
||||||
@@ -75,6 +81,15 @@ func IsFileExist(path string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TouchFile create an empty file
|
||||||
|
func TouchFile(name string) error {
|
||||||
|
file, err := os.OpenFile(name, os.O_RDONLY|os.O_CREATE, 0644)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return file.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// CopyData copy the file data from source file to destination file
|
// CopyData copy the file data from source file to destination file
|
||||||
func CopyData(destination, source string) error {
|
func CopyData(destination, source string) error {
|
||||||
|
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user