summaryrefslogtreecommitdiffstats
path: root/cmd/input.go
blob: 36af6d866cd4d9387982e96d1a4908434dad3937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package cmd

import (
	"path/filepath"

	log "github.com/sirupsen/logrus"
)

// Input contains the input for the root command
type Input struct {
	actor                              string
	workdir                            string
	workflowsPath                      string
	autodetectEvent                    bool
	eventPath                          string
	reuseContainers                    bool
	bindWorkdir                        bool
	secrets                            []string
	vars                               []string
	envs                               []string
	inputs                             []string
	platforms                          []string
	dryrun                             bool
	forcePull                          bool
	forceRebuild                       bool
	noOutput                           bool
	envfile                            string
	inputfile                          string
	secretfile                         string
	varfile                            string
	insecureSecrets                    bool
	defaultBranch                      string
	privileged                         bool
	usernsMode                         string
	containerArchitecture              string
	containerDaemonSocket              string
	containerOptions                   string
	noWorkflowRecurse                  bool
	useGitIgnore                       bool
	githubInstance                     string
	containerCapAdd                    []string
	containerCapDrop                   []string
	autoRemove                         bool
	artifactServerPath                 string
	artifactServerAddr                 string
	artifactServerPort                 string
	noCacheServer                      bool
	cacheServerPath                    string
	cacheServerAddr                    string
	cacheServerPort                    uint16
	jsonLogger                         bool
	noSkipCheckout                     bool
	remoteName                         string
	replaceGheActionWithGithubCom      []string
	replaceGheActionTokenWithGithubCom string
	matrix                             []string
	actionCachePath                    string
	actionOfflineMode                  bool
	logPrefixJobID                     bool
	networkName                        string
	useNewActionCache                  bool
}

func (i *Input) resolve(path string) string {
	basedir, err := filepath.Abs(i.workdir)
	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)
}

func (i *Input) Varfile() string {
	return i.resolve(i.varfile)
}

// Workdir returns path to workdir
func (i *Input) Workdir() string {
	return i.resolve(".")
}

// WorkflowsPath returns path to workflow file(s)
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)
}

// Inputfile returns the path to the input file
func (i *Input) Inputfile() string {
	return i.resolve(i.inputfile)
}