2020-02-05 08:38:41 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Input contains the input for the root command
|
|
|
|
type Input struct {
|
2020-05-12 15:14:56 +08:00
|
|
|
actor string
|
2020-02-07 14:17:58 +08:00
|
|
|
workdir string
|
2020-02-05 08:38:41 +08:00
|
|
|
workflowsPath string
|
|
|
|
eventPath string
|
|
|
|
reuseContainers bool
|
2020-02-25 09:48:21 +08:00
|
|
|
bindWorkdir bool
|
2020-02-18 13:51:49 +08:00
|
|
|
secrets []string
|
2020-02-20 11:16:40 +08:00
|
|
|
platforms []string
|
2020-02-05 08:38:41 +08:00
|
|
|
dryrun bool
|
|
|
|
forcePull bool
|
2020-02-21 00:57:18 +08:00
|
|
|
noOutput bool
|
2020-03-07 04:30:24 +08:00
|
|
|
envfile string
|
2020-04-18 01:04:40 +08:00
|
|
|
secretfile string
|
2020-02-05 08:38:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Input) resolve(path string) string {
|
2020-02-07 14:17:58 +08:00
|
|
|
basedir, err := filepath.Abs(i.workdir)
|
2020-02-05 08:38:41 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
if path == "" {
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
if !filepath.IsAbs(path) {
|
|
|
|
path = filepath.Join(basedir, path)
|
|
|
|
}
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2020-03-07 04:30:24 +08:00
|
|
|
// Envfile returns path to .env
|
|
|
|
func (i *Input) Envfile() string {
|
|
|
|
return i.resolve(i.envfile)
|
|
|
|
}
|
|
|
|
|
2020-04-18 01:04:40 +08:00
|
|
|
// Secretfile returns path to secrets
|
|
|
|
func (i *Input) Secretfile() string {
|
|
|
|
return i.resolve(i.secretfile)
|
|
|
|
}
|
|
|
|
|
2020-02-07 14:17:58 +08:00
|
|
|
// Workdir returns path to workdir
|
|
|
|
func (i *Input) Workdir() string {
|
|
|
|
return i.resolve(".")
|
|
|
|
}
|
|
|
|
|
2020-02-05 08:38:41 +08:00
|
|
|
// WorkflowsPath returns path to workflows
|
|
|
|
func (i *Input) WorkflowsPath() string {
|
|
|
|
return i.resolve(i.workflowsPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EventPath returns the path to events file
|
|
|
|
func (i *Input) EventPath() string {
|
|
|
|
return i.resolve(i.eventPath)
|
|
|
|
}
|