Repository: tetratelabs/getenvoy
Pull request #244 (2021-05-27 00:39:20)

Changes envoy versions json from snake_case to kebab-case
see #106

codefromthecrypt: will follow-up immediately on getenvoy.io repo. I can't raise before here as netlify redirect checker would break

Patch:
diff --git a/internal/globals/globals.go b/internal/globals/globals.go
index 34cfc63..02a8be4 100644
--- a/internal/globals/globals.go
+++ b/internal/globals/globals.go
@@ -38,7 +38,7 @@ type RunOpts struct {
 type GlobalOpts struct {
 	// RunOpts are inlined to allow tests to override parameters without changing ENV variables or flags
 	RunOpts
-	// EnvoyVersionsURL is the path to the envoy_versions.json. Defaults to DefaultEnvoyVersionsURL
+	// EnvoyVersionsURL is the path to the envoy-versions.json. Defaults to DefaultEnvoyVersionsURL
 	EnvoyVersionsURL string
 	// HomeDir most importantly contains Envoy versions installed from EnvoyVersionsURL. Defaults to DefaultHomeDir
 	HomeDir string
@@ -50,5 +50,5 @@ const (
 	// DefaultHomeDir is the default value for GlobalOpts.HomeDir
 	DefaultHomeDir = "${HOME}/.getenvoy"
 	// DefaultEnvoyVersionsURL is the default value for GlobalOpts.EnvoyVersionsURL
-	DefaultEnvoyVersionsURL = "https://getenvoy.io/envoy_versions.json"
+	DefaultEnvoyVersionsURL = "https://getenvoy.io/envoy-versions.json"
 )
diff --git a/internal/tar/tar.go b/internal/tar/tar.go
index 6af9584..dcd4ab2 100644
--- a/internal/tar/tar.go
+++ b/internal/tar/tar.go
@@ -31,7 +31,7 @@ import (
 // Untar unarchives the compressed "src" which is either a "tar.xz" or "tar.gz" stream.
 // This strips the base directory inside the "src" archive. Ex on "/foo/bar", "dst" will have "bar/**"
 //
-// This is used to decompress Envoy distributions in the "tarballURL" field of "envoy_versions.json".
+// This is used to decompress Envoy distributions in the "tarballURL" field of "envoy-versions.json".
 // To keep the binary size small, only supports compression formats used in practice. As of May 2021, all
 // "tarballURL" from stable releases were "tar.xz".
 func Untar(dst string, src io.Reader) error { // dst, src order like io.Copy
diff --git a/internal/version/version.go b/internal/version/version.go
index 7867b0e..8b38a49 100644
--- a/internal/version/version.go
+++ b/internal/version/version.go
@@ -21,7 +21,7 @@ import _ "embed" // We embed the Envoy version so that we can cache it in CI
 var GetEnvoy = "dev"
 
 // LastKnownEnvoy is the last known Envoy version, used to ensure help statements aren't out-of-date.
-// This is derived from /site/envoy_versions.json, but not used directly because go:embed requires a file read from the
+// This is derived from /site/envoy-versions.json, but not used directly because go:embed requires a file read from the
 // current directory tree.
 //
 // This is different than the "latestVersion" because this is built into the binary. For example, after the binary is
diff --git a/site/README.md b/site/README.md
index bd59427..e8fd7af 100644
--- a/site/README.md
+++ b/site/README.md
@@ -4,5 +4,5 @@ The following files are hosted on https://getenvoy.io, specifically via [Netlify
 
 Latest master merge:
 * https://getenvoy.io/install.sh -> [./install.sh](install.sh)
-* https://getenvoy.io/envoy_versions.json -> [./envoy_versions.json](envoy_versions.json)
-* https://getenvoy.io/envoy_versions-schema.json -> [./envoy_versions-schema.json](envoy_versions-schema.json)
+* https://getenvoy.io/envoy-versions.json -> [./envoy-versions.json](envoy-versions.json)
+* https://getenvoy.io/envoy-versions-schema.json -> [./envoy-versions-schema.json](envoy-versions-schema.json)


Test patch:
diff --git a/e2e/README.md b/e2e/README.md
index 68f06eb..8513496 100644
--- a/e2e/README.md
+++ b/e2e/README.md
@@ -12,7 +12,7 @@ make e2e
 You can override the binary tested by setting `E2E_GETENVOY_BINARY` to an alternative location, for example a release.
 
 If the `getenvoy` version is a snapshot and the `ENVOY_VERSIONS_URL` environment variable is unset, tests run against
-the local [envoy_versions.json](../site/envoy_versions.json). This allows local development and pull requests to verify
+the local [envoy-versions.json](../site/envoy-versions.json). This allows local development and pull requests to verify
 changes prior to deployment to getenvoy.io.
 
 ## Version of Envoy under test
diff --git a/e2e/main_test.go b/e2e/main_test.go
index bc7a80d..3a5a8b5 100644
--- a/e2e/main_test.go
+++ b/e2e/main_test.go
@@ -30,7 +30,7 @@ import (
 const (
 	getenvoyBinaryEnvKey   = "E2E_GETENVOY_BINARY"
 	envoyVersionsURLEnvKey = "ENVOY_VERSIONS_URL"
-	envoyVersionsJSON      = "../site/envoy_versions.json"
+	envoyVersionsJSON      = "../site/envoy-versions.json"
 )
 
 // TestMain ensures the "getenvoy" binary is valid.
diff --git a/internal/cmd/app_test.go b/internal/cmd/app_test.go
index d557c8f..0e9a797 100644
--- a/internal/cmd/app_test.go
+++ b/internal/cmd/app_test.go
@@ -125,9 +125,9 @@ func TestEnvoyVersionsURL(t *testing.T) {
 
 	tests := []testCase{ // we don't test default as that depends on the runtime env
 		{
-			name:     "default is https://getenvoy.io/envoy_versions.json",
+			name:     "default is https://getenvoy.io/envoy-versions.json",
 			args:     []string{"getenvoy"},
-			expected: "https://getenvoy.io/envoy_versions.json",
+			expected: "https://getenvoy.io/envoy-versions.json",
 		},
 		{
 			name: "ENVOY_VERSIONS_URL env",
@@ -221,7 +221,7 @@ func setupTest(t *testing.T) (*globals.GlobalOpts, func()) {
 	require.NoError(t, err, `error creating directory: %s`, result.HomeDir)
 
 	versionsServer := test.RequireEnvoyVersionsTestServer(t, version.LastKnownEnvoy)
-	result.EnvoyVersionsURL = versionsServer.URL + "/envoy_versions.json"
+	result.EnvoyVersionsURL = versionsServer.URL + "/envoy-versions.json"
 	tearDown = append(tearDown, versionsServer.Close)
 
 	return &result, func() {
diff --git a/internal/cmd/testdata/getenvoy_help.txt b/internal/cmd/testdata/getenvoy_help.txt
index 744f04f..45a50ab 100644
--- a/internal/cmd/testdata/getenvoy_help.txt
+++ b/internal/cmd/testdata/getenvoy_help.txt
@@ -14,6 +14,6 @@ COMMANDS:
 
 GLOBAL OPTIONS:
    --home-dir value            GetEnvoy home directory (location of downloaded versions and run archives) (default: ${HOME}/.getenvoy) [$GETENVOY_HOME]
-   --envoy-versions-url value  URL of Envoy versions JSON (default: https://getenvoy.io/envoy_versions.json) [$ENVOY_VERSIONS_URL]
+   --envoy-versions-url value  URL of Envoy versions JSON (default: https://getenvoy.io/envoy-versions.json) [$ENVOY_VERSIONS_URL]
    --help, -h                  show help (default: false)
    --version, -v               print the version (default: false)
diff --git a/internal/envoy/install_test.go b/internal/envoy/install_test.go
index 43e73ac..0272189 100644
--- a/internal/envoy/install_test.go
+++ b/internal/envoy/install_test.go
@@ -245,7 +245,7 @@ func setupInstallTest(t *testing.T) (*installTest, func()) {
 			tarballURL: test.TarballURL(versionsServer.URL, runtime.GOOS, runtime.GOARCH, version.LastKnownEnvoy),
 			GlobalOpts: globals.GlobalOpts{
 				HomeDir:          tempDir,
-				EnvoyVersionsURL: versionsServer.URL + "/envoy_versions.json",
+				EnvoyVersionsURL: versionsServer.URL + "/envoy-versions.json",
 				Out:              new(bytes.Buffer),
 				RunOpts: globals.RunOpts{
 					EnvoyPath: filepath.Join(tempDir, "versions", version.LastKnownEnvoy, "bin", "envoy"),
diff --git a/internal/test/server.go b/internal/test/server.go
index fcf61ab..6e7d4d8 100644
--- a/internal/test/server.go
+++ b/internal/test/server.go
@@ -38,7 +38,7 @@ import (
 const archiveFormat = ".tar.gz"
 const versionsPath = "/versions/"
 
-// RequireEnvoyVersionsTestServer serves "/envoy_versions.json", containing download links a fake Envoy archive.
+// RequireEnvoyVersionsTestServer serves "/envoy-versions.json", containing download links a fake Envoy archive.
 func RequireEnvoyVersionsTestServer(t *testing.T, v string) *httptest.Server {
 	s := &server{t: t}
 	h := httptest.NewServer(s)
@@ -70,7 +70,7 @@ type server struct {
 
 func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	switch {
-	case r.RequestURI == "/envoy_versions.json":
+	case r.RequestURI == "/envoy-versions.json":
 		w.WriteHeader(http.StatusOK)
 		_, err := w.Write(s.getEnvoyVersions())
 		require.NoError(s.t, err)
diff --git a/site/envoy_versions-schema.json b/site/envoy-versions-schema.json
similarity index 100%
rename from site/envoy_versions-schema.json
rename to site/envoy-versions-schema.json
diff --git a/site/envoy_versions.json b/site/envoy-versions.json
similarity index 100%
rename from site/envoy_versions.json
rename to site/envoy-versions.json
diff --git a/site/envoy_versions_test.go b/site/envoy-versions_test.go
similarity index 98%
rename from site/envoy_versions_test.go
rename to site/envoy-versions_test.go
index d4e44dc..12b138d 100644
--- a/site/envoy_versions_test.go
+++ b/site/envoy-versions_test.go
@@ -28,7 +28,7 @@ import (
 	"github.com/tetratelabs/getenvoy/internal/version"
 )
 
-const envoyVersionsPath = "./envoy_versions.json"
+const envoyVersionsPath = "./envoy-versions.json"
 
 // GitHubRelease includes a subset of fields we use from https://docs.github.com/en/rest/reference/repos#releases
 type gitHubRelease struct {