Check chart directory existence now
This commit is contained in:
14
README.md
14
README.md
@@ -26,18 +26,20 @@ sudo make install PREFIX=/usr/local
|
|||||||
```bash
|
```bash
|
||||||
Usage of katenary:
|
Usage of katenary:
|
||||||
-appname string
|
-appname string
|
||||||
Give the helm chart app name (default "MyApp")
|
sive the helm chart app name (default "MyApp")
|
||||||
-appversion string
|
-appversion string
|
||||||
Set the chart appVersion (default "0.1.1")
|
set the chart appVersion (default "0.0.1")
|
||||||
|
-chart-dir string
|
||||||
|
set the chart directory (default "chart")
|
||||||
-compose string
|
-compose string
|
||||||
set the compose file to parse (default "docker-compose.yaml")
|
set the compose file to parse (default "docker-compose.yaml")
|
||||||
|
-force
|
||||||
|
force the removal of the chart-dir
|
||||||
-version
|
-version
|
||||||
Show version and exist
|
Show version and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
Katenary will try to find a `docker-compose.yaml` file inside the current directory. It will then **delete** the `chart` directory to create a new Helm Chart.
|
Katenary will try to find a `docker-compose.yaml` file inside the current directory. It will check *the existence of the `chart` directory to create a new Helm Chart inside a named subdirectory. Katenary will ask you if you want to delete it before recreating.
|
||||||
|
|
||||||
> It's important that you keep in mind that katenary will not alert you (for now) that it will remove the `chart` directory !
|
|
||||||
|
|
||||||
It creates a subdirectory inside `chart` that is named with the `appname` option (default is `MyApp`)
|
It creates a subdirectory inside `chart` that is named with the `appname` option (default is `MyApp`)
|
||||||
|
|
||||||
|
34
main.go
34
main.go
@@ -19,13 +19,16 @@ var ComposeFile = "docker-compose.yaml"
|
|||||||
var AppName = "MyApp"
|
var AppName = "MyApp"
|
||||||
var AppVersion = "0.0.1"
|
var AppVersion = "0.0.1"
|
||||||
var Version = "master"
|
var Version = "master"
|
||||||
|
var ChartsDir = "chart"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
flag.StringVar(&ChartsDir, "chart-dir", ChartsDir, "set the chart directory")
|
||||||
flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse")
|
flag.StringVar(&ComposeFile, "compose", ComposeFile, "set the compose file to parse")
|
||||||
flag.StringVar(&AppName, "appname", AppName, "Give the helm chart app name")
|
flag.StringVar(&AppName, "appname", AppName, "sive the helm chart app name")
|
||||||
flag.StringVar(&AppVersion, "appversion", AppVersion, "Set the chart appVersion")
|
flag.StringVar(&AppVersion, "appversion", AppVersion, "set the chart appVersion")
|
||||||
version := flag.Bool("version", false, "Show version and exist")
|
version := flag.Bool("version", false, "Show version and exit")
|
||||||
|
force := flag.Bool("force", false, "force the removal of the chart-dir")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *version {
|
if *version {
|
||||||
@@ -33,6 +36,26 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirname := filepath.Join(ChartsDir, AppName)
|
||||||
|
|
||||||
|
if _, err := os.Stat(dirname); err == nil && !*force {
|
||||||
|
response := ""
|
||||||
|
for response != "y" && response != "n" {
|
||||||
|
response = "n"
|
||||||
|
fmt.Printf("The %s directory already exists, it will be \x1b[31;1mremoved\x1b[0m, do you really want to continue ? [y/N]: ", dirname)
|
||||||
|
fmt.Scanf("%s", &response)
|
||||||
|
response = strings.ToLower(response)
|
||||||
|
}
|
||||||
|
if response == "n" {
|
||||||
|
fmt.Println("Cancelled...")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.RemoveAll(dirname)
|
||||||
|
templatesDir := filepath.Join(dirname, "templates")
|
||||||
|
os.MkdirAll(templatesDir, 0755)
|
||||||
|
|
||||||
helm.Version = Version
|
helm.Version = Version
|
||||||
p := compose.NewParser(ComposeFile)
|
p := compose.NewParser(ComposeFile)
|
||||||
p.Parse(AppName)
|
p.Parse(AppName)
|
||||||
@@ -53,11 +76,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
wait.Wait()
|
wait.Wait()
|
||||||
|
|
||||||
dirname := filepath.Join("chart", AppName)
|
|
||||||
os.RemoveAll(dirname)
|
|
||||||
templatesDir := filepath.Join(dirname, "templates")
|
|
||||||
os.MkdirAll(templatesDir, 0755)
|
|
||||||
|
|
||||||
// to generate notes, we need to keep an Ingresses list
|
// to generate notes, we need to keep an Ingresses list
|
||||||
ingresses := make(map[string]*helm.Ingress)
|
ingresses := make(map[string]*helm.Ingress)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user