refactor: better SSH connection details handling

This commit is contained in:
2021-10-25 10:42:39 +02:00
parent f9e2d24550
commit 9e0d77d5c6
3 changed files with 106 additions and 73 deletions

View File

@ -24,18 +24,16 @@ var recipeNewCommand = &cli.Command{
directory := path.Join(config.APPS_DIR, recipe.Name)
if _, err := os.Stat(directory); !os.IsNotExist(err) {
logrus.Fatalf("'%s' recipe directory already exists?", directory)
return nil
}
url := fmt.Sprintf("%s/example.git", config.REPOS_BASE_URL)
if err := git.Clone(directory, url); err != nil {
return err
logrus.Fatal(err)
}
gitRepo := path.Join(config.APPS_DIR, recipe.Name, ".git")
if err := os.RemoveAll(gitRepo); err != nil {
logrus.Fatal(err)
return nil
}
logrus.Debugf("removed git repo in '%s'", gitRepo)
@ -48,13 +46,11 @@ var recipeNewCommand = &cli.Command{
file, err := os.OpenFile(path, os.O_RDWR, 0755)
if err != nil {
logrus.Fatal(err)
return nil
}
tpl, err := template.ParseFiles(path)
if err != nil {
logrus.Fatal(err)
return nil
}
// TODO: ask for description and probably other things so that the
@ -65,7 +61,6 @@ var recipeNewCommand = &cli.Command{
Description string
}{recipe.Name, "TODO"}); err != nil {
logrus.Fatal(err)
return nil
}
}