From 7327698305cecd5df2b37e8c007cd81e97a8d938 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Fri, 3 Mar 2023 22:36:51 +0100 Subject: [PATCH 1/4] fix: dont use ioutils and handle error --- cli/packages/util/check-for-update.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 220b098e9..28a1890c8 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "os" "os/exec" @@ -55,7 +55,7 @@ func getLatestTag(repoOwner string, repoName string) (string, error) { defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return "", err } @@ -64,7 +64,9 @@ func getLatestTag(repoOwner string, repoName string) (string, error) { Name string `json:"name"` } - json.Unmarshal(body, &tags) + if err := json.Unmarshal(body, &tags); err != nil { + return "", fmt.Errorf("failed to unmarshal github response: %w", err) + } return tags[0].Name[1:], nil } From 933f837f6488813e8c3fcac3725c340b226d88c4 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Fri, 3 Mar 2023 23:52:01 +0100 Subject: [PATCH 2/4] feat: option to disable update check --- cli/packages/util/check-for-update.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 28a1890c8..87832a9ce 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -14,6 +14,9 @@ import ( ) func CheckForUpdate() { + if checkEnv := os.Getenv("INFISICAL_DISABLE_UPDATE_CHECK"); checkEnv != "" { + return + } latestVersion, err := getLatestTag("Infisical", "infisical") if err != nil { // do nothing and continue From b226642853a98b3febe91c381ad4285008eaeae4 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Fri, 3 Mar 2023 23:56:14 +0100 Subject: [PATCH 3/4] fix: add debug log --- cli/packages/util/check-for-update.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 87832a9ce..2f283070c 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + log "github.com/sirupsen/logrus" "io" "net/http" "os" @@ -19,6 +20,7 @@ func CheckForUpdate() { } latestVersion, err := getLatestTag("Infisical", "infisical") if err != nil { + log.Debug(err) // do nothing and continue return } From 50da0a753ac5cbb643f7c9a2b315ec93b12816be Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Sun, 5 Mar 2023 22:36:00 -0500 Subject: [PATCH 4/4] Add cli docs for supported environment variables --- docs/cli/commands/export.mdx | 21 +++++++++++++++++++++ docs/cli/commands/run.mdx | 23 ++++++++++++++++++++++- docs/cli/commands/secrets.mdx | 23 ++++++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/docs/cli/commands/export.mdx b/docs/cli/commands/export.mdx index 206a85cc6..0fb673418 100644 --- a/docs/cli/commands/export.mdx +++ b/docs/cli/commands/export.mdx @@ -35,6 +35,27 @@ Export environment variables from the platform into a file format. infisical export --format=yaml > secrets.yaml ``` + ### Environment variables + + Used to fetch secrets via a [service token](/getting-started/dashboard/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec + ``` + + + + Used to disable the check for new CLI versions. This can improve the time it takes to run this command. Recommended for production environments. + + To use, simply export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_DISABLE_UPDATE_CHECK=true + ``` + + ### flags Used to set the environment that secrets are pulled from. diff --git a/docs/cli/commands/run.mdx b/docs/cli/commands/run.mdx index 18c0069bc..d801bd9f3 100644 --- a/docs/cli/commands/run.mdx +++ b/docs/cli/commands/run.mdx @@ -40,7 +40,28 @@ Inject secrets from Infisical into your application process. $ infisical run -- npm run dev ``` - ### flags + ### Environment variables + + Used to fetch secrets via a [service token](/getting-started/dashboard/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec + ``` + + + + Used to disable the check for new CLI versions. This can improve the time it takes to run this command. Recommended for production environments. + + To use, simply export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_DISABLE_UPDATE_CHECK=true + ``` + + + ### Flags Pass secrets into multiple commands at once diff --git a/docs/cli/commands/secrets.mdx b/docs/cli/commands/secrets.mdx index d2c4da494..55f0dc0dc 100644 --- a/docs/cli/commands/secrets.mdx +++ b/docs/cli/commands/secrets.mdx @@ -18,7 +18,28 @@ This command enables you to perform CRUD (create, read, update, delete) operatio $ infisical secrets ``` - ### flags + ### Environment variables + + Used to fetch secrets via a [service token](/getting-started/dashboard/token) apposed to logged in credentials. Simply, export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_TOKEN=st.63e03c4a97cb4a747186c71e.ed5b46a34c078a8f94e8228f4ab0ff97.4f7f38034811995997d72badf44b42ec + ``` + + + + Used to disable the check for new CLI versions. This can improve the time it takes to run this command. Recommended for production environments. + + To use, simply export this variable in the terminal before running this command. + + ```bash + # Example + export INFISICAL_DISABLE_UPDATE_CHECK=true + ``` + + + ### Flags Parse shell parameter expansions in your secrets