diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fb26795e..edc6a2ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,7 +30,6 @@ jobs: - name: "Run GoReleaser" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HOMEBREW_FUNC-E_GITHUB_TOKEN: ${{ secrets.FUNC-E_CI_GITHUB_TOKEN }} run: make release e2e: @@ -58,4 +57,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Run e2e tests using released `func-e` binary" - run: E2E_FUNC-E_BINARY=$PWD/func-e make e2e + run: E2E_FUNC_E_BINARY=$PWD/func-e make e2e diff --git a/Makefile b/Makefile index 7fd8a00c..fbdeb40a 100644 --- a/Makefile +++ b/Makefile @@ -42,13 +42,13 @@ test: # End-to-end (e2e) tests run against a compiled binary. # -# When E2E_FUNC-E_BINARY isn't set, the func-e binary is built on-demand. +# When E2E_FUNC_E_BINARY isn't set, the func-e binary is built on-demand. # # Tests run one at a time, in verbose mode, so that failures are easy to diagnose. # Note: -failfast helps as it stops at the first error. However, it is not a cacheable flag, so runs won't cache. -E2E_FUNC-E_BINARY ?= $(BIN) +E2E_FUNC_E_BINARY ?= $(BIN) .PHONY: e2e -e2e: $(E2E_FUNC-E_BINARY) +e2e: $(E2E_FUNC_E_BINARY) @echo "--- e2e ---" @go test -parallel 1 -v -failfast ./e2e diff --git a/e2e/README.md b/e2e/README.md index 8ff0098d..07de25d1 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -9,7 +9,7 @@ Ex run this from the project root: make e2e ``` -You can override the binary tested by setting `E2E_FUNC-E_BINARY` to an alternative location, for example a release. +You can override the binary tested by setting `E2E_FUNC_E_BINARY` to an alternative location, for example a release. If the `func-e` version is a snapshot and "envoy-versions.json" exists, tests run against the local. This allows local development and pull requests to verify changes not yet [published](https://archive.tetratelabs.io/envoy/envoy-versions.json) diff --git a/e2e/main_test.go b/e2e/main_test.go index 7709d806..9ed8e228 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -34,7 +34,7 @@ import ( //nolint:golint const ( - funcEBinaryEnvKey = "E2E_FUNC-E_BINARY" + funcEBinaryEnvKey = "E2E_FUNC_E_BINARY" envoyVersionsURLEnvKey = "ENVOY_VERSIONS_URL" envoyVersionsJSON = "envoy-versions.json" runTimeout = 2 * time.Minute @@ -107,7 +107,7 @@ func mockEnvoyVersionsServer() (*httptest.Server, error) { return ts, nil } -// readFuncEPath reads E2E_FUNC-E_BINARY or defaults to "$PWD/dist/func-e_$GOOS_$GOARCH/func-e" +// readFuncEPath reads E2E_FUNC_E_BINARY or defaults to "$PWD/dist/func-e_$GOOS_$GOARCH/func-e" // An error is returned if the value isn't an executable file. func readFuncEPath() (string, error) { path := os.Getenv(funcEBinaryEnvKey) diff --git a/internal/cmd/app.go b/internal/cmd/app.go index e3541885..90ef7b3b 100644 --- a/internal/cmd/app.go +++ b/internal/cmd/app.go @@ -42,7 +42,7 @@ func NewApp(o *globals.GlobalOpts) *cli.App { To list versions of Envoy you can use, execute ` + "`func-e versions -a`" + `. To choose one, invoke ` + fmt.Sprintf("`func-e use %s`", version.LastKnownEnvoy) + `. This installs into - ` + fmt.Sprintf("`$FUNC-E_HOME/versions/%s`", version.LastKnownEnvoy) + `, if not already present. + ` + fmt.Sprintf("`$FUNC_E_HOME/versions/%s`", version.LastKnownEnvoy) + `, if not already present. You may want to override ` + "`$ENVOY_VERSIONS_URL`" + ` to supply custom builds or otherwise control the source of Envoy binaries. When overriding, validate @@ -54,7 +54,7 @@ func NewApp(o *globals.GlobalOpts) *cli.App { Usage: "func-e home directory (location of installed versions and run archives)", DefaultText: globals.DefaultHomeDir, Destination: &homeDir, - EnvVars: []string{"FUNC-E_HOME"}, + EnvVars: []string{"FUNC_E_HOME"}, }, &cli.StringFlag{ Name: "envoy-versions-url", @@ -117,7 +117,7 @@ func setHomeDir(o *globals.GlobalOpts, homeDir string) error { if homeDir == "" { u, err := user.Current() if err != nil || u.HomeDir == "" { - return NewValidationError("unable to determine home directory. Set FUNC-E_HOME instead: %v", err) + return NewValidationError("unable to determine home directory. Set FUNC_E_HOME instead: %v", err) } o.HomeDir = filepath.Join(u.HomeDir, ".func-e") } else { diff --git a/internal/cmd/app_test.go b/internal/cmd/app_test.go index 84169661..5ed596e1 100644 --- a/internal/cmd/app_test.go +++ b/internal/cmd/app_test.go @@ -74,12 +74,12 @@ func TestHomeDir(t *testing.T) { expected: filepath.Join(u.HomeDir, ".func-e"), }, { - name: "FUNC-E_HOME env", + name: "FUNC_E_HOME env", args: []string{"func-e"}, setup: func() func() { - return morerequire.RequireSetenv(t, "FUNC-E_HOME", "/from/FUNC-E_HOME/env") + return morerequire.RequireSetenv(t, "FUNC_E_HOME", "/from/FUNC_E_HOME/env") }, - expected: "/from/FUNC-E_HOME/env", + expected: "/from/FUNC_E_HOME/env", }, { name: "--home-dir arg", @@ -87,10 +87,10 @@ func TestHomeDir(t *testing.T) { expected: "/from/home-dir/arg", }, { - name: "prioritizes --home-dir arg over FUNC-E_HOME env", + name: "prioritizes --home-dir arg over FUNC_E_HOME env", args: []string{"func-e", "--home-dir", "/from/home-dir/arg"}, setup: func() func() { - return morerequire.RequireSetenv(t, "FUNC-E_HOME", "/from/FUNC-E_HOME/env") + return morerequire.RequireSetenv(t, "FUNC_E_HOME", "/from/FUNC_E_HOME/env") }, expected: "/from/home-dir/arg", }, diff --git a/internal/cmd/run.go b/internal/cmd/run.go index 183c577f..1ea762a2 100644 --- a/internal/cmd/run.go +++ b/internal/cmd/run.go @@ -49,9 +49,9 @@ Envoy interprets the '[arguments...]' and runs in the current working directory (aka $CWD) until func-e is interrupted (ex Ctrl+C, Ctrl+Break). Envoy's process ID and console output write to "envoy.pid", stdout.log" and -"stderr.log" in the run directory (` + "`$FUNC-E_HOME/runs/$epochtime`" + `). +"stderr.log" in the run directory (` + "`$FUNC_E_HOME/runs/$epochtime`" + `). When interrupted, shutdown hooks write files including network and process -state. On exit, these archive into ` + "`$FUNC-E_HOME/runs/$epochtime.tar.gz`", +state. On exit, these archive into ` + "`$FUNC_E_HOME/runs/$epochtime.tar.gz`", Before: func(c *cli.Context) error { if err := os.MkdirAll(o.HomeDir, 0750); err != nil { return NewValidationError(err.Error()) @@ -133,7 +133,7 @@ func initializeRunOpts(ctx context.Context, o *globals.GlobalOpts, p version.Pla return nil } -// setHomeEnvoyVersion makes sure the $FUNC-E_HOME/version exists. +// setHomeEnvoyVersion makes sure the $FUNC_E_HOME/version exists. func setHomeEnvoyVersion(ctx context.Context, o *globals.GlobalOpts) error { v, homeVersionFile, err := envoy.GetHomeVersion(o.HomeDir) if err != nil { diff --git a/internal/cmd/run_test.go b/internal/cmd/run_test.go index d2d3a86d..3cfe1ae4 100644 --- a/internal/cmd/run_test.go +++ b/internal/cmd/run_test.go @@ -136,7 +136,7 @@ func TestFuncERun_ValidatesHomeVersion(t *testing.T) { err := c.Run([]string{"func-e", "run"}) // Verify the command failed with the expected error - require.EqualError(t, err, fmt.Sprintf(`invalid version in "$FUNC-E_HOME/version": "a.a.a" should look like "%s"`, version.LastKnownEnvoy)) + require.EqualError(t, err, fmt.Sprintf(`invalid version in "$FUNC_E_HOME/version": "a.a.a" should look like "%s"`, version.LastKnownEnvoy)) } // TestFuncERun_ValidatesWorkingVersion duplicates logic in version_test.go to ensure a non-home version validates. diff --git a/internal/cmd/testdata/func-e_help.txt b/internal/cmd/testdata/func-e_help.txt index 8f844a4f..38344e0b 100644 --- a/internal/cmd/testdata/func-e_help.txt +++ b/internal/cmd/testdata/func-e_help.txt @@ -7,7 +7,7 @@ USAGE: To list versions of Envoy you can use, execute `func-e versions -a`. To choose one, invoke `func-e use {ENVOY_VERSION}`. This installs into - `$FUNC-E_HOME/versions/{ENVOY_VERSION}`, if not already present. + `$FUNC_E_HOME/versions/{ENVOY_VERSION}`, if not already present. You may want to override `$ENVOY_VERSIONS_URL` to supply custom builds or otherwise control the source of Envoy binaries. When overriding, validate @@ -23,6 +23,6 @@ COMMANDS: use Sets the current [version] used by the "run" command GLOBAL OPTIONS: - --home-dir value func-e home directory (location of installed versions and run archives) (default: ${HOME}/.func-e) [$FUNC-E_HOME] + --home-dir value func-e home directory (location of installed versions and run archives) (default: ${HOME}/.func-e) [$FUNC_E_HOME] --envoy-versions-url value URL of Envoy versions JSON (default: https://archive.tetratelabs.io/envoy/envoy-versions.json) [$ENVOY_VERSIONS_URL] --version, -v print the version (default: false) diff --git a/internal/cmd/testdata/func-e_run_help.txt b/internal/cmd/testdata/func-e_run_help.txt index 8700bbec..06d6d7b7 100644 --- a/internal/cmd/testdata/func-e_run_help.txt +++ b/internal/cmd/testdata/func-e_run_help.txt @@ -9,7 +9,7 @@ DESCRIPTION: The first version in the below is run, controllable by the "use" command: ``` - $ENVOY_VERSION, $PWD/.envoy-version, $FUNC-E_HOME/version + $ENVOY_VERSION, $PWD/.envoy-version, $FUNC_E_HOME/version ``` The version to use is downloaded and installed, if necessary. @@ -17,6 +17,6 @@ DESCRIPTION: directory (aka $CWD) until func-e is interrupted (ex Ctrl+C, Ctrl+Break). Envoy's process ID and console output write to "envoy.pid", stdout.log" and - "stderr.log" in the run directory (`$FUNC-E_HOME/runs/$epochtime`). + "stderr.log" in the run directory (`$FUNC_E_HOME/runs/$epochtime`). When interrupted, shutdown hooks write files including network and process - state. On exit, these archive into `$FUNC-E_HOME/runs/$epochtime.tar.gz` + state. On exit, these archive into `$FUNC_E_HOME/runs/$epochtime.tar.gz` diff --git a/internal/cmd/testdata/func-e_use_help.txt b/internal/cmd/testdata/func-e_use_help.txt index 6caab0a8..afd51b3b 100644 --- a/internal/cmd/testdata/func-e_use_help.txt +++ b/internal/cmd/testdata/func-e_use_help.txt @@ -6,10 +6,10 @@ USAGE: DESCRIPTION: The '[version]' is from the "versions -a" command. - The Envoy [version] installs on-demand into $FUNC-E_HOME/versions/[version] + The Envoy [version] installs on-demand into $FUNC_E_HOME/versions/[version] if needed. - This updates $PWD/.envoy-version or $FUNC-E_HOME/version with [version], + This updates $PWD/.envoy-version or $FUNC_E_HOME/version with [version], depending on which is present. Example: diff --git a/internal/cmd/use.go b/internal/cmd/use.go index 624d4f5e..ff8dfe08 100644 --- a/internal/cmd/use.go +++ b/internal/cmd/use.go @@ -31,7 +31,7 @@ func NewUseCmd(o *globals.GlobalOpts) *cli.Command { Usage: `Sets the current [version] used by the "run" command`, ArgsUsage: "[version]", Description: fmt.Sprintf(`The '[version]' is from the "versions -a" command. -The Envoy [version] installs on-demand into $FUNC-E_HOME/versions/[version] +The Envoy [version] installs on-demand into $FUNC_E_HOME/versions/[version] if needed. This updates %s or %s with [version], diff --git a/internal/cmd/versions_cmd_test.go b/internal/cmd/versions_cmd_test.go index c6f19f95..10059579 100644 --- a/internal/cmd/versions_cmd_test.go +++ b/internal/cmd/versions_cmd_test.go @@ -72,13 +72,13 @@ func TestFuncEVersions_CurrentVersion(t *testing.T) { `, stdout.String()) }) - t.Run("set by $FUNC-E_HOME/version", func(t *testing.T) { + t.Run("set by $FUNC_E_HOME/version", func(t *testing.T) { require.NoError(t, os.WriteFile(filepath.Join(o.HomeDir, "version"), []byte("1.1.2"), 0600)) c, stdout, _ := newApp(o) require.NoError(t, c.Run([]string{"func-e", "versions"})) require.Equal(t, ` 1.2.2 2021-01-31 -* 1.1.2 2021-01-31 (set by $FUNC-E_HOME/version) +* 1.1.2 2021-01-31 (set by $FUNC_E_HOME/version) 1.2.1 2021-01-30 `, stdout.String()) }) @@ -119,7 +119,7 @@ func TestFuncEVersions_Sorted(t *testing.T) { require.NoError(t, err) require.Equal(t, ` 1.2.2 2021-01-31 1.1.2 2021-01-31 -* 1.2.1 2021-01-30 (set by $FUNC-E_HOME/version) +* 1.2.1 2021-01-30 (set by $FUNC_E_HOME/version) `, stdout.String()) require.Empty(t, stderr) } @@ -145,7 +145,7 @@ func TestFuncEVersions_All_RemoteIsCurrent(t *testing.T) { morerequire.RequireSetMtime(t, versionDir, "2020-12-31") require.NoError(t, os.WriteFile(filepath.Join(o.HomeDir, "version"), []byte(version.LastKnownEnvoy), 0600)) - expected := fmt.Sprintf("* %s 2020-12-31 (set by $FUNC-E_HOME/version)\n", version.LastKnownEnvoy) + expected := fmt.Sprintf("* %s 2020-12-31 (set by $FUNC_E_HOME/version)\n", version.LastKnownEnvoy) c, stdout, stderr := newApp(o) err := c.Run([]string{"func-e", "versions", "-a"}) @@ -165,7 +165,7 @@ func TestFuncEVersions_All_Mixed(t *testing.T) { require.NoError(t, err) require.Equal(t, fmt.Sprintf(` 1.2.2 2021-01-31 1.1.2 2021-01-31 -* 1.2.1 2021-01-30 (set by $FUNC-E_HOME/version) +* 1.2.1 2021-01-30 (set by $FUNC_E_HOME/version) %s 2020-12-31 `, version.LastKnownEnvoy), stdout.String()) require.Empty(t, stderr) diff --git a/internal/envoy/version.go b/internal/envoy/version.go index f61839a3..166066c4 100644 --- a/internal/envoy/version.go +++ b/internal/envoy/version.go @@ -29,7 +29,7 @@ var ( // CurrentVersionWorkingDirFile is used for stable "versions" and "help" output CurrentVersionWorkingDirFile = filepath.Join("$PWD", ".envoy-version") // CurrentVersionHomeDirFile is used for stable "versions" and "help" output - CurrentVersionHomeDirFile = filepath.Join("$FUNC-E_HOME", "version") + CurrentVersionHomeDirFile = filepath.Join("$FUNC_E_HOME", "version") ) // GetHomeVersion returns the default version in the "homeDir" and path to to it (homeVersionFile). When "v" is empty, @@ -90,7 +90,7 @@ func getCurrentVersion(homeDir string) (v version.Version, source string, err er return "", CurrentVersionWorkingDirFile, err } - // Priority 3: $FUNC-E_HOME/version + // Priority 3: $FUNC_E_HOME/version source = CurrentVersionHomeDirFile v, _, err = getHomeVersion(homeDir) return diff --git a/internal/envoy/version_test.go b/internal/envoy/version_test.go index ce170870..40f6a87b 100644 --- a/internal/envoy/version_test.go +++ b/internal/envoy/version_test.go @@ -27,7 +27,7 @@ import ( ) func TestVersionUsageList(t *testing.T) { - require.Equal(t, "$ENVOY_VERSION, $PWD/.envoy-version, $FUNC-E_HOME/version", VersionUsageList()) + require.Equal(t, "$ENVOY_VERSION, $PWD/.envoy-version, $FUNC_E_HOME/version", VersionUsageList()) } func TestGetHomeVersion_Empty(t *testing.T) { @@ -172,7 +172,7 @@ func TestCurrentVersion_Validates(t *testing.T) { t.Run("validates home version", func(t *testing.T) { _, _, err := CurrentVersion(homeDir) - require.EqualError(t, err, fmt.Sprintf(`invalid version in "$FUNC-E_HOME/version": "a.a.a" should look like "%s"`, version.LastKnownEnvoy)) + require.EqualError(t, err, fmt.Sprintf(`invalid version in "$FUNC_E_HOME/version": "a.a.a" should look like "%s"`, version.LastKnownEnvoy)) }) revertTempWd := morerequire.RequireChdirIntoTemp(t) diff --git a/internal/globals/globals.go b/internal/globals/globals.go index 6241bc20..1efaa36a 100644 --- a/internal/globals/globals.go +++ b/internal/globals/globals.go @@ -41,7 +41,7 @@ type RunOpts struct { // Fields representing non-hidden flags have values set according to the following rules: // 1) value that precedes flag parsing, used in tests // 2) to a value of the command line argument, e.g. `--home-dir` -// 3) optional mapping to an environment variable, e.g. `FUNC-E_HOME` (not all flags are mapped to ENV) +// 3) optional mapping to an environment variable, e.g. `FUNC_E_HOME` (not all flags are mapped to ENV) // 4) otherwise, to the default value, e.g. DefaultHomeDir type GlobalOpts struct { // RunOpts are inlined to allow tests to override parameters without changing ENV variables or flags diff --git a/site/usage.md b/site/usage.md index e9a03810..c0c5530a 100644 --- a/site/usage.md +++ b/site/usage.md @@ -4,7 +4,7 @@ downloads and installs the latest version of Envoy for you. To list versions of Envoy you can use, execute `func-e versions -a`. To choose one, invoke `func-e use 1.18.3`. This installs into -`$FUNC-E_HOME/versions/1.18.3`, if not already present. +`$FUNC_E_HOME/versions/1.18.3`, if not already present. You may want to override `$ENVOY_VERSIONS_URL` to supply custom builds or otherwise control the source of Envoy binaries. When overriding, validate @@ -24,5 +24,5 @@ your JSON first: https://archive.tetratelabs.io/release-versions-schema.json | Name | Usage | Default | | ---- | ----- | ------- | -| FUNC-E_HOME | func-e home directory (location of installed versions and run archives) | ${HOME}/.func-e | +| FUNC_E_HOME | func-e home directory (location of installed versions and run archives) | ${HOME}/.func-e | | ENVOY_VERSIONS_URL | URL of Envoy versions JSON | https://archive.tetratelabs.io/envoy/envoy-versions.json |