Skip to content

Commit

Permalink
Merge branch 'hashicorp:main' into kiril/reload-debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
komapa authored Jun 21, 2023
2 parents 1d986be + 7fde202 commit fa09f10
Show file tree
Hide file tree
Showing 32 changed files with 420 additions and 337 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ jobs:
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Determine Go version
id: get-go-version
# looking for just the number, eg. 1.18.3
run: |
echo "Building with Go $(go env GOVERSION | tr -d 'go')"
echo "::set-output name=go-version::$(go env GOVERSION | tr -d 'go')"
echo "go-version=$(go env GOVERSION | tr -d 'go')" >> "$GITHUB_OUTPUT"
get-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: get product version
id: get-product-version
run: |
make version
echo "::set-output name=product-version::$(make version)"
echo "product-version=$(make version)" >> "$GITHUB_OUTPUT"
generate-metadata-file:
needs: get-product-version
Expand All @@ -51,15 +51,15 @@ jobs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- name: "Checkout directory"
uses: actions/checkout@v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@v1
with:
version: ${{ needs.get-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
repositoryOwner: "hashicorp"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}
Expand All @@ -86,10 +86,10 @@ jobs:
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}

Expand All @@ -103,7 +103,7 @@ jobs:
go build -o dist/ -ldflags "-s -w -X $(go list -m)/version.GitCommit=$(git rev-parse --short HEAD)" .
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
Expand All @@ -123,10 +123,10 @@ jobs:
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}

Expand All @@ -140,7 +140,7 @@ jobs:
go build -o dist/ -ldflags "-s -w -X $(go list -m)/version.GitCommit=$(git rev-parse --short HEAD)" .
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
Expand All @@ -166,13 +166,13 @@ jobs:
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ matrix.goos == 'linux' }}
with:
name: ${{ env.RPM_PACKAGE }}
path: out/${{ env.RPM_PACKAGE }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ matrix.goos == 'linux' }}
with:
name: ${{ env.DEB_PACKAGE }}
Expand All @@ -196,10 +196,10 @@ jobs:
GOARCH: ${{ matrix.goarch }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}

Expand All @@ -209,7 +209,7 @@ jobs:
go build -tags netcgo -o dist/
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
Expand All @@ -228,7 +228,7 @@ jobs:
version: ${{ needs.get-product-version.outputs.product-version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
go: [^1]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go }}

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v0.32.0 (May 18, 2023)

IMPROVEMENTS:
* Add support for Vault agent environment variables. [GH-1741](https://github.com/hashicorp/consul-template/pull/1741)
* Upgrade hashicorp/vault/api from 1.8.2 to 1.9.1. [GH-1743](https://github.com/hashicorp/consul-template/pull/1743)

REPO MAINTENANCE:
* remove repo-specific codeql action, in favor of centralized job. [GH-1740](https://github.com/hashicorp/consul-template/pull/1740/files)


## v0.31.0 (Apr 06, 2023)

IMPROVEMENTS:
Expand Down
3 changes: 2 additions & 1 deletion child/child.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ func New(i *NewInput) (*Child, error) {

// ExitCh returns the current exit channel for this child process. This channel
// may change if the process is restarted, so implementers must not cache this
// value.
// value. To prevent a potential race condition, this function must be invoked
// strictly after child.Start().
func (c *Child) ExitCh() <-chan int {
c.RLock()
defer c.RUnlock()
Expand Down
41 changes: 41 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,26 @@ func (cli *CLI) ParseFlags(args []string) (
return nil
}), "exec-splay", "")

flags.Var((funcBoolVar)(func(b bool) error {
c.Exec.Env.Pristine = config.Bool(b)
return nil
}), "exec-env-pristine", "")

flags.Var((funcVar)(func(s string) error {
c.Exec.Env.Custom = append(c.Exec.Env.Custom, s)
return nil
}), "exec-env-custom", "")

flags.Var((funcVar)(func(s string) error {
c.Exec.Env.Allowlist = append(c.Exec.Env.Allowlist, s)
return nil
}), "exec-env-allowlist", "")

flags.Var((funcVar)(func(s string) error {
c.Exec.Env.Denylist = append(c.Exec.Env.Denylist, s)
return nil
}), "exec-env-denylist", "")

flags.Var((funcVar)(func(s string) error {
sig, err := signals.Parse(s)
if err != nil {
Expand Down Expand Up @@ -773,6 +793,27 @@ Options:
-exec-splay=<duration>
Amount of time to wait before sending signals
-exec-env-pristine
Child process should not inherit the parent process's environment.
-exec-env-custom
Additional custom environment variables to inject into the child's
runtime. Even if pristine, allowlist, or denylist is specified, all
values in this option are given to the child process. Can be specified
multiple times.
-exec-env-allowlist
List of environment variables to exclusively include in the list of
environment variables exposed to the child process. Only those environment
variables matching the given patterns are exposed to the child process.
Wildcards are permitted. Can be specified multiple times.
-exec-env-denylist
List of environment variables to exclusively prohibit in the list of
environment variables exposed to the child process. The values in this
option take precedence over the values in the allowlist.
Wildcards are permitted. Can be specified multiple times.
-kill-signal=<signal>
Signal to listen to gracefully terminate the process
Expand Down
102 changes: 102 additions & 0 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,108 @@ func TestCLI_ParseFlags(t *testing.T) {
},
false,
},
{
"exec-env-pristine",
[]string{"-exec-env-pristine"},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Pristine: config.Bool(true),
},
},
},
false,
},
{
"exec-env-custom",
[]string{"-exec-env-custom", "SOME_ENV_VARIABLE=VALUE"},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Custom: []string{"SOME_ENV_VARIABLE=VALUE"},
},
},
},
false,
},
{
"exec-env-custom-multiple",
[]string{
"-exec-env-custom", "SOME_ENV_VARIABLE=VALUE",
"-exec-env-custom", "ANOTHER_ENV_VARIABLE=VALUE",
},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Custom: []string{
"SOME_ENV_VARIABLE=VALUE",
"ANOTHER_ENV_VARIABLE=VALUE",
},
},
},
},
false,
},
{
"exec-env-allowlist",
[]string{"-exec-env-allowlist", "SOME_*"},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Allowlist: []string{"SOME_*"},
},
},
},
false,
},
{
"exec-env-allowlist-multiple",
[]string{
"-exec-env-allowlist", "SOME_*",
"-exec-env-allowlist", "ANOTHER_*",
},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Allowlist: []string{
"SOME_*",
"ANOTHER_*",
},
},
},
},
false,
},
{
"exec-env-denylist",
[]string{"-exec-env-denylist", "VAULT_*"},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Denylist: []string{"VAULT_*"},
},
},
},
false,
},
{
"exec-env-denylist-multiple",
[]string{
"-exec-env-denylist", "VAULT_*",
"-exec-env-denylist", "CONSUL_*",
},
&config.Config{
Exec: &config.ExecConfig{
Env: &config.EnvConfig{
Denylist: []string{
"VAULT_*",
"CONSUL_*",
},
},
},
},
false,
},
{
"kill-signal",
[]string{"-kill-signal", "SIGUSR1"},
Expand Down
2 changes: 1 addition & 1 deletion config/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestFileModePresent(t *testing.T) {
},
{
"present",
FileMode(123),
FileMode(0644),
true,
},
{
Expand Down
Loading

0 comments on commit fa09f10

Please sign in to comment.