From 47635effd5759fe53998d3c8f527df435b6cc647 Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Sun, 11 Jun 2023 14:23:46 +0300 Subject: [PATCH 1/7] Document WARN log level (#2027) --- docs/common/env.go | 2 +- documentation/JFrog-CLI.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/common/env.go b/docs/common/env.go index 2f5cc2d4b..7e016e24c 100644 --- a/docs/common/env.go +++ b/docs/common/env.go @@ -10,7 +10,7 @@ const ( JfrogCliLogLevel = ` JFROG_CLI_LOG_LEVEL [Default: INFO] This variable determines the log level of the JFrog CLI. - Possible values are: INFO, ERROR, and DEBUG. + Possible values are: DEBUG, INFO, WARN and ERROR. If set to ERROR, JFrog CLI logs error messages only. It is useful when you wish to read or parse the JFrog CLI output and do not want any other information logged.` diff --git a/documentation/JFrog-CLI.md b/documentation/JFrog-CLI.md index cf56800c9..e54196056 100644 --- a/documentation/JFrog-CLI.md +++ b/documentation/JFrog-CLI.md @@ -290,7 +290,7 @@ JFrog CLI makes use of the following environment variables: | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **Variable Name** | **Description** | -| **JFROG_CLI_LOG_LEVEL** | \[Default: INFO\]

This variable determines the log level of the JFrog CLI.
Possible values are: INFO, ERROR, and DEBUG.
If set to ERROR, JFrog CLI logs error messages only. It is useful when you wish to read or parse the JFrog CLI output and do not want any other information logged. | +| **JFROG_CLI_LOG_LEVEL** | \[Default: INFO\]

This variable determines the log level of the JFrog CLI.
Possible values are: DEBUG, INFO, WARN and ERROR.
If set to ERROR, JFrog CLI logs error messages only. It is useful when you wish to read or parse the JFrog CLI output and do not want any other information logged. | | **JFROG_CLI_LOG_TIMESTAMP** | \[Default: TIME\]

Controls the log messages timestamp format. Possible values are: TIME, DATE\_AND\_TIME, and OFF. | | **JFROG_CLI_HOME_DIR** | \[Default: ~/.jfrog\]

Defines the JFrog CLI home directory. | | **JFROG_CLI_TEMP_DIR** | \[Default: The operating system's temp directory\]

Defines the temp directory used by JFrog CLI. | From 21513525ecbaaa557a5e66a77e902c908786d9da Mon Sep 17 00:00:00 2001 From: Sara Omari <114062096+sarao1310@users.noreply.github.com> Date: Sun, 11 Jun 2023 17:35:14 +0300 Subject: [PATCH 2/7] New `--include` option for `jf search` (#1948) * supporting audit with gradle wrapper --- artifactory/cli.go | 1 + documentation/CLI-for-JFrog-Artifactory.md | 8 ++++++++ go.mod | 4 ++-- go.sum | 8 ++++---- utils/cliutils/commandsflags.go | 7 ++++++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/artifactory/cli.go b/artifactory/cli.go index 48aa8d0c5..427b3ab1b 100644 --- a/artifactory/cli.go +++ b/artifactory/cli.go @@ -2566,6 +2566,7 @@ func createDefaultSearchSpec(c *cli.Context) (*spec.SpecFiles, error) { IncludeDirs(c.Bool("include-dirs")). ArchiveEntries(c.String("archive-entries")). Transitive(c.Bool("transitive")). + Include(cliutils.GetStringsArrFlagValue(c, "include")). BuildSpec(), nil } diff --git a/documentation/CLI-for-JFrog-Artifactory.md b/documentation/CLI-for-JFrog-Artifactory.md index 3a5b7edb4..768f84669 100644 --- a/documentation/CLI-for-JFrog-Artifactory.md +++ b/documentation/CLI-for-JFrog-Artifactory.md @@ -559,6 +559,7 @@ This command is used to search and display files in Artifactory. | --insecure-tls | \[Default: false\]

Set to true to skip TLS certificates verification. | | --retries | \[Default: 3\]

Number of HTTP retry attempts. | | --retry-wait-time | \[Default: 0s\]

Number of seconds or milliseconds to wait between retries. The numeric value should either end with s for seconds or ms for milliseconds.retry-wait-time | +| --include | \[Optional\]

List of fields in the form of \"value1;value2;...\".
Only the path and the fields that are specified will be returned. The fields must be part of the 'items' AQL domain. for the full supported items list check [AQL documentation](https://jfrog.com/help/r/jfrog-artifactory-documentation/artifactory-query-language) | | Command arguments | | | Search path | Specifies the search path in Artifactory, in the following format: `[repository name]/[repository path].` You can use wildcards to specify multiple artifacts. | @@ -578,6 +579,13 @@ Display a list of all zip files located under **/rabbit** in the **frog-repo** r jf rt s "frog-repo/rabbit/*.zip" ``` +##### **Example 3** + +Display a list of the files under example-repo-local with the following fields: path, actual_md5, modified_b, updated and depth. +``` +jf rt s example-repo-local --include="actual_md5;modified_by;updated;depth" +``` + ### Setting Properties on Files This command is used for setting properties on existing files in Artifactory. diff --git a/go.mod b/go.mod index f5cff8253..3d5105db3 100644 --- a/go.mod +++ b/go.mod @@ -123,8 +123,8 @@ require ( // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go -// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230608153517-de4a0e58a8cb +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 -// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230608151345-511372c0fe13 +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3 diff --git a/go.sum b/go.sum index 3b0b75fd8..a5df7bd89 100644 --- a/go.sum +++ b/go.sum @@ -238,10 +238,10 @@ github.com/jfrog/build-info-go v1.9.6 h1:lCJ2j5uXAlJsSwDe5J8WD7Co1f/hUlZvMfwfb5A github.com/jfrog/build-info-go v1.9.6/go.mod h1:GbuFS+viHCKZYx9nWHYu7ab1DgQkFdtVN3BJPUNb2D4= github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= -github.com/jfrog/jfrog-cli-core/v2 v2.35.0 h1:HHc4LZWbN0FnTIY/NJDDGCj0t8PcqbtXVS0zMWjSnGM= -github.com/jfrog/jfrog-cli-core/v2 v2.35.0/go.mod h1:Im3KGsSXuW6AeRyncHyMyGSPl4C8KolqB8apmxW19Ts= -github.com/jfrog/jfrog-client-go v1.30.0 h1:pEUCP0aRxyTIpFkN+jHCkHZF+NNllzpZ2pYJOVSbC2E= -github.com/jfrog/jfrog-client-go v1.30.0/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875 h1:Ix7WQLxWNPuh36vAalOJsHZU6LWvfIKVV3gVpbCeATk= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875/go.mod h1:Kzh4oTlJu1iYFNQcgAHgKIMvsvgC5LN2DlV/NHWCXZM= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3 h1:bIpljSo/bnilaRky2mtXcljC0JmONgc97AEy1YG6rXE= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index 1c9dd5f10..68d9a2a7e 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -252,6 +252,7 @@ const ( deleteQuiet = deletePrefix + quiet // Unique search flags + searchInclude = "include" searchPrefix = "search-" searchRecursive = searchPrefix + recursive searchProps = searchPrefix + props @@ -857,6 +858,10 @@ var flagsMap = map[string]cli.Flag{ Name: transitive, Usage: "[Default: false] Set to true to look for artifacts also in remote repositories. The search will run on the first five remote repositories within the virtual repository. Available on Artifactory version 7.17.0 or higher.` `", }, + searchInclude: cli.StringFlag{ + Name: searchInclude, + Usage: fmt.Sprintf("[Optional] List of fields in the form of \"value1;value2;...\". Only the path and the fields that are specified will be returned. The fields must be part of the 'items' AQL domain. For the full supported items list, check %sjfrog-artifactory-documentation/artifactory-query-language` `", coreutils.JFrogHelpUrl), + }, propsRecursive: cli.BoolTFlag{ Name: recursive, Usage: "[Default: true] When false, artifacts inside sub-folders in Artifactory will not be affected.` `", @@ -1602,7 +1607,7 @@ var commandFlags = map[string][]string{ url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, ClientCertPath, ClientCertKeyPath, specFlag, specVars, exclusions, sortBy, sortOrder, limit, offset, searchRecursive, build, includeDeps, excludeArtifacts, count, bundle, includeDirs, searchProps, searchExcludeProps, failNoOp, archiveEntries, - InsecureTls, searchTransitive, retries, retryWaitTime, project, + InsecureTls, searchTransitive, retries, retryWaitTime, project, searchInclude, }, Properties: { url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, ClientCertPath, From 60dd2e55f2224beeaab6b7b7a746658ac02ea5a3 Mon Sep 17 00:00:00 2001 From: Sara Omari <114062096+sarao1310@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:18:32 +0300 Subject: [PATCH 3/7] Bug Fix - Bug - CLI upload status bar keep increasing (#2017) Bug Fix - Bug - CLI upload status bar keep increasing --- go.mod | 4 ++-- go.sum | 8 ++++---- utils/progressbar/filesprogressbar.go | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 3d5105db3..c91291965 100644 --- a/go.mod +++ b/go.mod @@ -123,8 +123,8 @@ require ( // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875 +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 -replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3 +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd diff --git a/go.sum b/go.sum index a5df7bd89..35e394b39 100644 --- a/go.sum +++ b/go.sum @@ -238,10 +238,10 @@ github.com/jfrog/build-info-go v1.9.6 h1:lCJ2j5uXAlJsSwDe5J8WD7Co1f/hUlZvMfwfb5A github.com/jfrog/build-info-go v1.9.6/go.mod h1:GbuFS+viHCKZYx9nWHYu7ab1DgQkFdtVN3BJPUNb2D4= github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875 h1:Ix7WQLxWNPuh36vAalOJsHZU6LWvfIKVV3gVpbCeATk= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230611135850-d003935e8875/go.mod h1:Kzh4oTlJu1iYFNQcgAHgKIMvsvgC5LN2DlV/NHWCXZM= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3 h1:bIpljSo/bnilaRky2mtXcljC0JmONgc97AEy1YG6rXE= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230611131847-a3b84a9004c3/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 h1:MvKxuFsgCeIL74qeXJ7Z6rbDO0tfE15M3D24U0kGgFs= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01/go.mod h1:Kzh4oTlJu1iYFNQcgAHgKIMvsvgC5LN2DlV/NHWCXZM= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd h1:/X2eIts0BRy3Y6AhzBnM+8Dmrl0assoBFG1iyW6Jq8U= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= diff --git a/utils/progressbar/filesprogressbar.go b/utils/progressbar/filesprogressbar.go index a70e09a38..57997bedc 100644 --- a/utils/progressbar/filesprogressbar.go +++ b/utils/progressbar/filesprogressbar.go @@ -185,8 +185,11 @@ func (p *filesProgressBarManager) RemoveProgress(id int) { defer p.barsWg.Done() defer p.barsRWMutex.RUnlock() p.bars[id-1].Abort() - p.generalProgressBar.Increment() +} +// Increases general progress bar by 1 +func (p *filesProgressBarManager) IncrementGeneralProgress() { + p.generalProgressBar.Increment() } // Quits the progress bar while aborting the initial bars. From 37d3e4a7a6aaab32d15d350d4aab9667b3f9b0de Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Wed, 14 Jun 2023 14:07:22 +0300 Subject: [PATCH 4/7] Add GolangCI static checks action and fix all found issues (#2011) --- .github/workflows/analysis.yml | 7 +- access_test.go | 10 +- artifactory/cli.go | 194 +++++++------------------ artifactory_test.go | 40 ++--- buildinfo_test.go | 16 +- buildtools/cli.go | 48 ++---- config/cli.go | 28 +--- distribution/cli.go | 20 +-- docker_test.go | 8 +- docs/common/env.go | 2 +- general/cisetup/cisetup.go | 28 ++-- general/project/cli.go | 4 +- go.mod | 5 +- go.sum | 11 +- go_test.go | 23 ++- gradle_test.go | 6 +- inttestutils/docker.go | 10 +- main.go | 15 +- missioncontrol/cli.go | 20 +-- nuget_test.go | 3 +- pipelines/cli.go | 20 +-- plugins/cli.go | 12 +- plugins_test.go | 14 +- scan/cli.go | 33 ++--- transfer_test.go | 14 +- utils/cliutils/utils.go | 3 - utils/progressbar/filesprogressbar.go | 5 +- utils/progressbar/readerprogressbar.go | 1 + utils/progressbar/simpleprogressbar.go | 3 +- utils/summary/summary.go | 4 +- utils/tests/consts.go | 14 +- utils/tests/container.go | 12 +- utils/tests/proxy/server/server.go | 4 +- utils/tests/utils.go | 4 +- xray_test.go | 34 ++--- 35 files changed, 254 insertions(+), 421 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 69e89ffe3..d3957b0d4 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -34,6 +34,7 @@ jobs: restore-keys: ${{ runner.os }}-go - name: Run Go vet run: go vet -v ./... + Static-Check: name: Static Check ubuntu-latest runs-on: ubuntu-latest @@ -45,9 +46,11 @@ jobs: with: go-version: 1.20.x - name: Static Code Analysis - uses: dominikh/staticcheck-action@v1 + uses: golangci/golangci-lint-action@v3 with: - install-go: false + args: | + --timeout 5m --out-${NO_FUTURE}format colored-line-number --enable errcheck,gosimple,govet,ineffassign,staticcheck,typecheck,unused,gocritic,asasalint,asciicheck,errchkjson,exportloopref,forcetypeassert,makezero,nilerr,unparam,unconvert,wastedassign,usestdlibvars + Go-Sec: name: Go-Sec ubuntu-latest runs-on: ubuntu-latest diff --git a/access_test.go b/access_test.go index 2dc77a5f8..919eba11c 100644 --- a/access_test.go +++ b/access_test.go @@ -64,7 +64,7 @@ func TestRefreshableAccessTokens(t *testing.T) { // Upload a file and assert the refreshable tokens were generated. artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", "") uploadedFiles := 1 - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/a1.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a1.in", uploadedFiles) if !assert.NoError(t, err) { return } @@ -80,11 +80,11 @@ func TestRefreshableAccessTokens(t *testing.T) { // Upload a file and assert tokens were refreshed. uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/a2.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a2.in", uploadedFiles) if !assert.NoError(t, err) { return } - curAccessToken, curRefreshToken, err = assertTokensChanged(t, tests.ServerId, curAccessToken, curRefreshToken) + curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken) if !assert.NoError(t, err) { return } @@ -92,11 +92,11 @@ func TestRefreshableAccessTokens(t *testing.T) { // Make the token not refresh. Verify Tokens did not refresh. auth.InviteRefreshBeforeExpiryMinutes = 0 uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/b/b2.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/b/b2.in", uploadedFiles) if !assert.NoError(t, err) { return } - newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t, tests.ServerId) + newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t) if !assert.NoError(t, err) { return } diff --git a/artifactory/cli.go b/artifactory/cli.go index 427b3ab1b..6e35b64ad 100644 --- a/artifactory/cli.go +++ b/artifactory/cli.go @@ -128,9 +128,7 @@ func GetCommands() []cli.Command { UsageText: upload.GetArguments(), ArgsUsage: common.CreateEnvVars(upload.EnvVar...), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return uploadCmd(c) - }, + Action: uploadCmd, }, { Name: "download", @@ -141,9 +139,7 @@ func GetCommands() []cli.Command { UsageText: download.GetArguments(), ArgsUsage: common.CreateEnvVars(download.EnvVar...), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return downloadCmd(c) - }, + Action: downloadCmd, }, { Name: "move", @@ -154,9 +150,7 @@ func GetCommands() []cli.Command { UsageText: move.GetArguments(), ArgsUsage: common.CreateEnvVars(move.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return moveCmd(c) - }, + Action: moveCmd, }, { Name: "copy", @@ -167,9 +161,7 @@ func GetCommands() []cli.Command { UsageText: copydocs.GetArguments(), ArgsUsage: common.CreateEnvVars(copydocs.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return copyCmd(c) - }, + Action: copyCmd, }, { Name: "delete", @@ -180,9 +172,7 @@ func GetCommands() []cli.Command { UsageText: delete.GetArguments(), ArgsUsage: common.CreateEnvVars(delete.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return deleteCmd(c) - }, + Action: deleteCmd, }, { Name: "search", @@ -193,9 +183,7 @@ func GetCommands() []cli.Command { UsageText: search.GetArguments(), ArgsUsage: common.CreateEnvVars(search.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return searchCmd(c) - }, + Action: searchCmd, }, { Name: "set-props", @@ -206,9 +194,7 @@ func GetCommands() []cli.Command { UsageText: setprops.GetArguments(), ArgsUsage: common.CreateEnvVars(setprops.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return setPropsCmd(c) - }, + Action: setPropsCmd, }, { Name: "delete-props", @@ -219,9 +205,7 @@ func GetCommands() []cli.Command { UsageText: deleteprops.GetArguments(), ArgsUsage: common.CreateEnvVars(deleteprops.EnvVar), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return deletePropsCmd(c) - }, + Action: deletePropsCmd, }, { Name: "build-publish", @@ -232,9 +216,7 @@ func GetCommands() []cli.Command { UsageText: buildpublish.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildPublishCmd(c) - }, + Action: buildPublishCmd, }, { Name: "build-collect-env", @@ -245,9 +227,7 @@ func GetCommands() []cli.Command { UsageText: buildcollectenv.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildCollectEnvCmd(c) - }, + Action: buildCollectEnvCmd, }, { Name: "build-append", @@ -258,9 +238,7 @@ func GetCommands() []cli.Command { UsageText: buildappend.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildAppendCmd(c) - }, + Action: buildAppendCmd, }, { Name: "build-add-dependencies", @@ -271,9 +249,7 @@ func GetCommands() []cli.Command { UsageText: buildadddependencies.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildAddDependenciesCmd(c) - }, + Action: buildAddDependenciesCmd, }, { Name: "build-add-git", @@ -284,9 +260,7 @@ func GetCommands() []cli.Command { UsageText: buildaddgit.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildAddGitCmd(c) - }, + Action: buildAddGitCmd, }, { Name: "build-scan", @@ -309,9 +283,7 @@ func GetCommands() []cli.Command { UsageText: buildclean.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildCleanCmd(c) - }, + Action: buildCleanCmd, }, { Name: "build-promote", @@ -322,9 +294,7 @@ func GetCommands() []cli.Command { UsageText: buildpromote.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildPromoteCmd(c) - }, + Action: buildPromoteCmd, }, { Name: "build-discard", @@ -335,9 +305,7 @@ func GetCommands() []cli.Command { UsageText: builddiscard.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return buildDiscardCmd(c) - }, + Action: buildDiscardCmd, }, { Name: "git-lfs-clean", @@ -348,9 +316,7 @@ func GetCommands() []cli.Command { UsageText: gitlfsclean.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return gitLfsCleanCmd(c) - }, + Action: gitLfsCleanCmd, }, { Name: "mvn-config", @@ -411,9 +377,7 @@ func GetCommands() []cli.Command { UsageText: dockerpromote.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return dockerPromoteCmd(c) - }, + Action: dockerPromoteCmd, }, { Name: "docker-push", @@ -476,9 +440,7 @@ func GetCommands() []cli.Command { UsageText: builddockercreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return BuildDockerCreateCmd(c) - }, + Action: BuildDockerCreateCmd, }, { Name: "oc", // Only 'oc start-build' is supported @@ -489,9 +451,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return ocStartBuildCmd(c) - }, + Action: ocStartBuildCmd, }, { Name: "npm-config", @@ -602,9 +562,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("rt nuget-deps-tree", nugettree.GetDescription(), nugettree.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return nugetDepsTreeCmd(c) - }, + Action: nugetDepsTreeCmd, }, { Name: "dotnet-config", @@ -677,9 +635,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("rt ping", ping.GetDescription(), ping.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return pingCmd(c) - }, + Action: pingCmd, }, { Name: "curl", @@ -691,9 +647,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), SkipFlagParsing: true, - Action: func(c *cli.Context) error { - return curlCmd(c) - }, + Action: curlCmd, }, { Name: "pip-config", @@ -729,9 +683,7 @@ func GetCommands() []cli.Command { UsageText: repotemplate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return repoTemplateCmd(c) - }, + Action: repoTemplateCmd, }, { Name: "repo-create", @@ -742,9 +694,7 @@ func GetCommands() []cli.Command { UsageText: repocreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return repoCreateCmd(c) - }, + Action: repoCreateCmd, }, { Name: "repo-update", @@ -755,9 +705,7 @@ func GetCommands() []cli.Command { UsageText: repoupdate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return repoUpdateCmd(c) - }, + Action: repoUpdateCmd, }, { Name: "repo-delete", @@ -768,9 +716,7 @@ func GetCommands() []cli.Command { UsageText: repodelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return repoDeleteCmd(c) - }, + Action: repoDeleteCmd, }, { Name: "replication-template", @@ -781,9 +727,7 @@ func GetCommands() []cli.Command { UsageText: replicationtemplate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return replicationTemplateCmd(c) - }, + Action: replicationTemplateCmd, }, { Name: "replication-create", @@ -794,9 +738,7 @@ func GetCommands() []cli.Command { UsageText: replicationcreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return replicationCreateCmd(c) - }, + Action: replicationCreateCmd, }, { Name: "replication-delete", @@ -807,9 +749,7 @@ func GetCommands() []cli.Command { UsageText: replicationdelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return replicationDeleteCmd(c) - }, + Action: replicationDeleteCmd, }, { Name: "permission-target-template", @@ -819,9 +759,7 @@ func GetCommands() []cli.Command { UsageText: permissiontargettemplate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return permissionTargetTemplateCmd(c) - }, + Action: permissionTargetTemplateCmd, }, { Name: "permission-target-create", @@ -832,9 +770,7 @@ func GetCommands() []cli.Command { UsageText: permissiontargetcreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return permissionTargetCreateCmd(c) - }, + Action: permissionTargetCreateCmd, }, { Name: "permission-target-update", @@ -845,9 +781,7 @@ func GetCommands() []cli.Command { UsageText: permissiontargetupdate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return permissionTargetUpdateCmd(c) - }, + Action: permissionTargetUpdateCmd, }, { Name: "permission-target-delete", @@ -858,9 +792,7 @@ func GetCommands() []cli.Command { UsageText: permissiontargetdelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return permissionTargetDeleteCmd(c) - }, + Action: permissionTargetDeleteCmd, }, { Name: "user-create", @@ -869,9 +801,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("rt user-create", usercreate.GetDescription(), usercreate.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return userCreateCmd(c) - }, + Action: userCreateCmd, }, { Name: "users-create", @@ -881,9 +811,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("rt uc", userscreate.GetDescription(), userscreate.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return usersCreateCmd(c) - }, + Action: usersCreateCmd, }, { Name: "users-delete", @@ -894,9 +822,7 @@ func GetCommands() []cli.Command { UsageText: usersdelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return usersDeleteCmd(c) - }, + Action: usersDeleteCmd, }, { Name: "group-create", @@ -907,9 +833,7 @@ func GetCommands() []cli.Command { UsageText: groupcreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return groupCreateCmd(c) - }, + Action: groupCreateCmd, }, { Name: "group-add-users", @@ -920,9 +844,7 @@ func GetCommands() []cli.Command { UsageText: groupaddusers.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return groupAddUsersCmd(c) - }, + Action: groupAddUsersCmd, }, { Name: "group-delete", @@ -933,9 +855,7 @@ func GetCommands() []cli.Command { UsageText: groupdelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return groupDeleteCmd(c) - }, + Action: groupDeleteCmd, }, { Name: "access-token-create", @@ -946,9 +866,7 @@ func GetCommands() []cli.Command { UsageText: accesstokencreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return accessTokenCreateCmd(c) - }, + Action: accessTokenCreateCmd, }, { Name: "transfer-settings", @@ -956,9 +874,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("rt transfer-settings", transfersettings.GetDescription(), transfersettings.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return transferSettingsCmd() - }, + Action: transferSettingsCmd, }, { Name: "transfer-config", @@ -968,9 +884,7 @@ func GetCommands() []cli.Command { UsageText: transferconfig.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return transferConfigCmd(c) - }, + Action: transferConfigCmd, }, { Name: "transfer-config-merge", @@ -980,9 +894,7 @@ func GetCommands() []cli.Command { UsageText: transferconfigmerge.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return transferConfigMergeCmd(c) - }, + Action: transferConfigMergeCmd, }, { Name: "transfer-files", @@ -992,9 +904,7 @@ func GetCommands() []cli.Command { UsageText: transferfiles.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return transferFilesCmd(c) - }, + Action: transferFilesCmd, }, { Name: "transfer-plugin-install", @@ -1004,9 +914,7 @@ func GetCommands() []cli.Command { UsageText: transferplugininstall.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return dataTransferPluginInstallCmd(c) - }, + Action: dataTransferPluginInstallCmd, }, }) } @@ -1062,12 +970,14 @@ func getRetryWaitTime(c *cli.Context) (waitMilliSecs int, err error) { waitTimeStringValue := c.String("retry-wait-time") useSeconds := false if waitTimeStringValue != "" { - if strings.HasSuffix(waitTimeStringValue, "ms") { + switch { + case strings.HasSuffix(waitTimeStringValue, "ms"): waitTimeStringValue = strings.TrimSuffix(waitTimeStringValue, "ms") - } else if strings.HasSuffix(waitTimeStringValue, "s") { + + case strings.HasSuffix(waitTimeStringValue, "s"): useSeconds = true waitTimeStringValue = strings.TrimSuffix(waitTimeStringValue, "s") - } else { + default: err = getRetryWaitTimeVerificationError() return } @@ -1078,7 +988,7 @@ func getRetryWaitTime(c *cli.Context) (waitMilliSecs int, err error) { } // Convert seconds to milliseconds if useSeconds { - waitMilliSecs = waitMilliSecs * 1000 + waitMilliSecs *= 1000 } } return diff --git a/artifactory_test.go b/artifactory_test.go index b8a9ae04a..250545b05 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -123,7 +123,7 @@ func authenticate(configCli bool) string { // Removed the ssh-passphrase flag that cannot be passed to with a config command func createConfigJfrogCLI(cred string) *tests.JfrogCli { if strings.Contains(cred, " --ssh-passphrase=") { - cred = strings.Replace(cred, " --ssh-passphrase="+*tests.JfrogSshPassphrase, "", -1) + cred = strings.ReplaceAll(cred, " --ssh-passphrase="+*tests.JfrogSshPassphrase, "") } return tests.NewJfrogCli(execMain, "jfrog config", cred) } @@ -1248,10 +1248,10 @@ func TestArtifactoryDownloadAndExplodeSpecialChars(t *testing.T) { cleanArtifactoryTest() } -func verifyExistAndCleanDir(t *testing.T, GetExtractedDownload func() []string) { +func verifyExistAndCleanDir(t *testing.T, getExtractedDownload func() []string) { paths, err := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false) assert.NoError(t, err) - tests.VerifyExistLocally(GetExtractedDownload(), paths, t) + tests.VerifyExistLocally(getExtractedDownload(), paths, t) clientTestUtils.RemoveAllAndAssert(t, tests.Out) assert.NoError(t, fileutils.CreateDirIfNotExist(tests.Out)) } @@ -4216,7 +4216,7 @@ func TestArtifactoryBuildDiscard(t *testing.T) { jsonResponse = getAllBuildsByBuildName(client, tests.RtBuildName1, t, http.StatusNotFound) assert.Zero(t, jsonResponse, "Incorrect operation of build-discard by max-days.") - //Cleanup + // Cleanup inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.RtBuildName1, artHttpDetails) cleanArtifactoryTest() } @@ -5255,11 +5255,11 @@ func TestRefreshableArtifactoryTokens(t *testing.T) { // Upload a file and assert the refreshable tokens were generated. artifactoryCommandExecutor := tests.NewJfrogCli(execMain, "jfrog rt", "") uploadedFiles := 1 - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/a1.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a1.in", uploadedFiles) if err != nil { return } - curAccessToken, curRefreshToken, err := getArtifactoryTokensFromConfig(t, tests.ServerId) + curAccessToken, curRefreshToken, err := getArtifactoryTokensFromConfig(t) if err != nil { return } @@ -5271,11 +5271,11 @@ func TestRefreshableArtifactoryTokens(t *testing.T) { // Upload a file and assert tokens were refreshed. uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/a2.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a2.in", uploadedFiles) if err != nil { return } - curAccessToken, curRefreshToken, err = assertTokensChanged(t, tests.ServerId, curAccessToken, curRefreshToken) + curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken) if err != nil { return } @@ -5286,11 +5286,11 @@ func TestRefreshableArtifactoryTokens(t *testing.T) { return } uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/a3.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/a3.in", uploadedFiles) if err != nil { return } - curAccessToken, curRefreshToken, err = assertTokensChanged(t, tests.ServerId, curAccessToken, curRefreshToken) + curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken) if err != nil { return } @@ -5301,11 +5301,11 @@ func TestRefreshableArtifactoryTokens(t *testing.T) { return } uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/b/b1.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/b/b1.in", uploadedFiles) if err != nil { return } - curAccessToken, curRefreshToken, err = assertTokensChanged(t, tests.ServerId, curAccessToken, curRefreshToken) + curAccessToken, curRefreshToken, err = assertTokensChanged(t, curAccessToken, curRefreshToken) if err != nil { return } @@ -5313,11 +5313,11 @@ func TestRefreshableArtifactoryTokens(t *testing.T) { // Make the token not refresh. Verify Tokens did not refresh. auth.RefreshBeforeExpiryMinutes = 0 uploadedFiles++ - err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, tests.ServerId, "testdata/a/b/b2.in", uploadedFiles) + err = uploadWithSpecificServerAndVerify(t, artifactoryCommandExecutor, "testdata/a/b/b2.in", uploadedFiles) if err != nil { return } - newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t, tests.ServerId) + newAccessToken, newRefreshToken, err := getArtifactoryTokensFromConfig(t) if err != nil { return } @@ -5358,8 +5358,8 @@ func setPasswordInConfig(t *testing.T, serverId, password string) error { return nil } -func getArtifactoryTokensFromConfig(t *testing.T, serverId string) (accessToken, refreshToken string, err error) { - details, err := config.GetSpecificConfig(serverId, false, false) +func getArtifactoryTokensFromConfig(t *testing.T) (accessToken, refreshToken string, err error) { + details, err := config.GetSpecificConfig(tests.ServerId, false, false) if err != nil { assert.NoError(t, err) return "", "", err @@ -5367,8 +5367,8 @@ func getArtifactoryTokensFromConfig(t *testing.T, serverId string) (accessToken, return details.AccessToken, details.ArtifactoryRefreshToken, nil } -func assertTokensChanged(t *testing.T, serverId, curAccessToken, curRefreshToken string) (newAccessToken, newRefreshToken string, err error) { - newAccessToken, newRefreshToken, err = getArtifactoryTokensFromConfig(t, serverId) +func assertTokensChanged(t *testing.T, curAccessToken, curRefreshToken string) (newAccessToken, newRefreshToken string, err error) { + newAccessToken, newRefreshToken, err = getArtifactoryTokensFromConfig(t) if err != nil { assert.NoError(t, err) return "", "", err @@ -5378,8 +5378,8 @@ func assertTokensChanged(t *testing.T, serverId, curAccessToken, curRefreshToken return newAccessToken, newRefreshToken, nil } -func uploadWithSpecificServerAndVerify(t *testing.T, cli *tests.JfrogCli, serverId string, source string, expectedResults int) error { - err := cli.Exec("upload", source, tests.RtRepo1, "--server-id="+serverId) +func uploadWithSpecificServerAndVerify(t *testing.T, cli *tests.JfrogCli, source string, expectedResults int) error { + err := cli.Exec("upload", source, tests.RtRepo1, "--server-id="+tests.ServerId) if err != nil { assert.NoError(t, err) return err diff --git a/buildinfo_test.go b/buildinfo_test.go index 9231d3d7f..a04443559 100644 --- a/buildinfo_test.go +++ b/buildinfo_test.go @@ -199,7 +199,7 @@ func TestBuildPublishDetailedSummary(t *testing.T) { assert.NoError(t, err) runRt(t, "upload", "--spec="+specFile, "--build-name="+tests.RtBuildName1, "--build-number="+buildNumber) // Verify build dir is not empty - assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber, "")) + assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber)) buffer, _, previousLog := coretests.RedirectLogOutputToBuffer() // Restore previous logger when the function returns @@ -224,7 +224,7 @@ func TestBuildPublishDryRun(t *testing.T) { assert.NoError(t, err) runRt(t, "upload", "--spec="+specFile, "--build-name="+tests.RtBuildName1, "--build-number="+buildNumber) // Verify build dir is not empty - assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber, "")) + assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber)) buffer, _, previousLog := coretests.RedirectLogOutputToBuffer() // Restore previous logger when the function returns @@ -235,7 +235,7 @@ func TestBuildPublishDryRun(t *testing.T) { verifyBuildPublishOutput(t, buffer, true) // Verify build dir is not empty. - assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber, "")) + assert.NotEmpty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber)) // Verify build was not published. _, found, err := tests.GetBuildInfo(serverDetails, tests.RtBuildName1, buildNumber) if err != nil { @@ -252,7 +252,7 @@ func TestBuildPublishDryRun(t *testing.T) { verifyBuildPublishOutput(t, buffer, false) // Verify build dir is empty - assert.Empty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber, "")) + assert.Empty(t, getFilesFromBuildDir(t, tests.RtBuildName1, buildNumber)) // Verify build was published publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, tests.RtBuildName1, buildNumber) if err != nil { @@ -282,7 +282,10 @@ func verifyBuildPublishOutput(t *testing.T, buffer *bytes.Buffer, dryRun bool) { } } -func getFilesFromBuildDir(t *testing.T, buildName, buildNumber, projectKey string) []os.DirEntry { +// The linter has an issue with buildNumber that is always the same number, but we do it on purpose. +// +//nolint:unparam +func getFilesFromBuildDir(t *testing.T, buildName, buildNumber string) []os.DirEntry { buildDir, err := utils.GetBuildDir(buildName, buildNumber, "") assert.NoError(t, err) @@ -867,7 +870,8 @@ func validateBuildAddDepsBuildInfo(t *testing.T, buildInfoTestParams buildAddDep } buildInfo := publishedBuildInfo.BuildInfo if buildInfo.Modules == nil || len(buildInfo.Modules) == 0 { - buildInfoString, _ := json.Marshal(buildInfo) + buildInfoString, err := json.Marshal(buildInfo) + assert.NoError(t, err) // Case no module was not created assert.Failf(t, "%s test with the command: \nrt bad %s \nexpected to have module with the following dependencies: \n%s \nbut has no modules: \n%s", buildInfoTestParams.description, buildInfoTestParams.commandArgs, buildInfoTestParams.expectedDependencies, buildInfoString) diff --git a/buildtools/cli.go b/buildtools/cli.go index 8ef8f3c8d..4d1f9762d 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -84,9 +84,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return MvnCmd(c) - }, + Action: MvnCmd, }, { Name: "gradle-config", @@ -111,9 +109,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return GradleCmd(c) - }, + Action: GradleCmd, }, { Name: "yarn-config", @@ -137,9 +133,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return YarnCmd(c) - }, + Action: YarnCmd, }, { Name: "nuget-config", @@ -164,9 +158,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return NugetCmd(c) - }, + Action: NugetCmd, }, { Name: "dotnet-config", @@ -191,9 +183,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return DotnetCmd(c) - }, + Action: DotnetCmd, }, { Name: "go-config", @@ -219,9 +209,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return GoCmd(c) - }, + Action: GoCmd, }, { Name: "go-publish", @@ -233,9 +221,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return GoPublishCmd(c) - }, + Action: GoPublishCmd, }, { Name: "pip-config", @@ -260,9 +246,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return PipCmd(c) - }, + Action: PipCmd, }, { Name: "pipenv-config", @@ -287,9 +271,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return PipenvCmd(c) - }, + Action: PipenvCmd, }, { Name: "poetry-config", @@ -314,9 +296,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return PoetryCmd(c) - }, + Action: PoetryCmd, }, { Name: "npm-config", @@ -361,9 +341,7 @@ func GetCommands() []cli.Command { }(), BashComplete: corecommon.CreateBashCompletionFunc("push", "pull", "scan"), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return dockerCmd(c) - }, + Action: dockerCmd, }, { Name: "terraform-config", @@ -389,9 +367,7 @@ func GetCommands() []cli.Command { SkipFlagParsing: true, BashComplete: corecommon.CreateBashCompletionFunc(), Category: buildToolsCategory, - Action: func(c *cli.Context) error { - return terraformCmd(c) - }, + Action: terraformCmd, }, }) } diff --git a/config/cli.go b/config/cli.go index 8f7ab75aa..b55d5dadc 100644 --- a/config/cli.go +++ b/config/cli.go @@ -31,9 +31,7 @@ func GetCommands() []cli.Command { Flags: cliutils.GetCommandFlags(cliutils.AddConfig), HelpName: corecommon.CreateUsage("c add", add.GetDescription(), add.Usage), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return addCmd(c) - }, + Action: addCmd, }, { Name: "edit", @@ -41,9 +39,7 @@ func GetCommands() []cli.Command { Flags: cliutils.GetCommandFlags(cliutils.EditConfig), HelpName: corecommon.CreateUsage("c edit", edit.GetDescription(), edit.Usage), BashComplete: corecommon.CreateBashCompletionFunc(commands.GetAllServerIds()...), - Action: func(c *cli.Context) error { - return editCmd(c) - }, + Action: editCmd, }, { Name: "show", @@ -51,9 +47,7 @@ func GetCommands() []cli.Command { Usage: show.GetDescription(), HelpName: corecommon.CreateUsage("c show", show.GetDescription(), show.Usage), BashComplete: corecommon.CreateBashCompletionFunc(commands.GetAllServerIds()...), - Action: func(c *cli.Context) error { - return showCmd(c) - }, + Action: showCmd, }, { Name: "remove", @@ -62,9 +56,7 @@ func GetCommands() []cli.Command { Flags: cliutils.GetCommandFlags(cliutils.DeleteConfig), HelpName: corecommon.CreateUsage("c rm", remove.GetDescription(), remove.Usage), BashComplete: corecommon.CreateBashCompletionFunc(commands.GetAllServerIds()...), - Action: func(c *cli.Context) error { - return deleteCmd(c) - }, + Action: deleteCmd, }, { Name: "import", @@ -72,9 +64,7 @@ func GetCommands() []cli.Command { Usage: importcmd.GetDescription(), HelpName: corecommon.CreateUsage("c import", importcmd.GetDescription(), importcmd.Usage), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return importCmd(c) - }, + Action: importCmd, }, { Name: "export", @@ -82,18 +72,14 @@ func GetCommands() []cli.Command { Usage: exportcmd.GetDescription(), HelpName: corecommon.CreateUsage("c export", exportcmd.GetDescription(), exportcmd.Usage), BashComplete: corecommon.CreateBashCompletionFunc(commands.GetAllServerIds()...), - Action: func(c *cli.Context) error { - return exportCmd(c) - }, + Action: exportCmd, }, { Name: "use", Usage: use.GetDescription(), HelpName: corecommon.CreateUsage("c use", use.GetDescription(), use.Usage), BashComplete: corecommon.CreateBashCompletionFunc(commands.GetAllServerIds()...), - Action: func(c *cli.Context) error { - return useCmd(c) - }, + Action: useCmd, }, }) } diff --git a/distribution/cli.go b/distribution/cli.go index 875af521c..81d04c537 100644 --- a/distribution/cli.go +++ b/distribution/cli.go @@ -35,9 +35,7 @@ func GetCommands() []cli.Command { UsageText: releasebundlecreate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: coreCommonDocs.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return releaseBundleCreateCmd(c) - }, + Action: releaseBundleCreateCmd, }, { Name: "release-bundle-update", @@ -48,9 +46,7 @@ func GetCommands() []cli.Command { UsageText: releasebundleupdate.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: coreCommonDocs.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return releaseBundleUpdateCmd(c) - }, + Action: releaseBundleUpdateCmd, }, { Name: "release-bundle-sign", @@ -61,9 +57,7 @@ func GetCommands() []cli.Command { UsageText: releasebundlesign.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: coreCommonDocs.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return releaseBundleSignCmd(c) - }, + Action: releaseBundleSignCmd, }, { Name: "release-bundle-distribute", @@ -74,9 +68,7 @@ func GetCommands() []cli.Command { UsageText: releasebundledistribute.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: coreCommonDocs.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return releaseBundleDistributeCmd(c) - }, + Action: releaseBundleDistributeCmd, }, { Name: "release-bundle-delete", @@ -87,9 +79,7 @@ func GetCommands() []cli.Command { UsageText: releasebundledelete.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: coreCommonDocs.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return releaseBundleDeleteCmd(c) - }, + Action: releaseBundleDeleteCmd, }, }) } diff --git a/docker_test.go b/docker_test.go index f418dc2d5..f0c76ef12 100644 --- a/docker_test.go +++ b/docker_test.go @@ -209,10 +209,8 @@ func TestPushFatManifestImage(t *testing.T) { // Docker daemon take times to load. In order to check if it's available we wait for a log message to indications that the Docker daemon has finished initializing. WaitFor(wait.ForLog("API listen on /var/run/docker.sock").WithStartupTimeout(5*time.Minute)). Remove(). - Build(ctx, t, true) - if err != nil { - t.Errorf("Couldn't run create buildx image. Error: %s", err.Error()) - } + Build(ctx, true) + assert.NoError(t, err, "Couldn't run create buildx image.") defer func() { assert.NoError(t, testContainer.Terminate(ctx)) }() // Enable the builder util in the container. @@ -495,7 +493,7 @@ func runKaniko(t *testing.T, imageToPush string) string { Mount(credentialsFile, "/kaniko/.docker/config.json", true). Cmd("--dockerfile="+dockerFile, "--destination="+imageToPush, "--insecure", "--skip-tls-verify", "--image-name-with-digest-file="+KanikoOutputFile). WaitFor(wait.ForExit().WithExitTimeout(300000*time.Millisecond)). - Build(context.Background(), t, true) + Build(context.Background(), true) assert.NoError(t, err) // Return a file contains the image metadata which was built by Kaniko. diff --git a/docs/common/env.go b/docs/common/env.go index 7e016e24c..105b74148 100644 --- a/docs/common/env.go +++ b/docs/common/env.go @@ -129,5 +129,5 @@ func GetGlobalEnvVars() string { func CreateEnvVars(envVars ...string) string { var s []string s = append(s, envVars...) - return strings.Join(s[:], "\n\n") + return strings.Join(s, "\n\n") } diff --git a/general/cisetup/cisetup.go b/general/cisetup/cisetup.go index 1396c8559..450c04ad5 100644 --- a/general/cisetup/cisetup.go +++ b/general/cisetup/cisetup.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "golang.org/x/exp/slices" "os" "path" "path/filepath" @@ -170,8 +171,8 @@ func (cc *CiSetupCommand) Run() error { return err } // Ask the user which CI he tries to setup - err = cc.ciProviderPhase() - err = saveIfNoError(err, cc.data) + cc.ciProviderPhase() + err = saveVcsConf(cc.data) if err != nil { return err } @@ -298,6 +299,7 @@ func getPipelinesToken() (string, error) { if err != nil { return "", err } + //nolint:unconvert byteToken, err = term.ReadPassword(int(syscall.Stdin)) if err != nil { return "", errorutils.CheckError(err) @@ -494,7 +496,7 @@ func (cc *CiSetupCommand) getGithubActionsCompletionInstruction(githubActionFile } func (cc *CiSetupCommand) logCompletionInstruction(ciSpecificInstructions []string) error { - instructions := append(ciSpecificInstructions, + instructions := append(slices.Clone(ciSpecificInstructions), coreutils.PrintTitle("Allowing developers to access this pipeline from their IDE"), "You have the option of viewing the new pipeline's runs from within IntelliJ IDEA.", "To achieve this, follow these steps:", @@ -519,7 +521,7 @@ func getPipelineUiPath(pipelinesUrl, pipelineName string) string { func (cc *CiSetupCommand) publishFirstBuild() (err error) { cc.data.BuildName = fmt.Sprintf("%s-%s", cc.data.RepositoryName, cc.data.GitBranch) // Run BAG Command (in order to publish the first, empty, build info) - buildAddGitConfigurationCmd := buildinfo.NewBuildAddGitCommand().SetDotGitPath(cc.data.LocalDirPath).SetServerId(cisetup.ConfigServerId) //.SetConfigFilePath(c.String("config")) + buildAddGitConfigurationCmd := buildinfo.NewBuildAddGitCommand().SetDotGitPath(cc.data.LocalDirPath).SetServerId(cisetup.ConfigServerId) buildConfiguration := rtutils.NewBuildConfiguration(cc.data.BuildName, DefaultFirstBuildNumber, "", "") buildAddGitConfigurationCmd = buildAddGitConfigurationCmd.SetBuildConfiguration(buildConfiguration) log.Info("Generating an initial build-info...") @@ -567,10 +569,10 @@ func (cc *CiSetupCommand) xrayConfigPhase() (err error) { err = xrayManager.CreatePolicy(policyParams) if err != nil { // In case the error is from type PolicyAlreadyExistsError, we should continue with the regular flow. - if _, ok := err.(*xrayservices.PolicyAlreadyExistsError); !ok { + if paeErr, ok := err.(*xrayservices.PolicyAlreadyExistsError); !ok { return err } else { - log.Debug(err.(*xrayservices.PolicyAlreadyExistsError).InnerError) + log.Debug(paeErr.InnerError) } } // Create new default watcher. @@ -589,10 +591,10 @@ func (cc *CiSetupCommand) xrayConfigPhase() (err error) { err = xrayManager.CreateWatch(watchParams) if err != nil { // In case the error is from type WatchAlreadyExistsError, we should continue with the regular flow. - if _, ok := err.(*xrayservices.WatchAlreadyExistsError); !ok { + if waeErr, ok := err.(*xrayservices.WatchAlreadyExistsError); !ok { return err } else { - log.Debug(err.(*xrayservices.WatchAlreadyExistsError).InnerError) + log.Debug(waeErr.InnerError) err = nil } } @@ -963,6 +965,7 @@ func (cc *CiSetupCommand) gitPhase() (err error) { if err != nil { return err } + //nolint:unconvert byteToken, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { log.Error(err) @@ -986,10 +989,9 @@ func (cc *CiSetupCommand) gitPhase() (err error) { } } -func (cc *CiSetupCommand) ciProviderPhase() (err error) { - var ciType string +func (cc *CiSetupCommand) ciProviderPhase() { for { - ciType, err = promptCiProviderSelection() + ciType, err := promptCiProviderSelection() if err != nil { log.Error(err) continue @@ -1027,7 +1029,7 @@ func (cc *CiSetupCommand) ciProviderPhase() (err error) { _, err = pipelinesMgr.GetSystemInfo() if err == nil { cc.data.CiType = cisetup.CiType(ciType) - return nil + return } log.Error(err) if _, ok := err.(*pipelinesservices.PipelinesNotAvailableError); ok { @@ -1038,7 +1040,7 @@ func (cc *CiSetupCommand) ciProviderPhase() (err error) { } } else { // The user doesn't choose Pipelines. cc.data.CiType = cisetup.CiType(ciType) - return nil + return } } } diff --git a/general/project/cli.go b/general/project/cli.go index 64c32726c..f1a3dd758 100644 --- a/general/project/cli.go +++ b/general/project/cli.go @@ -23,9 +23,7 @@ func GetCommands() []cli.Command { Flags: cliutils.GetCommandFlags(cliutils.InitProject), HelpName: corecommon.CreateUsage("project init", projectinit.GetDescription(), projectinit.Usage), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return initProject(c) - }, + Action: initProject, }, }) } diff --git a/go.mod b/go.mod index c91291965..ce09de2c6 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/agnivade/levenshtein v1.1.1 github.com/buger/jsonparser v1.1.1 github.com/go-git/go-git/v5 v5.7.0 - github.com/gocarina/gocsv v0.0.0-20230513223533-9ddd7fd60602 + github.com/gocarina/gocsv v0.0.0-20230406101422-6445c2b15027 github.com/jfrog/build-info-go v1.9.6 github.com/jfrog/gofrog v1.3.0 github.com/jfrog/jfrog-cli-core/v2 v2.35.0 @@ -16,12 +16,13 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.20.1 - github.com/urfave/cli v1.22.13 + github.com/urfave/cli v1.22.12 github.com/vbauerster/mpb/v7 v7.5.3 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/term v0.8.0 gopkg.in/yaml.v2 v2.4.0 + ) require ( diff --git a/go.sum b/go.sum index 35e394b39..60006e5ce 100644 --- a/go.sum +++ b/go.sum @@ -109,6 +109,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= +github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= @@ -147,8 +149,8 @@ github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhc github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/gocarina/gocsv v0.0.0-20230513223533-9ddd7fd60602 h1:HSpPf+lPYwzoJNup34uegmOQk5Qm83S+wpu8anTDJkg= -github.com/gocarina/gocsv v0.0.0-20230513223533-9ddd7fd60602/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= +github.com/gocarina/gocsv v0.0.0-20230406101422-6445c2b15027 h1:LCGzZb4kMUUjMUzLxxqSJBwo9szUO0tK8cOxnEOT4Jc= +github.com/gocarina/gocsv v0.0.0-20230406101422-6445c2b15027/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -376,7 +378,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= @@ -388,8 +389,8 @@ github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli v1.22.13 h1:wsLILXG8qCJNse/qAgLNf23737Cx05GflHg/PJGe1Ok= -github.com/urfave/cli v1.22.13/go.mod h1:VufqObjsMTF2BBwKawpx9R8eAneNEWhoO0yx8Vd+FkE= +github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8= +github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= github.com/vbauerster/mpb/v7 v7.5.3 h1:BkGfmb6nMrrBQDFECR/Q7RkKCw7ylMetCb4079CGs4w= github.com/vbauerster/mpb/v7 v7.5.3/go.mod h1:i+h4QY6lmLvBNK2ah1fSreiw3ajskRlBp9AhY/PnuOE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= diff --git a/go_test.go b/go_test.go index d2559db76..d51d422ff 100644 --- a/go_test.go +++ b/go_test.go @@ -31,7 +31,7 @@ func TestGoConfigWithModuleNameChange(t *testing.T) { wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - prepareGoProject("project1", "", t, true) + prepareGoProject("project1", t, true) runGo(t, ModuleNameJFrogTest, tests.GoBuildName, buildNumber, 4, 0, "go", "build", "--mod=mod", "--build-name="+tests.GoBuildName, "--build-number="+buildNumber, "--module="+ModuleNameJFrogTest) clientTestUtils.ChangeDirAndAssert(t, wd) @@ -44,7 +44,7 @@ func TestGoGetSpecificVersion(t *testing.T) { buildNumber := "1" wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - prepareGoProject("project1", "", t, true) + prepareGoProject("project1", t, true) // Build and publish a go project. // We do so in order to make sure the rsc.io/quote:v1.5.2 will be available for the get command runGo(t, "", tests.GoBuildName, buildNumber, 4, 0, "go", "build", "--mod=mod", "--build-name="+tests.GoBuildName, "--build-number="+buildNumber) @@ -87,7 +87,7 @@ func TestGoGetNestedPackage(t *testing.T) { defer cleanUpFunc() wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - prepareGoProject("project1", "", t, true) + prepareGoProject("project1", t, true) jfrogCli := tests.NewJfrogCli(execMain, "jfrog", "") // Download 'mockgen', which is a nested package inside 'github.com/golang/mock@v1.4.1'. Then validate it was downloaded correctly. @@ -112,9 +112,9 @@ func TestGoPublishResolve(t *testing.T) { defer cleanUpFunc() wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - project1Path := prepareGoProject("project1", "", t, true) + project1Path := prepareGoProject("project1", t, true) clientTestUtils.ChangeDirAndAssert(t, wd) - project2Path := prepareGoProject("project2", "", t, true) + project2Path := prepareGoProject("project2", t, true) clientTestUtils.ChangeDirAndAssert(t, project1Path) // Build the first project and download its dependencies from Artifactory @@ -145,7 +145,7 @@ func TestGoPublishWithDetailedSummary(t *testing.T) { // Init environment wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - projectPath := prepareGoProject("project1", "", t, true) + projectPath := prepareGoProject("project1", t, true) // Publish with detailed summary and buildinfo. // Build project @@ -190,7 +190,7 @@ func TestGoPublishWithDeploymentView(t *testing.T) { wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - prepareGoProject("project1", "", t, true) + prepareGoProject("project1", t, true) jfrogCli := tests.NewJfrogCli(execMain, "jf", "") err = execGo(jfrogCli, "gp", "v1.1.1") if err != nil { @@ -209,7 +209,7 @@ func TestGoVcsFallback(t *testing.T) { wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - _ = prepareGoProject("vcsfallback", "", t, false) + _ = prepareGoProject("vcsfallback", t, false) jfrogCli := tests.NewJfrogCli(execMain, "jfrog", "") // Run "go get github.com/octocat/Hello-World" with --no-fallback. @@ -225,17 +225,14 @@ func TestGoVcsFallback(t *testing.T) { clientTestUtils.ChangeDirAndAssert(t, wd) } -func prepareGoProject(projectName, configDestDir string, t *testing.T, copyDirs bool) string { +func prepareGoProject(projectName string, t *testing.T, copyDirs bool) string { projectPath := createGoProject(t, projectName, copyDirs) testdataTarget := filepath.Join(tests.Out, "testdata") testdataSrc := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "go", "testdata") err := fileutils.CopyDir(testdataSrc, testdataTarget, copyDirs, nil) assert.NoError(t, err) - if configDestDir == "" { - configDestDir = filepath.Join(projectPath, ".jfrog") - } configFileDir := filepath.Join(filepath.FromSlash(tests.GetTestResourcesPath()), "go", projectName, ".jfrog", "projects") - _, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "go.yaml"), filepath.Join(configDestDir, "projects")) + _, err = tests.ReplaceTemplateVariables(filepath.Join(configFileDir, "go.yaml"), filepath.Join(projectPath, ".jfrog", "projects")) assert.NoError(t, err) clientTestUtils.ChangeDirAndAssert(t, projectPath) log.Info("Using Go project located at", projectPath) diff --git a/gradle_test.go b/gradle_test.go index c89f8ca12..773521091 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -74,7 +74,8 @@ func TestGradleBuildWithServerID(t *testing.T) { createConfigFile(destPath, configFilePath, t) oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) buildNumber := "1" - buildGradlePath = strings.Replace(buildGradlePath, `\`, "/", -1) // Windows compatibility. + // Windows compatibility + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") runJfrogCli(t, "gradle", "clean artifactoryPublish", "-b"+buildGradlePath, "--build-name="+tests.GradleBuildName, "--build-number="+buildNumber) clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) // Validate @@ -106,7 +107,8 @@ func TestGradleBuildWithServerIDAndDetailedSummary(t *testing.T) { createConfigFile(destPath, configFilePath, t) oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath)) buildNumber := "1" - buildGradlePath = strings.Replace(buildGradlePath, `\`, "/", -1) // Windows compatibility. + // Windows compatibility. + buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/") // Test gradle with detailed summary without buildinfo props. filteredGradleArgs := []string{"clean artifactoryPublish", "-b" + buildGradlePath} diff --git a/inttestutils/docker.go b/inttestutils/docker.go index 44f496d39..5b537d2db 100644 --- a/inttestutils/docker.go +++ b/inttestutils/docker.go @@ -51,7 +51,7 @@ func (image *BuildDockerImage) GetCmd() *exec.Cmd { } cmd = append(cmd, image.buildContext) - return exec.Command(image.containerManager.String(), cmd[:]...) + return exec.Command(image.containerManager.String(), cmd...) } func (image *BuildDockerImage) GetEnv() map[string]string { @@ -82,7 +82,7 @@ func (e *ExecDockerImage) GetCmd() *exec.Cmd { var cmd []string cmd = append(cmd, "exec") cmd = append(cmd, e.Args...) - return exec.Command(e.containerManager.String(), cmd[:]...) + return exec.Command(e.containerManager.String(), cmd...) } func (e *ExecDockerImage) GetEnv() map[string]string { @@ -118,7 +118,7 @@ func (run *RunDockerImage) GetCmd() *exec.Cmd { var cmd []string cmd = append(cmd, "run") cmd = append(cmd, run.Args...) - return exec.Command(run.containerManager.String(), cmd[:]...) + return exec.Command(run.containerManager.String(), cmd...) } func (run *RunDockerImage) GetEnv() map[string]string { @@ -147,7 +147,7 @@ func (image *DeleteDockerImage) GetCmd() *exec.Cmd { cmd = append(cmd, "image") cmd = append(cmd, "rm") cmd = append(cmd, image.imageTag) - return exec.Command(image.containerManager.String(), cmd[:]...) + return exec.Command(image.containerManager.String(), cmd...) } func (image *DeleteDockerImage) GetEnv() map[string]string { @@ -176,7 +176,7 @@ func (image *DeleteContainer) GetCmd() *exec.Cmd { cmd = append(cmd, "rm") cmd = append(cmd, "--force") cmd = append(cmd, image.containerName) - return exec.Command(image.containerManager.String(), cmd[:]...) + return exec.Command(image.containerManager.String(), cmd...) } func (image *DeleteContainer) GetEnv() map[string]string { diff --git a/main.go b/main.go index ddb09b4d8..8bf2d8e1c 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "golang.org/x/exp/slices" "os" "runtime" "sort" @@ -231,7 +232,7 @@ func getCommands() []cli.Command { return cisetupcommand.RunCiSetupCmd() }, }, - //{ + // { // Name: "invite", // Usage: invite.GetDescription(), // HelpName: corecommon.CreateUsage("invite", invite.GetDescription(), invite.Usage), @@ -241,24 +242,20 @@ func getCommands() []cli.Command { // Action: func(c *cli.Context) error { // return invitecommand.RunInviteCmd(c) // }, - //}, + // }, { Name: "setup", HideHelp: true, Hidden: true, Flags: cliutils.GetCommandFlags(cliutils.Setup), - Action: func(c *cli.Context) error { - return SetupCmd(c) - }, + Action: SetupCmd, }, { Name: "intro", HideHelp: true, Hidden: true, Flags: cliutils.GetCommandFlags(cliutils.Intro), - Action: func(*cli.Context) error { - return IntroCmd() - }, + Action: IntroCmd, }, { Name: cliutils.CmdOptions, @@ -269,7 +266,7 @@ func getCommands() []cli.Command { }, }, } - allCommands := append(cliNameSpaces, utils.GetPlugins()...) + allCommands := append(slices.Clone(cliNameSpaces), utils.GetPlugins()...) allCommands = append(allCommands, scan.GetCommands()...) allCommands = append(allCommands, buildtools.GetCommands()...) return append(allCommands, buildtools.GetBuildToolsHelpCommands()...) diff --git a/missioncontrol/cli.go b/missioncontrol/cli.go index ed7c22458..4e7a6341a 100644 --- a/missioncontrol/cli.go +++ b/missioncontrol/cli.go @@ -31,9 +31,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), Aliases: []string{"la"}, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return licenseAcquire(c) - }, + Action: licenseAcquire, }, { Name: "license-deploy", @@ -44,9 +42,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), Aliases: []string{"ld"}, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return licenseDeploy(c) - }, + Action: licenseDeploy, }, { Name: "license-release", @@ -57,9 +53,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), Aliases: []string{"lr"}, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return licenseRelease(c) - }, + Action: licenseRelease, }, { Name: "jpd-add", @@ -70,9 +64,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), Aliases: []string{"ja"}, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return jpdAdd(c) - }, + Action: jpdAdd, }, { Name: "jpd-delete", @@ -83,9 +75,7 @@ func GetCommands() []cli.Command { ArgsUsage: common.CreateEnvVars(), Aliases: []string{"jd"}, BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return jpdDelete(c) - }, + Action: jpdDelete, }, }) } diff --git a/nuget_test.go b/nuget_test.go index 446ee82a0..b77f106b5 100644 --- a/nuget_test.go +++ b/nuget_test.go @@ -15,6 +15,7 @@ import ( clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "golang.org/x/exp/slices" "os" "path/filepath" "strconv" @@ -62,7 +63,7 @@ func TestDotnetResolve(t *testing.T) { func testNativeNugetDotnetResolve(t *testing.T, uniqueTests []testDescriptor, buildName string, projectType utils.ProjectType) { initNugetTest(t) - testDescriptors := append(uniqueTests, []testDescriptor{ + testDescriptors := append(slices.Clone(uniqueTests), []testDescriptor{ {"referencewithoutmodulechnage", "reference", []string{projectType.String(), "restore"}, []string{"reference"}, []int{6}}, {"referencewithmodulechnage", "reference", []string{projectType.String(), "restore", "--module=" + ModuleNameJFrogTest}, []string{ModuleNameJFrogTest}, []int{6}}, {"multireferencewithoutmodulechnage", "multireference", []string{projectType.String(), "restore"}, []string{"proj1", "proj2"}, []int{5, 3}}, diff --git a/pipelines/cli.go b/pipelines/cli.go index d01011e1c..b9c539250 100644 --- a/pipelines/cli.go +++ b/pipelines/cli.go @@ -29,9 +29,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("pl status", status.GetDescription(), status.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return fetchLatestPipelineRunStatus(c) - }, + Action: fetchLatestPipelineRunStatus, }, { Name: "trigger", @@ -42,9 +40,7 @@ func GetCommands() []cli.Command { UsageText: trigger.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return triggerNewRun(c) - }, + Action: triggerNewRun, }, { Name: "version", @@ -53,9 +49,7 @@ func GetCommands() []cli.Command { Usage: version.GetDescription(), HelpName: corecommon.CreateUsage("pl version", version.GetDescription(), version.Usage), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return getVersion(c) - }, + Action: getVersion, }, { Name: "sync", @@ -66,9 +60,7 @@ func GetCommands() []cli.Command { UsageText: sync.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return syncPipelineResources(c) - }, + Action: syncPipelineResources, }, { Name: "sync-status", @@ -78,9 +70,7 @@ func GetCommands() []cli.Command { HelpName: corecommon.CreateUsage("pl sync-status", syncstatus.GetDescription(), syncstatus.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return getSyncPipelineResourcesStatus(c) - }, + Action: getSyncPipelineResourcesStatus, }, }) } diff --git a/plugins/cli.go b/plugins/cli.go index 040027990..ae1842e4e 100644 --- a/plugins/cli.go +++ b/plugins/cli.go @@ -21,9 +21,7 @@ func GetCommands() []cli.Command { UsageText: installdocs.GetArguments(), ArgsUsage: common.CreateEnvVars(installdocs.EnvVar...), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return commands.InstallCmd(c) - }, + Action: commands.InstallCmd, }, { Name: "uninstall", @@ -33,9 +31,7 @@ func GetCommands() []cli.Command { UsageText: uninstalldocs.GetArguments(), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return commands.UninstallCmd(c) - }, + Action: commands.UninstallCmd, }, { Name: "publish", @@ -45,9 +41,7 @@ func GetCommands() []cli.Command { UsageText: publishdocs.GetArguments(), ArgsUsage: common.CreateEnvVars(publishdocs.EnvVar...), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: func(c *cli.Context) error { - return commands.PublishCmd(c) - }, + Action: commands.PublishCmd, }, }) } diff --git a/plugins_test.go b/plugins_test.go index c1cd56828..83e51eb77 100644 --- a/plugins_test.go +++ b/plugins_test.go @@ -49,13 +49,13 @@ func TestPluginInstallUninstallOfficialRegistry(t *testing.T) { jfrogCli := tests.NewJfrogCli(execMain, "jfrog", "") // Try installing a plugin with specific version. - err = installAndAssertPlugin(t, jfrogCli, officialPluginForTest, officialPluginVersion) + err = installAndAssertPlugin(t, jfrogCli, officialPluginVersion) if err != nil { return } // Try installing the latest version of the plugin. Also verifies replacement was successful. - err = installAndAssertPlugin(t, jfrogCli, officialPluginForTest, "") + err = installAndAssertPlugin(t, jfrogCli, "") if err != nil { return } @@ -99,21 +99,21 @@ func TestPluginInstallWithProgressBar(t *testing.T) { jfrogCli := tests.NewJfrogCli(execMain, "jfrog", "") // Try installing a plugin with specific version. - err = installAndAssertPlugin(t, jfrogCli, officialPluginForTest, officialPluginVersion) + err = installAndAssertPlugin(t, jfrogCli, officialPluginVersion) if err != nil { return } // Try installing the latest version of the plugin. Also verifies replacement was successful. - err = installAndAssertPlugin(t, jfrogCli, officialPluginForTest, "") + err = installAndAssertPlugin(t, jfrogCli, "") if err != nil { return } } -func installAndAssertPlugin(t *testing.T, jfrogCli *tests.JfrogCli, pluginName, pluginVersion string) error { +func installAndAssertPlugin(t *testing.T, jfrogCli *tests.JfrogCli, pluginVersion string) error { // If version required, concat to plugin name - identifier := pluginName + identifier := officialPluginForTest if pluginVersion != "" { identifier += "@" + pluginVersion } @@ -124,7 +124,7 @@ func installAndAssertPlugin(t *testing.T, jfrogCli *tests.JfrogCli, pluginName, assert.NoError(t, err) return err } - err = verifyPluginInPluginsDir(t, pluginName, true, false) + err = verifyPluginInPluginsDir(t, officialPluginForTest, true, false) if err != nil { return err } diff --git a/scan/cli.go b/scan/cli.go index 115e619d0..a407a0519 100644 --- a/scan/cli.go +++ b/scan/cli.go @@ -182,12 +182,11 @@ func AuditCmd(c *cli.Context) error { allTechnologies := coreutils.GetAllTechnologiesList() technologies := []string{} for _, tech := range allTechnologies { - techExists := false - switch tech { - case coreutils.Maven: + var techExists bool + if tech == coreutils.Maven { // On Maven we use '--mvn' flag techExists = c.Bool("mvn") - default: + } else { techExists = c.Bool(tech.ToString()) } if techExists { @@ -215,7 +214,7 @@ func CurationCmd(c *cli.Context) error { return err } curationAuditCommand := curation.NewCurationAuditCommand(). - SetWorkingDirs(splitAndTrim(c.String("working-dirs"), ",")). + SetWorkingDirs(splitByCommaAndTrim(c.String("working-dirs"))). SetParallelRequests(threads) serverDetails, err := cliutils.CreateServerDetailsWithConfigOffer(c, true, "rt") @@ -264,11 +263,11 @@ func createGenericAuditCmd(c *cli.Context) (*audit.GenericAuditCommand, error) { SetFixableOnly(c.Bool(cliutils.FixableOnly)) if c.String("watches") != "" { - auditCmd.SetWatches(splitAndTrim(c.String("watches"), ",")) + auditCmd.SetWatches(splitByCommaAndTrim(c.String("watches"))) } if c.String("working-dirs") != "" { - auditCmd.SetWorkingDirs(splitAndTrim(c.String("working-dirs"), ",")) + auditCmd.SetWorkingDirs(splitByCommaAndTrim(c.String("working-dirs"))) } auditCmd.SetServerDetails(serverDetails). SetExcludeTestDependencies(c.Bool(cliutils.ExcludeTestDeps)). @@ -295,11 +294,11 @@ func ScanCmd(c *cli.Context) error { var specFile *spec.SpecFiles if c.IsSet("spec") { specFile, err = cliutils.GetFileSystemSpec(c) + if err != nil { + return err + } } else { - specFile, err = createDefaultScanSpec(c, addTrailingSlashToRepoPathIfNeeded(c)) - } - if err != nil { - return err + specFile = createDefaultScanSpec(c, addTrailingSlashToRepoPathIfNeeded(c)) } err = spec.ValidateSpec(specFile.Files, false, false) if err != nil { @@ -332,7 +331,7 @@ func ScanCmd(c *cli.Context) error { SetFixableOnly(c.Bool(cliutils.FixableOnly)). SetMinSeverityFilter(minSeverity) if c.String("watches") != "" { - scanCmd.SetWatches(splitAndTrim(c.String("watches"), ",")) + scanCmd.SetWatches(splitByCommaAndTrim(c.String("watches"))) } return commands.Exec(scanCmd) } @@ -410,7 +409,7 @@ func DockerScan(c *cli.Context, image string) error { SetFixableOnly(c.Bool(cliutils.FixableOnly)). SetMinSeverityFilter(minSeverity) if c.String("watches") != "" { - containerScanCommand.SetWatches(splitAndTrim(c.String("watches"), ",")) + containerScanCommand.SetWatches(splitByCommaAndTrim(c.String("watches"))) } return progressbar.ExecWithProgress(containerScanCommand) } @@ -424,7 +423,7 @@ func addTrailingSlashToRepoPathIfNeeded(c *cli.Context) string { return repoPath } -func createDefaultScanSpec(c *cli.Context, defaultTarget string) (*spec.SpecFiles, error) { +func createDefaultScanSpec(c *cli.Context, defaultTarget string) *spec.SpecFiles { return spec.NewBuilder(). Pattern(c.Args().Get(0)). Target(defaultTarget). @@ -433,7 +432,7 @@ func createDefaultScanSpec(c *cli.Context, defaultTarget string) (*spec.SpecFile Regexp(c.Bool("regexp")). Ant(c.Bool("ant")). IncludeDirs(c.Bool("include-dirs")). - BuildSpec(), nil + BuildSpec() } func createServerDetailsWithConfigOffer(c *cli.Context) (*coreconfig.ServerDetails, error) { @@ -466,8 +465,8 @@ func isProjectProvided(c *cli.Context) bool { return c.String("project") != "" || os.Getenv(coreutils.Project) != "" } -func splitAndTrim(paramValue, separator string) (res []string) { - args := strings.Split(paramValue, separator) +func splitByCommaAndTrim(paramValue string) (res []string) { + args := strings.Split(paramValue, ",") res = make([]string, len(args)) for i, arg := range args { res[i] = strings.TrimSpace(arg) diff --git a/transfer_test.go b/transfer_test.go index f3334ae53..bfae8a364 100644 --- a/transfer_test.go +++ b/transfer_test.go @@ -489,12 +489,12 @@ func updateDockerRepoParams(t *testing.T, targetServicesManager artifactory.Arti params.AllowAnyHostAuth = inverseBooleanPointer(params.AllowAnyHostAuth) params.EnableCookieManagement = inverseBooleanPointer(params.EnableCookieManagement) params.BypassHeadRequests = inverseBooleanPointer(params.BypassHeadRequests) - params.SocketTimeoutMillis = params.SocketTimeoutMillis + 100 - params.RetrievalCachePeriodSecs = params.RetrievalCachePeriodSecs + 100 - params.MetadataRetrievalTimeoutSecs = params.MetadataRetrievalTimeoutSecs + 100 - params.MissedRetrievalCachePeriodSecs = params.MissedRetrievalCachePeriodSecs + 100 - params.UnusedArtifactsCleanupPeriodHours = params.UnusedArtifactsCleanupPeriodHours + 100 - params.AssumedOfflinePeriodSecs = params.AssumedOfflinePeriodSecs + 100 + params.SocketTimeoutMillis += 100 + params.RetrievalCachePeriodSecs += 100 + params.MetadataRetrievalTimeoutSecs += 100 + params.MissedRetrievalCachePeriodSecs += 100 + params.UnusedArtifactsCleanupPeriodHours += 100 + params.AssumedOfflinePeriodSecs += 100 params.Username = "test123" params.ContentSynchronisation.Enabled = inverseBooleanPointer(params.ContentSynchronisation.Enabled) @@ -570,6 +570,6 @@ func updateProjectParams(t *testing.T, projectParams *accessServices.Project, ta projectParams.Description = "123123123123" projectParams.AdminPrivileges.IndexResources = &trueValue projectParams.SoftLimit = &trueValue - projectParams.StorageQuotaBytes = projectParams.StorageQuotaBytes + 1 + projectParams.StorageQuotaBytes += 1 assert.NoError(t, targetAccessManager.UpdateProject(accessServices.ProjectParams{ProjectDetails: *projectParams})) } diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index 41fb661d8..887af601b 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -821,9 +821,6 @@ func shouldCheckLatestCliVersion() (shouldCheck bool, err error) { func getLatestCliVersionFromGithubAPI() (githubVersionInfo githubResponse, err error) { client := &http.Client{Timeout: time.Second * 2} - if errorutils.CheckError(err) != nil { - return - } req, err := http.NewRequest(http.MethodGet, "https://api.github.com/repos/jfrog/jfrog-cli/releases/latest", nil) if errorutils.CheckError(err) != nil { return diff --git a/utils/progressbar/filesprogressbar.go b/utils/progressbar/filesprogressbar.go index 57997bedc..5046c7058 100644 --- a/utils/progressbar/filesprogressbar.go +++ b/utils/progressbar/filesprogressbar.go @@ -69,7 +69,7 @@ func (p *filesProgressBarManager) NewProgressReader(total int64, label, path str p.barsRWMutex.Lock() defer p.barsRWMutex.Unlock() p.barsWg.Add(1) - newBar := p.container.New(int64(total), + newBar := p.container.New(total, mpb.BarStyle().Lbound("|").Filler("🟩").Tip("🟩").Padding("⬛").Refiller("").Rbound("|"), mpb.BarRemoveOnComplete(), mpb.AppendDecorators( @@ -89,8 +89,7 @@ func (p *filesProgressBarManager) NewProgressReader(total int64, label, path str // Changes progress indicator state and acts accordingly. func (p *filesProgressBarManager) SetProgressState(id int, state string) { - switch state { - case "Merging": + if state == "Merging" { p.addNewMergingSpinner(id) } } diff --git a/utils/progressbar/readerprogressbar.go b/utils/progressbar/readerprogressbar.go index e44cab22b..19f396794 100644 --- a/utils/progressbar/readerprogressbar.go +++ b/utils/progressbar/readerprogressbar.go @@ -27,6 +27,7 @@ func (p *ReaderProgressBar) Abort() { } // GetId Returns the ProgressBar ID +//nolint:gocritic func (p *ReaderProgressBar) GetId() (Id int) { return p.Id } diff --git a/utils/progressbar/simpleprogressbar.go b/utils/progressbar/simpleprogressbar.go index 7387265bd..85e816306 100644 --- a/utils/progressbar/simpleprogressbar.go +++ b/utils/progressbar/simpleprogressbar.go @@ -9,7 +9,7 @@ type SimpleProgressBar struct { Id int } -// Usesd to update the progress bar progress. +// Used to update the progress bar progress. func (p *SimpleProgressBar) ActionWithProgress(reader io.Reader) (results io.Reader) { p.bar.Increment() return nil @@ -21,6 +21,7 @@ func (p *SimpleProgressBar) Abort() { } // GetId Returns the ProgressBar ID +//nolint:gocritic func (p *SimpleProgressBar) GetId() (Id int) { return p.Id } diff --git a/utils/summary/summary.go b/utils/summary/summary.go index c7a7624a1..bb9207d2b 100644 --- a/utils/summary/summary.go +++ b/utils/summary/summary.go @@ -79,9 +79,7 @@ func (bis *BuildInfoSummary) AddSha256(sha256Str string) { func GetSummaryReport(success, failed int, failNoOp bool, err error) *Summary { summary := &Summary{Totals: &Totals{}} - if err != nil || failed > 0 { - summary.Status = Failure - } else if success == 0 && failNoOp { + if err != nil || failed > 0 || (success == 0 && failNoOp) { summary.Status = Failure } else { summary.Status = Success diff --git a/utils/tests/consts.go b/utils/tests/consts.go index 7e13132e6..23c5202c9 100644 --- a/utils/tests/consts.go +++ b/utils/tests/consts.go @@ -1910,7 +1910,7 @@ func GetUploadedFileWithDownloadedPlaceHolder() []string { func GetFileWithDownloadedPlaceHolder() []string { return []string{ - filepath.Join(Out), + Out, filepath.Join(Out, "mypath2"), filepath.Join(Out, "mypath2", "b1.in"), filepath.Join(Out, "mypath2", "b2.in"), @@ -1932,7 +1932,7 @@ func GetUploadedFileWithDownloadedDoublePlaceHolder() []string { func GetFileWithDownloadedDoublePlaceHolder() []string { return []string{ - filepath.Join(Out), + Out, filepath.Join(Out, "mypath2"), filepath.Join(Out, "mypath2", "c"), filepath.Join(Out, "mypath2", "c", "c1.in"), @@ -1954,7 +1954,7 @@ func GetUploadedFileWithDownloadedPlaceHolderlashSlashSuffix() []string { func GetFileWithDownloadedPlaceHolderSlashSuffix() []string { return []string{ - filepath.Join(Out), + Out, filepath.Join(Out, "mypath2"), filepath.Join(Out, "mypath2", "b1.in"), filepath.Join(Out, "mypath2", "b2.in"), @@ -1972,12 +1972,12 @@ func GetFileWithDownloadedPlaceHolderSlashSuffix() []string { } } -func GetExpectedUploadSummaryDetails(RtUrl string) []clientutils.FileTransferDetails { +func GetExpectedUploadSummaryDetails(rtUrl string) []clientutils.FileTransferDetails { path1, path2, path3 := filepath.Join("testdata", "a", "a1.in"), filepath.Join("testdata", "a", "a2.in"), filepath.Join("testdata", "a", "a3.in") return []clientutils.FileTransferDetails{ - {SourcePath: path1, RtUrl: RtUrl, TargetPath: RtRepo1 + "/testdata/a/a1.in", Sha256: "4eb341b5d2762a853d79cc25e622aa8b978eb6e12c3259e2d99dc9dc60d82c5d"}, - {SourcePath: path2, RtUrl: RtUrl, TargetPath: RtRepo1 + "/testdata/a/a2.in", Sha256: "3e3deb6628658a48cf0d280a2210211f9d977ec2e10a4619b95d5fb85cb10450"}, - {SourcePath: path3, RtUrl: RtUrl, TargetPath: RtRepo1 + "/testdata/a/a3.in", Sha256: "14e3dc4749bf42df13a67a271065b0f334d0ad36bb34a74cc57c6e137f9af09e"}, + {SourcePath: path1, RtUrl: rtUrl, TargetPath: RtRepo1 + "/testdata/a/a1.in", Sha256: "4eb341b5d2762a853d79cc25e622aa8b978eb6e12c3259e2d99dc9dc60d82c5d"}, + {SourcePath: path2, RtUrl: rtUrl, TargetPath: RtRepo1 + "/testdata/a/a2.in", Sha256: "3e3deb6628658a48cf0d280a2210211f9d977ec2e10a4619b95d5fb85cb10450"}, + {SourcePath: path3, RtUrl: rtUrl, TargetPath: RtRepo1 + "/testdata/a/a3.in", Sha256: "14e3dc4749bf42df13a67a271065b0f334d0ad36bb34a74cc57c6e137f9af09e"}, } } diff --git a/utils/tests/container.go b/utils/tests/container.go index 7894cea76..05024b0f1 100644 --- a/utils/tests/container.go +++ b/utils/tests/container.go @@ -3,12 +3,10 @@ package tests import ( "context" "fmt" - "io" - "testing" - "github.com/jfrog/jfrog-client-go/utils/log" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" + "io" ) // When two containers are joined to the same network, one container is able to address another by using its name (as the hostname). @@ -55,14 +53,14 @@ func NewContainerRequest() *ContainerRequest { // rather than using a pre-built image. // This setter cannot be used with 'SetImage' to run a container.. // -// context - The path to the context of of the docker build +// context - The path to the context of the docker build // file - The path from the context to the Dockerfile for the image, defaults to "Dockerfile" // BuildArgs - Args to docker daemon -func (c *ContainerRequest) SetDockerfile(context, file string, BuildArgs map[string]*string) *ContainerRequest { +func (c *ContainerRequest) SetDockerfile(context, file string, buildArgs map[string]*string) *ContainerRequest { c.request.FromDockerfile = testcontainers.FromDockerfile{ Context: context, Dockerfile: file, - BuildArgs: BuildArgs, + BuildArgs: buildArgs, PrintBuildLog: true, } return c @@ -123,7 +121,7 @@ func (c *ContainerRequest) WaitFor(waitingFor wait.Strategy) *ContainerRequest { } // Creates a container based on container request parameters. -func (c *ContainerRequest) Build(ctx context.Context, t *testing.T, autoStart bool) (*TestContainer, error) { +func (c *ContainerRequest) Build(ctx context.Context, autoStart bool) (*TestContainer, error) { container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: c.request, Started: autoStart, diff --git a/utils/tests/proxy/server/server.go b/utils/tests/proxy/server/server.go index 308ae0930..2462e5d75 100644 --- a/utils/tests/proxy/server/server.go +++ b/utils/tests/proxy/server/server.go @@ -86,7 +86,7 @@ func copyHeaders(dst, src http.Header) { func httpProxyHandler(w http.ResponseWriter, r *http.Request) { if r.RequestURI == "/" { - w.WriteHeader(200) + w.WriteHeader(http.StatusOK) } else { removeProxyHeaders(r) t := &http.Transport{} @@ -118,7 +118,7 @@ type testProxy struct { func (t *testProxy) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) { if request.RequestURI == "/" { - responseWriter.WriteHeader(200) + responseWriter.WriteHeader(http.StatusOK) } else { host := request.URL.Host request.Host = "https://" + request.Host diff --git a/utils/tests/utils.go b/utils/tests/utils.go index bd16fa265..5f245f63e 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -605,7 +605,7 @@ func ReplaceTemplateVariables(path, destPath string) (string, error) { } for name, value := range getSubstitutionMap() { - content = bytes.Replace(content, []byte(name), []byte(value), -1) + content = bytes.ReplaceAll(content, []byte(name), []byte(value)) } if destPath == "" { destPath, err = os.Getwd() @@ -620,7 +620,7 @@ func ReplaceTemplateVariables(path, destPath string) (string, error) { } specPath := filepath.Join(destPath, filepath.Base(path)) log.Info("Creating spec file at:", specPath) - err = os.WriteFile(specPath, []byte(content), 0700) + err = os.WriteFile(specPath, content, 0700) if err != nil { return "", errorutils.CheckError(err) } diff --git a/xray_test.go b/xray_test.go index 0496b5d23..b469c9568 100644 --- a/xray_test.go +++ b/xray_test.go @@ -96,7 +96,7 @@ func TestXrayBinaryScanJson(t *testing.T) { func TestXrayBinaryScanSimpleJson(t *testing.T) { output := testXrayBinaryScan(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 1, 1) + verifySimpleJsonScanResults(t, output, 1, 1) } func TestXrayBinaryScanJsonWithProgress(t *testing.T) { @@ -110,7 +110,7 @@ func TestXrayBinaryScanSimpleJsonWithProgress(t *testing.T) { callback := tests.MockProgressInitialization() defer callback() output := testXrayBinaryScan(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 1, 1) + verifySimpleJsonScanResults(t, output, 1, 1) } func testXrayBinaryScan(t *testing.T, format string) string { @@ -144,7 +144,7 @@ func TestXrayAuditNpmJson(t *testing.T) { func TestXrayAuditNpmSimpleJson(t *testing.T) { output := testXrayAuditNpm(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 1, 1) + verifySimpleJsonScanResults(t, output, 1, 1) } func testXrayAuditNpm(t *testing.T, format string) string { @@ -173,7 +173,7 @@ func TestXrayAuditYarnJson(t *testing.T) { func TestXrayAuditYarnSimpleJson(t *testing.T) { testXrayAuditYarn(t, "yarn", func() { output := runXrayAuditYarnWithOutput(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 1, 1) + verifySimpleJsonScanResults(t, output, 1, 1) }) } @@ -212,7 +212,7 @@ func TestXrayAuditNugetJson(t *testing.T) { func TestXrayAuditNugetSimpleJson(t *testing.T) { output := testXrayAuditNuget(t, "single", string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 2, 0) + verifySimpleJsonScanResults(t, output, 2, 0) } // Tests NuGet audit by providing a multi-project NuGet project and asserts any error. @@ -244,7 +244,7 @@ func TestXrayAuditGradleJson(t *testing.T) { func TestXrayAuditGradleSimpleJson(t *testing.T) { output := testXrayAuditGradle(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 0, 0) + verifySimpleJsonScanResults(t, output, 0, 0) } func testXrayAuditGradle(t *testing.T, format string) string { @@ -268,7 +268,7 @@ func TestXrayAuditMavenJson(t *testing.T) { func TestXrayAuditMavenSimpleJson(t *testing.T) { output := testXrayAuditMaven(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 1, 1) + verifySimpleJsonScanResults(t, output, 1, 1) } func testXrayAuditMaven(t *testing.T, format string) string { @@ -323,7 +323,7 @@ func TestXrayAuditMultiProjects(t *testing.T) { assert.NoError(t, fileutils.CopyDir(multiProject, tempDirPath, true, nil)) workingDirsFlag := fmt.Sprintf("--working-dirs=%s, %s ,%s", filepath.Join(tempDirPath, "maven"), filepath.Join(tempDirPath, "nuget", "single"), filepath.Join(tempDirPath, "python", "pip")) output := xrayCli.RunCliCmdWithOutput(t, "audit", "--format="+string(utils.SimpleJson), workingDirsFlag) - verifySimpleJsonScanResults(t, output, 0, 0, 30, 0) + verifySimpleJsonScanResults(t, output, 30, 0) } func TestXrayAuditPipJson(t *testing.T) { @@ -333,7 +333,7 @@ func TestXrayAuditPipJson(t *testing.T) { func TestXrayAuditPipSimpleJson(t *testing.T) { output := testXrayAuditPip(t, string(utils.SimpleJson), "") - verifySimpleJsonScanResults(t, output, 0, 0, 3, 1) + verifySimpleJsonScanResults(t, output, 3, 1) } func TestXrayAuditPipJsonWithRequirementsFile(t *testing.T) { @@ -343,7 +343,7 @@ func TestXrayAuditPipJsonWithRequirementsFile(t *testing.T) { func TestXrayAuditPipSimpleJsonWithRequirementsFile(t *testing.T) { output := testXrayAuditPip(t, string(utils.SimpleJson), "requirements.txt") - verifySimpleJsonScanResults(t, output, 0, 0, 2, 0) + verifySimpleJsonScanResults(t, output, 2, 0) } func testXrayAuditPip(t *testing.T, format, requirementsFile string) string { @@ -372,7 +372,7 @@ func TestXrayAuditPipenvJson(t *testing.T) { func TestXrayAuditPipenvSimpleJson(t *testing.T) { output := testXrayAuditPipenv(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 3, 1) + verifySimpleJsonScanResults(t, output, 3, 1) } func testXrayAuditPipenv(t *testing.T, format string) string { @@ -434,7 +434,7 @@ func TestXrayAuditPoetryJson(t *testing.T) { func TestXrayAuditPoetrySimpleJson(t *testing.T) { output := testXrayAuditPoetry(t, string(utils.SimpleJson)) - verifySimpleJsonScanResults(t, output, 0, 0, 3, 1) + verifySimpleJsonScanResults(t, output, 3, 1) } func testXrayAuditPoetry(t *testing.T, format string) string { @@ -503,12 +503,10 @@ func verifyJsonScanResults(t *testing.T, content string, minViolations, minVulne } } -func verifySimpleJsonScanResults(t *testing.T, content string, minSecViolations, minLicViolations, minVulnerabilities, minLicenses int) { +func verifySimpleJsonScanResults(t *testing.T, content string, minVulnerabilities, minLicenses int) { var results formats.SimpleJsonResults err := json.Unmarshal([]byte(content), &results) if assert.NoError(t, err) { - assert.GreaterOrEqual(t, len(results.SecurityViolations), minSecViolations) - assert.GreaterOrEqual(t, len(results.LicensesViolations), minLicViolations) assert.GreaterOrEqual(t, len(results.Vulnerabilities), minVulnerabilities) assert.GreaterOrEqual(t, len(results.Licenses), minLicenses) } @@ -703,11 +701,13 @@ func TestCurationAudit(t *testing.T) { output := localXrayCli.RunCliCmdWithOutput(t, "curation-audit", "--format="+string(utils.Json), workingDirsFlag) expectedResp := getCurationExpectedResponse(config) var got []coreCuration.PackageStatus - err = json.Unmarshal([]byte(output[strings.Index(output, "["):]), &got) + bracketIndex := strings.Index(output, "[") + require.Less(t, 0, bracketIndex, "Unexpected Curation output with missing '['") + err = json.Unmarshal([]byte(output[bracketIndex:]), &got) assert.NoError(t, err) assert.Equal(t, expectedResp, got) for k, v := range expectedRequest { - assert.Truef(t, v, "didn't recieve expected GET request for packe url %s", k) + assert.Truef(t, v, "didn't receive expected GET request for package url %s", k) } } From e049aa0e3869787610b073091ecff110c836715c Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Sun, 18 Jun 2023 11:24:37 +0300 Subject: [PATCH 5/7] Update Go to 1.20.5 (#2032) --- Jenkinsfile | 2 +- build/docker/full/Dockerfile | 2 +- build/docker/slim/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b06ee2698..ec5c772ef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ node("docker") { repo = 'jfrog-cli' sh 'rm -rf temp' sh 'mkdir temp' - def goRoot = tool 'go-1.20.4' + def goRoot = tool 'go-1.20.5' env.GOROOT="$goRoot" env.PATH+=":${goRoot}/bin" env.GO111MODULE="on" diff --git a/build/docker/full/Dockerfile b/build/docker/full/Dockerfile index 76e3f5c69..6198ce57b 100644 --- a/build/docker/full/Dockerfile +++ b/build/docker/full/Dockerfile @@ -1,6 +1,6 @@ ARG repo_name_21 # Remove ${repo_name_21} to pull from Docker Hub. -FROM ${repo_name_21}/jfrog-docker/golang:1.20.4 as builder +FROM ${repo_name_21}/jfrog-docker/golang:1.20 as builder ARG image_name=jfrog-cli-full ARG cli_executable_name WORKDIR /${image_name} diff --git a/build/docker/slim/Dockerfile b/build/docker/slim/Dockerfile index b9d93b469..ae69bd4c7 100644 --- a/build/docker/slim/Dockerfile +++ b/build/docker/slim/Dockerfile @@ -1,6 +1,6 @@ ARG repo_name_21 # Remove ${repo_name_21} to pull from Docker Hub. -FROM ${repo_name_21}/jfrog-docker/golang:1.20.4-alpine as builder +FROM ${repo_name_21}/jfrog-docker/golang:1.20-alpine as builder ARG image_name=jfrog-cli ARG cli_executable_name WORKDIR /${image_name} From 65ed020a3d453e8723ab01c17c77e80d75069b03 Mon Sep 17 00:00:00 2001 From: Sara Omari <114062096+sarao1310@users.noreply.github.com> Date: Sun, 18 Jun 2023 22:02:55 +0300 Subject: [PATCH 6/7] Unreleased bug upload progress bar values (#2033) unreleased bug - fix upload progress bar values --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ce09de2c6..8ee26ff50 100644 --- a/go.mod +++ b/go.mod @@ -128,4 +128,4 @@ replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 -replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2 diff --git a/go.sum b/go.sum index 60006e5ce..31f1f4785 100644 --- a/go.sum +++ b/go.sum @@ -242,8 +242,8 @@ github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 h1:MvKxuFsgCeIL74qeXJ7Z6rbDO0tfE15M3D24U0kGgFs= github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01/go.mod h1:Kzh4oTlJu1iYFNQcgAHgKIMvsvgC5LN2DlV/NHWCXZM= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd h1:/X2eIts0BRy3Y6AhzBnM+8Dmrl0assoBFG1iyW6Jq8U= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230614081045-ef833fcb4fdd/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2 h1:DtWbIgT1XZqodzwlVuGKj60XeKfdhGxIVIKy2MgXkm4= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= From ec935850a1e67cecdef6163de6870f00fb49fbf1 Mon Sep 17 00:00:00 2001 From: Eyal Ben Moshe Date: Tue, 27 Jun 2023 21:12:22 +0300 Subject: [PATCH 7/7] Promote to version 2.41.0 (#2045) --- build/npm/v2-jf/package-lock.json | 2 +- build/npm/v2-jf/package.json | 2 +- build/npm/v2/package-lock.json | 2 +- build/npm/v2/package.json | 2 +- go.mod | 8 ++++---- go.sum | 10 ++++------ utils/cliutils/cli_consts.go | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/build/npm/v2-jf/package-lock.json b/build/npm/v2-jf/package-lock.json index 3ccfed708..aa6066ad8 100644 --- a/build/npm/v2-jf/package-lock.json +++ b/build/npm/v2-jf/package-lock.json @@ -1,5 +1,5 @@ { "name": "jfrog-cli-v2-jf", - "version": "2.40.0", + "version": "2.41.0", "lockfileVersion": 1 } diff --git a/build/npm/v2-jf/package.json b/build/npm/v2-jf/package.json index 4419ecaf0..c175df8ac 100644 --- a/build/npm/v2-jf/package.json +++ b/build/npm/v2-jf/package.json @@ -1,6 +1,6 @@ { "name": "jfrog-cli-v2-jf", - "version": "2.40.0", + "version": "2.41.0", "description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸", "homepage": "https://github.com/jfrog/jfrog-cli", "preferGlobal": true, diff --git a/build/npm/v2/package-lock.json b/build/npm/v2/package-lock.json index 21d8687c0..931857fc7 100644 --- a/build/npm/v2/package-lock.json +++ b/build/npm/v2/package-lock.json @@ -1,5 +1,5 @@ { "name": "jfrog-cli-v2", - "version": "2.40.0", + "version": "2.41.0", "lockfileVersion": 1 } diff --git a/build/npm/v2/package.json b/build/npm/v2/package.json index bd5cba97f..482eb14d1 100644 --- a/build/npm/v2/package.json +++ b/build/npm/v2/package.json @@ -1,6 +1,6 @@ { "name": "jfrog-cli-v2", - "version": "2.40.0", + "version": "2.41.0", "description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸", "homepage": "https://github.com/jfrog/jfrog-cli", "preferGlobal": true, diff --git a/go.mod b/go.mod index 8ee26ff50..a15728c3f 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/gocarina/gocsv v0.0.0-20230406101422-6445c2b15027 github.com/jfrog/build-info-go v1.9.6 github.com/jfrog/gofrog v1.3.0 - github.com/jfrog/jfrog-cli-core/v2 v2.35.0 - github.com/jfrog/jfrog-client-go v1.30.0 + github.com/jfrog/jfrog-cli-core/v2 v2.36.1 + github.com/jfrog/jfrog-client-go v1.30.1 github.com/jszwec/csvutil v1.8.0 github.com/mholt/archiver/v3 v3.5.1 github.com/pkg/errors v0.9.1 @@ -124,8 +124,8 @@ require ( // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 +// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 -replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2 +// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2 diff --git a/go.sum b/go.sum index 31f1f4785..2671dc95b 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= @@ -240,10 +238,10 @@ github.com/jfrog/build-info-go v1.9.6 h1:lCJ2j5uXAlJsSwDe5J8WD7Co1f/hUlZvMfwfb5A github.com/jfrog/build-info-go v1.9.6/go.mod h1:GbuFS+viHCKZYx9nWHYu7ab1DgQkFdtVN3BJPUNb2D4= github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01 h1:MvKxuFsgCeIL74qeXJ7Z6rbDO0tfE15M3D24U0kGgFs= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230613104333-33061fa53a01/go.mod h1:Kzh4oTlJu1iYFNQcgAHgKIMvsvgC5LN2DlV/NHWCXZM= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2 h1:DtWbIgT1XZqodzwlVuGKj60XeKfdhGxIVIKy2MgXkm4= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230618140310-d7dc9bc462c2/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-cli-core/v2 v2.36.1 h1:O67ovxouqXYljE2Lo890ytM9fDiYsMCZJ8F/DHdSY7w= +github.com/jfrog/jfrog-cli-core/v2 v2.36.1/go.mod h1:Wvf/XWVcRSu1ZuloLOofkifuM8BLZZ2LiYYzmdUn80Y= +github.com/jfrog/jfrog-client-go v1.30.1 h1:wASYBrFkpWzQHTNnCIIfqpDLtQF5oNcwQK9rrv8I8AA= +github.com/jfrog/jfrog-client-go v1.30.1/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= diff --git a/utils/cliutils/cli_consts.go b/utils/cliutils/cli_consts.go index c8903a5aa..1bada4aa2 100644 --- a/utils/cliutils/cli_consts.go +++ b/utils/cliutils/cli_consts.go @@ -4,7 +4,7 @@ import "time" const ( // General CLI constants - CliVersion = "2.40.0" + CliVersion = "2.41.0" ClientAgent = "jfrog-cli-go" // CLI base commands constants: