From 3f9ec020592d8559f0cd3c5c286eabc709291820 Mon Sep 17 00:00:00 2001 From: Oshrat Zairi <159787052+oshratZairi@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:37:21 +0200 Subject: [PATCH] Updated the names and locations of the environment variables. (#32) --- evidence/cli/command_cli.go | 6 +++--- evidence/cli/command_cli_test.go | 9 +++++---- evidence/cli/flags.go | 6 ------ go.mod | 4 +++- go.sum | 4 ++-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/evidence/cli/command_cli.go b/evidence/cli/command_cli.go index dd61616..992d62e 100644 --- a/evidence/cli/command_cli.go +++ b/evidence/cli/command_cli.go @@ -93,16 +93,16 @@ func ensureKeyExists(ctx *components.Context, key string) error { return nil } - signingKeyValue, _ := getEnvVariable(evdSigningKey) + signingKeyValue, _ := getEnvVariable(coreUtils.SigningKey) if signingKeyValue == "" { - return errorutils.CheckErrorf("'key' or EVD_SIGNING_KEY must be provided when creating evidence: --%s", key) + return errorutils.CheckErrorf("JFROG_CLI_SIGNING_KEY env variable or --%s flag must be provided when creating evidence", key) } ctx.AddStringFlag(key, signingKeyValue) return nil } func setKeyAliasIfProvided(ctx *components.Context, keyAlias string) { - evdKeyAliasValue, _ := getEnvVariable(evdKeyAlias) + evdKeyAliasValue, _ := getEnvVariable(coreUtils.KeyAlias) if evdKeyAliasValue != "" { ctx.AddStringFlag(keyAlias, evdKeyAliasValue) } diff --git a/evidence/cli/command_cli_test.go b/evidence/cli/command_cli_test.go index e5470e4..0a275a8 100644 --- a/evidence/cli/command_cli_test.go +++ b/evidence/cli/command_cli_test.go @@ -4,6 +4,7 @@ import ( "flag" "github.com/jfrog/jfrog-cli-core/v2/common/commands" "github.com/jfrog/jfrog-cli-core/v2/plugins/components" + coreUtils "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" "github.com/stretchr/testify/assert" "github.com/urfave/cli" "go.uber.org/mock/gomock" @@ -15,10 +16,10 @@ func TestCreateEvidence_Context(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - assert.NoError(t, os.Setenv(evdSigningKey, "PGP"), "Failed to set env: "+evdSigningKey) - assert.NoError(t, os.Setenv("JFROG_CLI_BUILD_NAME", buildName), "Failed to set env: JFROG_CLI_BUILD_NAME") - defer os.Unsetenv(evdSigningKey) - defer os.Unsetenv("JFROG_CLI_BUILD_NAME") + assert.NoError(t, os.Setenv(coreUtils.SigningKey, "PGP"), "Failed to set env: "+coreUtils.SigningKey) + assert.NoError(t, os.Setenv(coreUtils.BuildName, buildName), "Failed to set env: JFROG_CLI_BUILD_NAME") + defer os.Unsetenv(coreUtils.SigningKey) + defer os.Unsetenv(coreUtils.BuildName) app := cli.NewApp() app.Commands = []cli.Command{ diff --git a/evidence/cli/flags.go b/evidence/cli/flags.go index 03b3917..13afdc6 100644 --- a/evidence/cli/flags.go +++ b/evidence/cli/flags.go @@ -37,12 +37,6 @@ const ( keyAlias = "key-alias" ) -const ( - // Evidence environments vars - evdSigningKey = "evd_signing_key" - evdKeyAlias = "evd_key_alias" -) - // Flag keys mapped to their corresponding components.Flag definition. var flagsMap = map[string]components.Flag{ // Common commands flags diff --git a/go.mod b/go.mod index a165321..a727ea1 100644 --- a/go.mod +++ b/go.mod @@ -96,7 +96,9 @@ require ( ) //replace github.com/jfrog/jfrog-cli-core/v2 => github.com/oshratZairi/jfrog-cli-core/v2 v2.56.9-0.20241127142944-b39d0cc8f1c1 -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/oshratZairi/jfrog-cli-core/v2 v2.56.9-0.20241127142944-b39d0cc8f1c1 +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/oshratZairi/jfrog-cli-core/v2 v2.31.1-0.20241211104546-3e12a85de116 + +//replace github.com/jfrog/jfrog-cli-core/v2 => ../../jfrog-cli-core //replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240811150357-12a9330a2d67 //replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240811142930-ab9715567376 diff --git a/go.sum b/go.sum index 4433fe4..0f93570 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,8 @@ github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9l github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/oshratZairi/jfrog-cli-core/v2 v2.56.9-0.20241127142944-b39d0cc8f1c1 h1:4RpB6gtAbO5ODXneIHzF/+9Ty/kY+wcscQYbAEmoVYw= -github.com/oshratZairi/jfrog-cli-core/v2 v2.56.9-0.20241127142944-b39d0cc8f1c1/go.mod h1:SThaC/fniC96oN8YgCsHjvOxp5rBM7IppuIybn1oxT0= +github.com/oshratZairi/jfrog-cli-core/v2 v2.31.1-0.20241211104546-3e12a85de116 h1:mj3vWZsJurae/5f8BMSAWNPa6b31PGyiB4KC2fQuctg= +github.com/oshratZairi/jfrog-cli-core/v2 v2.31.1-0.20241211104546-3e12a85de116/go.mod h1:RY74eDpw1WBxruSfZ0HO1ax7c1NAj+rbBgA/hVOJNME= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=