act/cmd/input.go

69 lines
1.3 KiB
Go
Raw Normal View History

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 {
actor string
workdir string
2020-02-04 18:38:41 -06:00
workflowsPath string
autodetectEvent bool
2020-02-04 18:38:41 -06:00
eventPath string
reuseContainers bool
2020-02-24 19:48:21 -06:00
bindWorkdir bool
secrets []string
envs []string
platforms []string
2020-02-04 18:38:41 -06:00
dryrun bool
forcePull bool
noOutput bool
envfile string
secretfile string
insecureSecrets bool
defaultBranch string
2020-08-01 15:21:49 -05:00
privileged bool
usernsMode string
2020-02-04 18:38:41 -06:00
}
func (i *Input) resolve(path string) string {
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
}
// Envfile returns path to .env
func (i *Input) Envfile() string {
return i.resolve(i.envfile)
}
// Secretfile returns path to secrets
func (i *Input) Secretfile() string {
return i.resolve(i.secretfile)
}
// Workdir returns path to workdir
func (i *Input) Workdir() string {
return i.resolve(".")
}
// 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)
}