From fa297c78600dc045e84a16e5e90cd1337f44121e Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 21 Jun 2023 11:20:04 -0400 Subject: [PATCH] Add fix for determining mgmt API path. Fix CLI config dir setting. --- CHANGELOG.md | 5 +++-- ziti/cmd/helpers/env_helpers.go | 1 - ziti/util/dirs.go | 15 +-------------- ziti/util/rest.go | 10 ++++++++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9b6e0647..f25e2d0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## What's New -This is a bugfix release. +* IMPORTANT: If you update your OpenZiti binaries to this version or later (which can be done easily with the `getZiti()` function, you will need to migrate any existing network that has been developed using OpenZiti v0.27.5 or earlier binaries as the new binaries will expect the new environment variable names. A function `performMigration()` has been provided in the `ziti-cli-script.sh` for this purpose. Simply source the latest `ziti-cli-script.sh`, and your current network's .env file, then run `performMigration()` to update environment variable name references. If the migration process cannot find your existing environment file in the default location, you will need to provide the path to the migration function, ex: `performMigration ` +* If you were using the `ZITI_HOME` environment variable to configure where your ziti CLI profiles were stored, you should now use `ZITI_CONFIG_DIR` instead. + ## Component Updates and Bug Fixes @@ -31,7 +33,6 @@ This is a bugfix release. * [Issue #761](https://github.com/openziti/ziti/issues/761) - Remove Management Listener section from controller config. * [Issue #650](https://github.com/openziti/ziti/issues/650) - Removed/Updated references to `ZITI_EDGE_CONTROLLER_API` * Quickstart environment variable names have been cleaned up. - * IMPORTANT: If you update your OpenZiti binaries to this version or later (which can be done easily with the `getZiti()` function, you will need to migrate any existing network that has been developed using OpenZiti v0.27.5 or earlier binaries as the new binaries will expect the new environment variable names. A function `performMigration()` has been provided in the `ziti-cli-script.sh` for this purpose. Simply source the latest `ziti-cli-script.sh`, and your current network's .env file, then run `performMigration()` to update environment variable name references. If the migration process cannot find your existing environment file in the default location, you will need to provide the path to the migration function, ex: `performMigration ` * [Issue #1030](https://github.com/openziti/ziti/issues/1030) - Provide an upgrade path for quickstart cleanup # Release 0.28.1 diff --git a/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go index 448fabd3b..193d4ed39 100644 --- a/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -47,7 +47,6 @@ func WorkingDir() (string, error) { } func GetZitiHome() (string, error) { - // Get path from env variable retVal := os.Getenv(constants.ZitiHomeVarName) diff --git a/ziti/util/dirs.go b/ziti/util/dirs.go index 597ca5e3f..9c28744ce 100644 --- a/ziti/util/dirs.go +++ b/ziti/util/dirs.go @@ -37,7 +37,7 @@ func HomeDir() string { } func ConfigDir() (string, error) { - path := os.Getenv("ZITI_HOME") + path := os.Getenv("ZITI_CONFIG_DIR") if path != "" { return path, nil } @@ -55,19 +55,6 @@ func ConfigDir() (string, error) { return path, nil } -func FabricConfigDir() (string, error) { - h, err := ConfigDir() - if err != nil { - return "", err - } - path := filepath.Join(h, "fabric") - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - func ZitiAppConfigDir(zitiApp string) (string, error) { h, err := ConfigDir() if err != nil { diff --git a/ziti/util/rest.go b/ziti/util/rest.go index 9d2416f7b..61af030f8 100644 --- a/ziti/util/rest.go +++ b/ziti/util/rest.go @@ -862,10 +862,16 @@ func EdgeControllerGetManagementApiBasePath(host string, cert string) string { client.SetRootCertificate(cert) } - resp, err := client.R().Get("/version") + // check v1 path first + resp, err := client.R().Get("/edge/client/v1/version") if err != nil || resp.StatusCode() != http.StatusOK { - return host + // if v1 path fails, fall back to removed /version path + resp, err = client.R().Get("/version") + + if err != nil || resp.StatusCode() != http.StatusOK { + return host + } } data, err := gabs.ParseJSON(resp.Body())