Skip to content

Commit

Permalink
feat(config): add file path option for reading values (#42)
Browse files Browse the repository at this point in the history
* feat(config): add file path option for reading values

* fix: update params pathing

* fix: add plugin name to params path
  • Loading branch information
Neal authored Jul 31, 2020
1 parent 264c66c commit 9d4414c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
2 changes: 2 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Registry: https://hub.docker.com/r/target/vela-git

## Usage

_The plugin supports reading all parameters via environment variables or files. Values set as a file take precedence over default values set from the environment._

**NOTE: This plugin is automatically injected into your pipeline for the source repository.**

Sample of cloning a repository:
Expand Down
76 changes: 43 additions & 33 deletions cmd/vela-git/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,66 +40,76 @@ func main() {
app.Flags = []cli.Flag{

&cli.StringFlag{
EnvVars: []string{"PARAMETER_LOG_LEVEL", "VELA_LOG_LEVEL", "GIT_LOG_LEVEL"},
Name: "log.level",
Usage: "set log level - options: (trace|debug|info|warn|error|fatal|panic)",
Value: "info",
EnvVars: []string{"PARAMETER_LOG_LEVEL", "VELA_LOG_LEVEL", "GIT_LOG_LEVEL"},
FilePath: string("/vela/parameters/git/log_level,/vela/secrets/git/log_level"),
Name: "log.level",
Usage: "set log level - options: (trace|debug|info|warn|error|fatal|panic)",
Value: "info",
},

// Build Flags

&cli.StringFlag{
EnvVars: []string{"PARAMETER_SHA", "BUILD_COMMIT"},
Name: "build.sha",
Usage: "git commit sha",
EnvVars: []string{"PARAMETER_SHA", "BUILD_COMMIT"},
FilePath: string("/vela/parameters/git/build/sha,/vela/secrets/git/build/sha"),
Name: "build.sha",
Usage: "git commit sha",
},
&cli.StringFlag{
EnvVars: []string{"PARAMETER_PATH", "BUILD_WORKSPACE"},
Name: "build.path",
Usage: "git clone path",
EnvVars: []string{"PARAMETER_PATH", "BUILD_WORKSPACE"},
FilePath: string("/vela/parameters/git/build/path,/vela/secrets/git/build/path"),
Name: "build.path",
Usage: "git clone path",
},
&cli.StringFlag{
EnvVars: []string{"PARAMETER_REF", "BUILD_REF"},
Name: "build.ref",
Usage: "git commit ref",
Value: "refs/heads/master",
EnvVars: []string{"PARAMETER_REF", "BUILD_REF"},
FilePath: string("/vela/parameters/git/build/ref,/vela/secrets/git/build/ref"),
Name: "build.ref",
Usage: "git commit ref",
Value: "refs/heads/master",
},

// Netrc Flags

&cli.StringFlag{
EnvVars: []string{"PARAMETER_NETRC_MACHINE", "VELA_NETRC_MACHINE"},
Name: "netrc.machine",
Usage: "remote machine name to communicate with",
Value: "github.com",
EnvVars: []string{"PARAMETER_NETRC_MACHINE", "VELA_NETRC_MACHINE"},
FilePath: string("/vela/parameters/git/netrc/machine,/vela/secrets/git/netrc/machine"),
Name: "netrc.machine",
Usage: "remote machine name to communicate with",
Value: "github.com",
},
&cli.StringFlag{
EnvVars: []string{"PARAMETER_NETRC_USERNAME", "VELA_NETRC_USERNAME", "GIT_USERNAME"},
Name: "netrc.username",
Usage: "user name for communication with the remote machine",
EnvVars: []string{"PARAMETER_NETRC_USERNAME", "VELA_NETRC_USERNAME", "GIT_USERNAME"},
FilePath: string("/vela/parameters/git/netrc/username,/vela/secrets/git/netrc/username"),
Name: "netrc.username",
Usage: "user name for communication with the remote machine",
},
&cli.StringFlag{
EnvVars: []string{"PARAMETER_NETRC_PASSWORD", "VELA_NETRC_PASSWORD", "GIT_PASSWORD"},
Name: "netrc.password",
Usage: "password for communication with the remote machine",
EnvVars: []string{"PARAMETER_NETRC_PASSWORD", "VELA_NETRC_PASSWORD", "GIT_PASSWORD"},
FilePath: string("/vela/parameters/git/netrc/password,/vela/secrets/git/netrc/password"),
Name: "netrc.password",
Usage: "password for communication with the remote machine",
},

// Repo Flags

&cli.StringFlag{
EnvVars: []string{"PARAMETER_REMOTE", "REPOSITORY_CLONE"},
Name: "repo.remote",
Usage: "git remote url",
EnvVars: []string{"PARAMETER_REMOTE", "REPOSITORY_CLONE"},
FilePath: string("/vela/parameters/git/repo/remote,/vela/secrets/git/repo/remote"),
Name: "repo.remote",
Usage: "git remote url",
},
&cli.BoolFlag{
EnvVars: []string{"PARAMETER_SUBMODULES"},
Name: "repo.submodules",
Usage: "git update submodules",
EnvVars: []string{"PARAMETER_SUBMODULES"},
FilePath: string("/vela/parameters/git/repo/submodules,/vela/secrets/git/repo/submodules"),
Name: "repo.submodules",
Usage: "git update submodules",
},
&cli.BoolFlag{
EnvVars: []string{"PARAMETER_TAGS"},
Name: "repo.tags",
Usage: "git fetch tags",
EnvVars: []string{"PARAMETER_TAGS"},
FilePath: string("/vela/parameters/git/repo/tags,/vela/secrets/git/repo/tags"),
Name: "repo.tags",
Usage: "git fetch tags",
},
}

Expand Down

0 comments on commit 9d4414c

Please sign in to comment.