2020-02-04 18:38:41 -06:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Input contains the input for the root command
|
|
|
|
type Input struct {
|
2020-05-12 02:14:56 -05:00
|
|
|
actor string
|
2020-02-07 00:17:58 -06:00
|
|
|
workdir string
|
2020-02-04 18:38:41 -06:00
|
|
|
workflowsPath string
|
2021-01-18 13:42:55 -06:00
|
|
|
autodetectEvent bool
|
2020-02-04 18:38:41 -06:00
|
|
|
eventPath string
|
|
|
|
reuseContainers bool
|
2020-02-24 19:48:21 -06:00
|
|
|
bindWorkdir bool
|
2020-02-17 23:51:49 -06:00
|
|
|
secrets []string
|
2021-01-14 23:26:01 -06:00
|
|
|
envs []string
|
2020-02-19 21:16:40 -06:00
|
|
|
platforms []string
|
2020-02-04 18:38:41 -06:00
|
|
|
dryrun bool
|
|
|
|
forcePull bool
|
2020-02-20 10:57:18 -06:00
|
|
|
noOutput bool
|
2020-03-06 14:30:24 -06:00
|
|
|
envfile string
|
2020-04-17 12:04:40 -05:00
|
|
|
secretfile string
|
2021-01-12 00:28:45 -06:00
|
|
|
insecureSecrets bool
|
2020-09-02 09:56:44 -05:00
|
|
|
defaultBranch string
|
2020-08-01 15:21:49 -05:00
|
|
|
privileged bool
|
2021-02-27 10:31:25 -06:00
|
|
|
usernsMode string
|
2020-02-04 18:38:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Input) resolve(path string) string {
|
2020-02-07 00:17:58 -06:00
|
|
|
basedir, err := filepath.Abs(i.workdir)
|
2020-02-04 18:38:41 -06:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
if path == "" {
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
if !filepath.IsAbs(path) {
|
|
|
|
path = filepath.Join(basedir, path)
|
|
|
|
}
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2020-03-06 14:30:24 -06:00
|
|
|
// Envfile returns path to .env
|
|
|
|
func (i *Input) Envfile() string {
|
|
|
|
return i.resolve(i.envfile)
|
|
|
|
}
|
|
|
|
|
2020-04-17 12:04:40 -05:00
|
|
|
// Secretfile returns path to secrets
|
|
|
|
func (i *Input) Secretfile() string {
|
|
|
|
return i.resolve(i.secretfile)
|
|
|
|
}
|
|
|
|
|
2020-02-07 00:17:58 -06:00
|
|
|
// Workdir returns path to workdir
|
|
|
|
func (i *Input) Workdir() string {
|
|
|
|
return i.resolve(".")
|
|
|
|
}
|
|
|
|
|
2020-05-26 22:29:50 -05:00
|
|
|
// WorkflowsPath returns path to workflow file(s)
|
2020-02-04 18:38:41 -06:00
|
|
|
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)
|
|
|
|
}
|