-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (31 loc) · 911 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"encoding/json"
"flag"
"github.com/mtenrero/k8sconfigmap-azappservice/cmapparser"
"io/ioutil"
"log"
)
func main() {
var filePath = flag.String("path", "./configmap.yaml", "Specify ConfigMap file path")
var outPath = flag.String("out", "./azout.json", "Specify target JSON file path")
flag.Parse()
log.Println("Parsing ConfigMap YAML file...")
envVars, err := cmapparser.ParseConfigMapEnvVars(*filePath)
if err != nil {
log.Fatal("Error parsing YAML file")
}
log.Println("Converting to appropriate YAML format")
jsonEnvVars := cmapparser.ConvertToAzureJSON(envVars)
jsonBytes, err := json.Marshal(jsonEnvVars)
if err != nil {
log.Fatal("Error generating JSON output file")
}
log.Println("Writing result to the temporary file...")
err = ioutil.WriteFile(*outPath, jsonBytes, 0644)
if err == nil {
log.Println("Succeeded! :)")
} else {
log.Fatal(err)
}
}