From 92ea53afcf931842b8e5c21cf9ce518f7e098f9e Mon Sep 17 00:00:00 2001 From: Mr Dung Date: Wed, 24 Feb 2021 22:20:41 +0700 Subject: [PATCH] refs #fix bug generate from file --- cmd/init.go | 5 +++-- config/yml.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 config/yml.go diff --git a/cmd/init.go b/cmd/init.go index 12b52b3..2ca6498 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "github.com/AlecAivazis/survey/v2" + "github.com/dung13890/deploy-tool/config" "github.com/fatih/color" "github.com/urfave/cli/v2" "log" @@ -91,11 +92,11 @@ func (a *answers) createFile(filename string) (err error) { return } // Parse template to template yml - t, err := template.ParseFiles(filepath.Join(dir, "templates", "config.tmpl")) + t, err := template.New("index").Parse(config.SourceYaml) if err != nil { return } - t.ExecuteTemplate(f, "config", a) + t.Execute(f, a) return nil } diff --git a/config/yml.go b/config/yml.go new file mode 100644 index 0000000..d1cca38 --- /dev/null +++ b/config/yml.go @@ -0,0 +1,30 @@ +package config + +var SourceYaml = `server: + address: "{{ .Ip }}" + user: "ec2-user" + port: 22 + dir: "/data/sites" + project: "{{ .Project }}" +repository: + url: "{{ .Repo }}" + branch: "master" + # tag: "1.0.2" +shared: + folders: + - "vendor" + - "node_modules" + files: + - ".env" +tasks: + - "echo 'Hello!!'" +cluster: + hosts: + # - "127.0.0.1" + rsync: + excludes: + - ".env" + - "*.log" + cmds: + - "uname -a" +`