|
@@ -58,25 +58,6 @@ var file_keys_map = map[string]map[string]string{
|
|
|
},
|
|
|
}
|
|
|
|
|
|
-func fileExists(filename string) bool {
|
|
|
- info, err := os.Stat(filename)
|
|
|
- if os.IsNotExist(err) {
|
|
|
- return false
|
|
|
- }
|
|
|
- return !info.IsDir()
|
|
|
-}
|
|
|
-
|
|
|
-func deleteFile(path string) {
|
|
|
- // delete file
|
|
|
- var err = os.Remove(path)
|
|
|
- if err != nil {
|
|
|
- fmt.Printf("Failed to delete original file: %s due to error %s... The conf util is going to exit.\n", path, err)
|
|
|
- os.Exit(0)
|
|
|
- return
|
|
|
- }
|
|
|
- fmt.Println("File Deleted")
|
|
|
-}
|
|
|
-
|
|
|
func main() {
|
|
|
fmt.Println(fileMap["edgex"])
|
|
|
files := make(map[string]map[interface{}]interface{})
|
|
@@ -88,11 +69,10 @@ func main() {
|
|
|
message := fmt.Sprintf("-------------------\nConf file %s: \n %s", f, string(bs))
|
|
|
fmt.Println(message)
|
|
|
if fname, ok := fileMap[f]; ok {
|
|
|
- if fileExists(fname) {
|
|
|
- deleteFile(fname)
|
|
|
- }
|
|
|
if e := ioutil.WriteFile(fname, bs, 0644); e != nil {
|
|
|
fmt.Println(e)
|
|
|
+ } else {
|
|
|
+ fmt.Printf("%s updated", fname)
|
|
|
}
|
|
|
}
|
|
|
}
|