command/push: add base_dir setting
This commit is contained in:
parent
f76116e4a3
commit
73c5192b35
@ -86,15 +86,32 @@ func (c *PushCommand) Run(args []string) int {
|
|||||||
archiveTemplateEntry: args[0],
|
archiveTemplateEntry: args[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the path we're archiving
|
// Determine the path we're archiving. This logic is a bit complicated
|
||||||
|
// as there are three possibilities:
|
||||||
|
//
|
||||||
|
// 1.) BaseDir is an absolute path, just use that.
|
||||||
|
//
|
||||||
|
// 2.) BaseDir is empty, so we use the directory of the template.
|
||||||
|
//
|
||||||
|
// 3.) BaseDir is relative, so we use the path relative to the directory
|
||||||
|
// of the template.
|
||||||
|
//
|
||||||
path := tpl.Push.BaseDir
|
path := tpl.Push.BaseDir
|
||||||
if path == "" {
|
if path == "" || !filepath.IsAbs(path) {
|
||||||
path, err = filepath.Abs(args[0])
|
tplPath, err := filepath.Abs(args[0])
|
||||||
|
if err != nil {
|
||||||
|
c.Ui.Error(fmt.Sprintf("Error determining path to archive: %s", err))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
tplPath = filepath.Dir(tplPath)
|
||||||
|
if path != "" {
|
||||||
|
tplPath = filepath.Join(tplPath, path)
|
||||||
|
}
|
||||||
|
path, err = filepath.Abs(tplPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error determining path to archive: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error determining path to archive: %s", err))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
path = filepath.Dir(path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the upload options
|
// Build the upload options
|
||||||
|
@ -46,7 +46,7 @@ type Template struct {
|
|||||||
type PushConfig struct {
|
type PushConfig struct {
|
||||||
Name string
|
Name string
|
||||||
Address string
|
Address string
|
||||||
BaseDir string
|
BaseDir string `mapstructure:"base_dir"`
|
||||||
Include []string
|
Include []string
|
||||||
Exclude []string
|
Exclude []string
|
||||||
Token string
|
Token string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user