Skip to content

Commit

Permalink
refs #fix bug generate from file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr Dung authored and Mr Dung committed Feb 24, 2021
1 parent 87fedc4 commit 92ea53a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
30 changes: 30 additions & 0 deletions config/yml.go
Original file line number Diff line number Diff line change
@@ -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"
`

0 comments on commit 92ea53a

Please sign in to comment.