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] 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,