From ef7f99c378d38ca4fe1502293e2e643302ad6017 Mon Sep 17 00:00:00 2001 From: Robi Nino Date: Thu, 13 Jul 2023 16:36:06 +0300 Subject: [PATCH 1/4] Respect project env var on build discard and promote (#2076) --- artifactory/cli.go | 16 ++++++++-------- buildtools/cli.go | 8 +------- utils/cliutils/utils.go | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/artifactory/cli.go b/artifactory/cli.go index 11e7474c2..065205971 100644 --- a/artifactory/cli.go +++ b/artifactory/cli.go @@ -1029,7 +1029,7 @@ func containerPushCmd(c *cli.Context, containerManagerType containerutils.Contai targetRepo := c.Args().Get(1) skipLogin := c.Bool("skip-login") - buildConfiguration, err := buildtools.CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return } @@ -1064,7 +1064,7 @@ func containerPullCmd(c *cli.Context, containerManagerType containerutils.Contai imageTag := c.Args().Get(0) sourceRepo := c.Args().Get(1) skipLogin := c.Bool("skip-login") - buildConfiguration, err := buildtools.CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return err } @@ -1090,7 +1090,7 @@ func BuildDockerCreateCmd(c *cli.Context) error { if imageNameWithDigestFile == "" { return cliutils.PrintHelpAndReturnError("The '--image-file' command option was not provided.", c) } - buildConfiguration, err := buildtools.CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return err } @@ -1217,7 +1217,7 @@ func downloadCmd(c *cli.Context) error { if err != nil { return err } - buildConfiguration, err := buildtools.CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return err } @@ -1274,7 +1274,7 @@ func uploadCmd(c *cli.Context) (err error) { if err != nil { return } - buildConfiguration, err := buildtools.CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return } @@ -1298,7 +1298,7 @@ func uploadCmd(c *cli.Context) (err error) { "You can avoid this confirmation message by adding --quiet to the command.", false) { return nil } - // This error is being checked latter on because we need to generate summary report before return. + // This error is being checked later on because we need to generate summary report before return. err = progressbar.ExecWithProgress(uploadCmd) result := uploadCmd.Result() defer cliutils.CleanupResult(result, &err) @@ -2529,7 +2529,7 @@ func createBuildPromoteConfiguration(c *cli.Context) services.PromotionParams { promotionParamsImpl.IncludeDependencies = c.Bool("include-dependencies") promotionParamsImpl.Copy = c.Bool("copy") promotionParamsImpl.Properties = c.String("props") - promotionParamsImpl.ProjectKey = c.String("project") + promotionParamsImpl.ProjectKey = cliutils.GetProject(c) promotionParamsImpl.FailFast = c.BoolT("fail-fast") // If the command received 3 args, read the build name, build number @@ -2554,7 +2554,7 @@ func createBuildDiscardConfiguration(c *cli.Context) services.DiscardBuildsParam discardParamsImpl.ExcludeBuilds = c.String("exclude-builds") discardParamsImpl.Async = c.Bool("async") discardParamsImpl.BuildName = cliutils.GetBuildName(c.Args().Get(0)) - discardParamsImpl.ProjectKey = c.String("project") + discardParamsImpl.ProjectKey = cliutils.GetProject(c) return discardParamsImpl } diff --git a/buildtools/cli.go b/buildtools/cli.go index 4d1f9762d..ce2c438ea 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -629,7 +629,7 @@ func GoPublishCmd(c *cli.Context) (err error) { if err != nil { return err } - buildConfiguration, err := CreateBuildConfigurationWithModule(c) + buildConfiguration, err := cliutils.CreateBuildConfigurationWithModule(c) if err != nil { return err } @@ -663,12 +663,6 @@ func goCmdVerification(c *cli.Context) (string, error) { return configFilePath, nil } -func CreateBuildConfigurationWithModule(c *cli.Context) (buildConfigConfiguration *utils.BuildConfiguration, err error) { - buildConfigConfiguration = new(utils.BuildConfiguration) - err = buildConfigConfiguration.SetBuildName(c.String("build-name")).SetBuildNumber(c.String("build-number")).SetProject(c.String("project")).SetModule(c.String("module")).ValidateBuildAndModuleParams() - return -} - func dockerCmd(c *cli.Context) error { args := cliutils.ExtractCommand(c) var cmd, image string diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index ffcfe7558..daae7887b 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -725,7 +725,8 @@ func SetCliExecutableName(executablePath string) { coreutils.SetCliExecutableName(filepath.Base(executablePath)) } -// Returns build configuration struct using the params provided from the console. +// Returns build configuration struct using the args (build name/number) and options (project) provided by the user. +// Any empty configuration could be later overridden by environment variables if set. func CreateBuildConfiguration(c *cli.Context) *artifactoryUtils.BuildConfiguration { buildConfiguration := new(artifactoryUtils.BuildConfiguration) buildNameArg, buildNumberArg := c.Args().Get(0), c.Args().Get(1) @@ -737,6 +738,15 @@ func CreateBuildConfiguration(c *cli.Context) *artifactoryUtils.BuildConfigurati return buildConfiguration } +// Returns build configuration struct using the options provided by the user. +// Any empty configuration could be later overridden by environment variables if set. +func CreateBuildConfigurationWithModule(c *cli.Context) (buildConfigConfiguration *artifactoryUtils.BuildConfiguration, err error) { + buildConfigConfiguration = new(artifactoryUtils.BuildConfiguration) + err = buildConfigConfiguration.SetBuildName(c.String("build-name")).SetBuildNumber(c.String("build-number")). + SetProject(c.String("project")).SetModule(c.String("module")).ValidateBuildAndModuleParams() + return +} + func CreateArtifactoryDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, error) { artDetails, err := CreateServerDetailsWithConfigOffer(c, false, Rt) if err != nil { @@ -860,8 +870,5 @@ func doHttpRequest(client *http.Client, req *http.Request) (resp *http.Response, // Get project key from flag or environment variable func GetProject(c *cli.Context) string { projectKey := c.String("project") - if projectKey == "" { - projectKey = os.Getenv(coreutils.Project) - } - return projectKey + return getOrDefaultEnv(projectKey, coreutils.Project) } From 95f6f4a8eae424f894c413887363c7d855f010c9 Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Fri, 14 Jul 2023 18:29:20 +0300 Subject: [PATCH 2/4] Add CONTRIBUTING.md (#2078) --- .github/PULL_REQUEST_TEMPLATE.md | 11 +- CONTRIBUTING.md | 297 ++++++++++++++++++++++++++++ README.md | 321 +------------------------------ 3 files changed, 305 insertions(+), 324 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f10575440..cca3d0c4e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,6 @@ -- [ ] All [tests](https://github.com/jfrog/jfrog-cli#tests) passed. If this feature is not already covered by the tests, I added new tests. -- [ ] All [static analysis checks](https://github.com/jfrog/jfrog-cli/actions/workflows/analysis.yml) passed. -- [ ] This pull request is on the dev branch. -- [ ] I used gofmt for formatting the code before submitting the pull request. ------ +- [ ] All [tests](https://github.com/jfrog/jfrog-cli/CONTRIBUTING.md#tests) have passed. If this feature is not already covered by the tests, new tests have been added. +- [ ] The pull request is targeting the `dev` branch. +- [ ] The code has been validated to compile successfully by running `go vet ./...`. +- [ ] The code has been formatted properly using `go fmt ./...`. + +--- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..d9bd3949d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,297 @@ +# 📖 Guidelines + +- Ensure that your changes are covered by existing tests. If not, please add new tests. +- Create pull requests on the `dev` branch. +- Before submitting the pull request, format the code by running `go fmt ./...`. +- Before submitting the pull request, ensure the code compiles by running `go vet ./...`. + +# ⚒️ Building and Testing the Sources + +## Building JFrog CLI + +To build JFrog CLI, first, make sure Go is installed by running the following command: + +```sh +go version +``` + +Next, clone the project sources and navigate to the root directory: + +```sh +git clone https://github.com/jfrog/jfrog-cli.git +cd jfrog-cli +``` + +To build the sources on Unix-based systems, run: + +```sh +./build/build.sh +``` + +On Windows, run: + +```sh +.\build\build.bat +``` + +After the build process completes, you will find the `jf` or `jf.exe` executable in the current directory. + +### Dependencies in other JFrog modules + +This project heavily depends on the following modules: + +- [github.com/jfrog/jfrog-client-go](https://github.com/jfrog/jfrog-client-go) +- [github.com/jfrog/jfrog-cli-core](github.com/jfrog/jfrog-cli-core) +- [github.com/jfrog/build-info-go](github.com/jfrog/build-info-go) +- [github.com/jfrog/gofrog](github.com/jfrog/gofrog) + +#### Local Development + +During local development, if you come across code that needs to be modified in one of the mentioned modules, it is advisable to replace the dependency with a local clone of the module. + +For instance, let's assume you wish to modify files from `jfrog-cli-core`. Clone the `jfrog-cli-core` repository (preferably your fork) to your local development machine, placing it at `/local/path/in/your/machine/jfrog-cli-core`. + +To include this local dependency, modify the `go.mod` file as follows: + +``` +replace github.com/jfrog/jfrog-cli-core/v2 => /local/path/in/your/machine/jfrog-cli-core +``` + +Afterward, execute `go mod tidy` to ensure the Go module files are updated. Note that Go will automatically adjust the version in the `go.mod` file. + +#### Pull Requests + +Once you have completed your coding changes, it is recommended to push the modifications made to the other modules first. Once these changes are pushed, you can update this project to resolve dependencies from your GitHub fork or branch. To achieve this, modify the `go.mod` file to point the dependency to your repository and branch, as shown in the example below: + +``` +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/galusben/jfrog-cli-core/v2 dev +``` + +Finally, execute `go mod tidy` to update the Go module files. Please note that Go will automatically update the version in the `go.mod` file. + +## Tests + +### Usage + +To run tests, use the following command: + +``` +go test -v github.com/jfrog/jfrog-cli [test-types] [flags] +``` + +The available flags are: + +| Flag | Description | +| ------------------- | ----------------------------------------------------------------------------------------------- | +| `-jfrog.url` | [Default: http://localhost:8081] JFrog platform URL | +| `-jfrog.user` | [Default: admin] JFrog platform username | +| `-jfrog.password` | [Default: password] JFrog platform password | +| `-jfrog.adminToken` | [Optional] JFrog platform admin token | +| `-ci.runId` | [Optional] A unique identifier used as a suffix to create repositories and builds in the tests. | + +The available test types are: + +| Type | Description | +| -------------------- | ------------------ | +| `-test.artifactory` | Artifactory tests | +| `-test.access` | Access tests | +| `-test.npm` | Npm tests | +| `-test.maven` | Maven tests | +| `-test.gradle` | Gradle tests | +| `-test.docker` | Docker tests | +| `-test.dockerScan` | Docker scan tests | +| `-test.podman` | Podman tests | +| `-test.go` | Go tests | +| `-test.pip` | Pip tests | +| `-test.pipenv` | Pipenv tests | +| `-test.poetry` | Poetry tests | +| `-test.nuget` | Nuget tests | +| `-test.plugins` | Plugins tests | +| `-test.distribution` | Distribution tests | +| `-test.transfer` | Transfer tests | +| `-test.xray` | Xray tests | + +When running the tests, builds and repositories with timestamps will be created, for example: `cli-rt1-1592990748` and `cli-rt2-1592990748`. The content of these repositories will be deleted once the tests are completed. + +#### Artifactory tests + +In addition to the [general optional flags](#Usage), you can use the following optional Artifactory flags: + +| Flag | Description | +| ---------------------- | --------------------------------------------------------------------------------------------------------------- | +| `-jfrog.sshKeyPath` | [Optional] Path to the SSH key file. Use this flag only if the Artifactory URL format is `ssh://[domain]:port`. | +| `-jfrog.sshPassphrase` | [Optional] Passphrase for the SSH key. | + +##### Examples + +To run Artifactory tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.artifactory [flags] +``` + +#### Npm tests + +##### Requirements + +- The _npm_ executables should be included in the system's `PATH` environment variable. +- The tests are compatible with npm 7 and higher. + +##### Limitations + +- Currently, npm integration only supports HTTP(S) connections to Artifactory using username and password. + +##### Examples + +To run Npm tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.npm [flags] +``` + +#### Maven tests + +##### Requirements + +- The _java_ executable should be included in the system's `PATH` environment variable. Alternatively, set the `_JAVA_HOME` environment variable. + +##### Limitations + +- Currently, Maven integration only supports HTTP(S) connections to Artifactory using username and password. + +##### Examples + +To run Maven tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.maven [flags] +``` + +#### Gradle tests + +##### Requirements + +- The _gradle_ and _java_ executables should be included in the system's `PATH` environment variable. Alternatively, set the `JAVA_HOME` environment variable. + +##### Limitations + +- Currently, Gradle integration only supports HTTP(S) connections to Artifactory using username and password. + +##### Examples + +To run Gradle tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.gradle [flags] +``` + +#### Docker tests + +##### Requirements + +- Make sure the `RTLIC` environment variable is configured with a valid license. +- You can start an Artifactory container by running the `startArtifactory.sh` script located in the `testdata/docker/artifactory` directory. Before running the tests, wait for Artifactory to finish booting up in the container. + +| Flag | Description | +| ------------------------- | ----------------------------------- | +| `-test.containerRegistry` | Artifactory Docker registry domain. | + +##### Examples + +To run Docker tests, execute the following command (replace the missing parameters as described below): + +``` +go test -v github.com/jfrog/jfrog-cli -test.docker [flags] +``` + +#### Podman tests + +| Flag | Description | +| ------------------------- | -------------------------------------- | +| `-test.containerRegistry` | Artifactory container registry domain. | + +##### Examples + +To run Podman tests, execute the following command (replace the missing parameters as described below): + +``` +go test -v github.com/jfrog/jfrog-cli -test.podman [flags] +``` + +#### Go commands tests + +##### + +Requirements + +- The tests are compatible with Artifactory 6.10 and higher. +- To run Go tests, use the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.go [flags] +``` + +#### NuGet tests + +##### Requirements + +- Add the NuGet executable to the system's `PATH` environment variable. +- Run the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.nuget [flags] +``` + +#### Pip tests + +##### Requirements + +- Add the Python and pip executables to the system's `PATH` environment variable. +- Run the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.pip [flags] +``` + +#### Plugins tests + +To run Plugins tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.plugins +``` + +#### Distribution tests + +To run Distribution tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.distribution [flags] +``` + +#### Transfer tests + +##### Requirement + +The Transfer tests execute `transfer-files` commands between a local Artifactory server and a remote SaaS instance. In addition to the [general optional flags](#Usage), you _must_ use the following flags: + +| Flag | Description | +| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `-jfrog.targetUrl` | JFrog target platform URL. | +| `-jfrog.targetAdminToken` | JFrog target platform admin token. | +| `-jfrog.jfrogHome` | The JFrog home directory of the local Artifactory installation. | +| `-jfrog.installDataTransferPlugin` | Set this flag to `true` if you want the test to automatically install the data-transfer plugin in the source Artifactory server. | + +To run Transfer tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.transfer [flags] +``` + +### Xray tests + +To run Xray tests, execute the following command: + +``` +go test -v github.com/jfrog/jfrog-cli -test.xray -test.dockerScan [flags] +``` diff --git a/README.md b/README.md index c6112be75..16955cb4e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/jfrog/jfrog-cli)](https://goreportcard.com/report/github.com/jfrog/jfrog-cli) [![license](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=flat)](https://raw.githubusercontent.com/jfrog/jfrog-cli/v2/LICENSE) [![](https://img.shields.io/badge/Docs-%F0%9F%93%96-blue)](https://www.jfrog.com/confluence/display/CLI/JFrog+CLI) [![Go version](https://img.shields.io/github/go-mod/go-version/jfrog/jfrog-cli)](https://tip.golang.org/doc/go1.20) +
@@ -235,8 +236,6 @@ - [Overview](#overview) - [Download and Installation](#download-and-installation) -- [Building the Executable](#building-the-executable) -- [Tests](#tests) - [Code Contributions](#code-contributions) - [Using JFrog CLI](#using-jfrog-cli) - [JFrog CLI Plugins](#jfrog-cli-plugins) @@ -260,325 +259,9 @@ Several features of the JFrog CLI makes your scripts more efficient and reliable You can either install JFrog CLI using one of the supported installers or download its executable directly. Visit the [Install JFrog CLI Page](https://jfrog.com/getcli/) for details. -# Building the Executable - -JFrog CLI is written in the [Go programming language](https://golang.org/), so to build the CLI yourself, you first need -to have Go installed and configured on your machine. - -## Install Go - -To download and install `Go`, please refer to the [Go documentation](https://golang.org/doc/install). -Please download `Go 1.14.x` or above. - -## Download and Build the CLI - -Navigate to a directory where you want to create the jfrog-cli project, **outside** the `$GOPATH` tree. - -If the `GOPATH` variable is unset, it's default value is the go folder under the user home. - -Verify that the `GO111MODULE` variable is either unset, or explicitly set to `auto`. - -Clone the jfrog-cli project by executing the following command: - -``` -git clone https://github.com/jfrog/jfrog-cli -``` - -Build the project by navigating to the jfrog folder and executing the following commands. -On Unix based systems run: - -``` -cd jfrog-cli -build/build.sh -``` - -On Windows run: - -``` -cd jfrog-cli -build\build.bat -``` - -Once completed, you will find the JFrog CLI executable at your current directory. - -# Tests - -### Usage - -``` -go test -v github.com/jfrog/jfrog-cli [test-types] [flags] -``` - -The flags are: - -| Flag | Description | -|---------------------|-------------------------------------------------------------------------------------------------| -| `-jfrog.url` | [Default: http://localhost:8081] JFrog platform URL. | -| `-jfrog.user` | [Default: admin] JFrog platform username. | -| `-jfrog.password` | [Default: password] JFrog platform password. | -| `-jfrog.adminToken` | [Optional] JFrog platform admin token. | -| `-ci.runId` | [Optional] A unique identifier used as a suffix to create repositories and builds in the tests. | - -The types are: - -| Type | Description | -|----------------------|--------------------| -| `-test.artifactory` | Artifactory tests | -| `-test.access` | Access tests | -| `-test.npm` | Npm tests | -| `-test.maven` | Maven tests | -| `-test.gradle` | Gradle tests | -| `-test.docker` | Docker tests | -| `-test.dockerScan` | Docker scan tests | -| `-test.podman` | Podman tests | -| `-test.go` | Go tests | -| `-test.pip` | Pip tests | -| `-test.pipenv` | Pipenv tests | -| `-test.poetry` | Poetry tests | -| `-test.nuget` | Nuget tests | -| `-test.plugins` | Plugins tests | -| `-test.distribution` | Distribution tests | -| `-test.transfer` | Transfer tests | -| `-test.xray` | Xray tests | - -- Running the tests will create builds and repositories with timestamps, - for example: `cli-rt1-1592990748` and `cli-rt2-1592990748`.
- Once the tests are completed, the content of these repositories will be deleted. - -#### Artifactory tests - -In addition to [general optional flags](#Usage) you can use the following optional artifactory flags. - -| Flag | Description | -|------------------------|---------------------------------------------------------------------------------------------------------| -| `-jfrog.sshKeyPath` | [Optional] Ssh key file path. Should be used only if the Artifactory URL format is ssh://[domain]:port. | -| `-jfrog.sshPassphrase` | [Optional] Ssh key passphrase. | - -##### Examples - -To run artifactory tests execute the following command. - -``` -go test -v github.com/jfrog/jfrog-cli -test.artifactory [flags] -``` - -#### Npm tests - -##### Requirements - -- The _npm_ executables should be included as part of the _PATH_ environment variable. -- The tests are compatible with npm 7 and higher. - -##### Limitation - -- Currently, npm integration support only http(s) connections to Artifactory using username and password. - -##### Examples - -To run npm tests execute the following command. - -``` -go test -v github.com/jfrog/jfrog-cli -test.npm [flags] -``` - -#### Maven tests - -##### Requirements - -- The _java_ executable should be included as part of the _PATH_ environment variable. Alternatively, set the - _JAVA_HOME_ environment variable. - -##### Limitation - -- Currently, maven integration support only http(s) connections to Artifactory using username and password. - -##### Examples - -To run maven tests execute the following command. - -``` -go test -v github.com/jfrog/jfrog-cli -test.maven [flags] -``` - -#### Gradle tests - -##### Requirements - -- The _gradle_ executables should be included as part of the _PATH_ environment variable. -- The _java_ executable should be included as part of the _PATH_ environment variable. Alternatively, set the - _JAVA_HOME_ environment variable. - -##### Limitation - -- Currently, gradle integration support only http(s) connections to Artifactory using username and password. - -##### Examples - -To run gradle tests execute the following command. - -``` -go test -v github.com/jfrog/jfrog-cli -test.gradle [flags] -``` - -#### Docker tests - -##### Requirements - -- Make sure the environment variable `RTLIC` is configured with a valid license. -- You can start an Artifactory container by running the `startArtifactory.sh` script under - the `testdata/docker/artifactory` directory. Before running the tests, wait for Artifactory to finish booting up in - the container. - -| Flag | Description | -|---------------------------|-------------------------------------| -| `-test.containerRegistry` | Artifactory Docker registry domain. | - -##### Examples - -To run docker tests execute the following command (fill out the missing parameters as described below). - -``` -go test -v github.com/jfrog/jfrog-cli -test.docker [flags] -``` - -#### Podman tests - -| Flag | Description | -|---------------------------|----------------------------------------| -| `-test.containerRegistry` | Artifactory container registry domain. | - -##### Examples - -To run podman tests execute the following command (fill out the missing parameters as described below). - -``` -go test -v github.com/jfrog/jfrog-cli -test.podman [flags] -``` - -#### Go commands tests - -##### Requirements - -- The tests are compatible with Artifactory 6.10 and higher. -- To run go tests run the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.go [flags] -``` - -#### NuGet tests - -##### Requirements - -- Add NuGet executable to the system search path (PATH environment variable). -- Run the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.nuget [flags] -``` - -#### Pip tests - -##### Requirements - -- Add Python and pip executables to the system search path (PATH environment variable). -- Run the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.pip [flags] -``` - -#### Plugins tests - -To run Plugins tests execute the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.plugins -``` - -### Distribution tests - -To run Distribution tests execute the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.distribution [flags] -``` - -### Transfer tests - -##### Requirement - -The transfer tests execute `transfer-files` commands between a local Artifactory server and a remote SaaS instance. -In addition to [general optional flags](#Usage) you _must_ use the following flags: - -| Flag | Description | -|------------------------------------|----------------------------------------------------------------------------------------------------------------| -| `-jfrog.targetUrl` | JFrog target platform URL. | -| `-jfrog.targetAdminToken` | JFrog target platform admin token. | -| `-jfrog.jfrogHome` | The JFrog home directory of the local Artifactory installation. | -| `-jfrog.installDataTransferPlugin` | Set to true if you'd like the test to install the data-transfer automatically in the source Artifactory server | - -To run transfer tests execute the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.transfer [flags] -``` - -### Xray tests - -To run Xray tests execute the following command: - -``` -go test -v github.com/jfrog/jfrog-cli -test.xray -test.dockerScan [flags] -``` - # Code Contributions -We welcome code contributions through pull requests from the community. - -## Pull Requests Guidelines - -- If the existing tests do not already cover your changes, please add tests.. -- Pull requests should be created on the _dev_ branch. -- Please use [gofmt](https://golang.org/cmd/gofmt/) for formatting the code before submitting the pull request. - -## Dependencies in other JFrog modules - -This project heavily depends on: - -- github.com/jfrog/jfrog-client-go -- github.com/jfrog/build-info-go -- github.com/jfrog/jfrog-cli-core - -### Local Development - -During local development, when you encounter code that needs to be changed from one of the above modules, it is -recommended to replace the dependency to work with a local clone of the dependency. - -For example, assuming you would like to change files from jfrog-cli-core. -Clone jfrog-cli-core (preferably your fork) to your local development machine -(assuming it will be cloned to `/repos/jfrog-cli-core`). - -Change go.mod to include the following: - -``` -replace github.com/jfrog/jfrog-cli-core/v2 => /repos/jfrog-cli-core -``` - -### Pull Requests - -Once done with your coding, you should push the changes you made to the other modules first. Once pushed, you can change -this -project to resolve the dependencies from your GitHub fork / branch. -This is done by pointing the dependency in go.mod to your repository and branch. For example: - -``` -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/galusben/jfrog-cli-core/v2 dev -``` - -Then run `go mod tidy` - -Notice that go will change the version in the go.mod file. +We welcome pull requests from the community. To help us improve this project, please read our [contribution](CONTRIBUTING.md) guide. # Using JFrog CLI From 488e89bb319a8cced2db20d3b1c9a9544a5204bf Mon Sep 17 00:00:00 2001 From: Sara Omari <114062096+sarao1310@users.noreply.github.com> Date: Mon, 17 Jul 2023 17:16:13 +0300 Subject: [PATCH 3/4] New `exclusions` options for go-publish (#2044) * gp --exclusion new flag --- buildtools/cli.go | 2 +- go.mod | 4 +- go.sum | 9 +-- go_test.go | 50 +++++++++++++ .../filespecs/go_publish_repo_excludes.json | 7 ++ testdata/go/project3/.jfrog/projects/go.yaml | 9 +++ .../go/project3/createGoProject_go.mod_suffix | 8 +++ testdata/go/project3/dependency.go | 11 +++ testdata/go/project3/go.sum | 7 ++ testdata/go/project4/.jfrog/projects/go.yaml | 9 +++ .../go/project4/createGoProject_go.mod_suffix | 8 +++ testdata/go/project4/dependency.go | 11 +++ testdata/go/project4/dir1/a.txt | 1 + testdata/go/project4/dir1/dir2/b.txt | 1 + testdata/go/project4/dir1/dir2/dir3/c.txt | 1 + testdata/go/project4/dir4/d.txt | 1 + testdata/go/project4/go.sum | 7 ++ utils/cliutils/commandsflags.go | 9 ++- utils/tests/consts.go | 71 +++++++++++++++++++ xray_test.go | 2 +- 20 files changed, 219 insertions(+), 9 deletions(-) create mode 100644 testdata/filespecs/go_publish_repo_excludes.json create mode 100644 testdata/go/project3/.jfrog/projects/go.yaml create mode 100644 testdata/go/project3/createGoProject_go.mod_suffix create mode 100644 testdata/go/project3/dependency.go create mode 100644 testdata/go/project3/go.sum create mode 100644 testdata/go/project4/.jfrog/projects/go.yaml create mode 100644 testdata/go/project4/createGoProject_go.mod_suffix create mode 100644 testdata/go/project4/dependency.go create mode 100644 testdata/go/project4/dir1/a.txt create mode 100644 testdata/go/project4/dir1/dir2/b.txt create mode 100644 testdata/go/project4/dir1/dir2/dir3/c.txt create mode 100644 testdata/go/project4/dir4/d.txt create mode 100644 testdata/go/project4/go.sum diff --git a/buildtools/cli.go b/buildtools/cli.go index ce2c438ea..508edb996 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -636,7 +636,7 @@ func GoPublishCmd(c *cli.Context) (err error) { version := c.Args().Get(0) printDeploymentView, detailedSummary := log.IsStdErrTerminal(), c.Bool("detailed-summary") goPublishCmd := golang.NewGoPublishCommand() - goPublishCmd.SetConfigFilePath(configFilePath).SetBuildConfiguration(buildConfiguration).SetVersion(version).SetDetailedSummary(detailedSummary || printDeploymentView) + goPublishCmd.SetConfigFilePath(configFilePath).SetBuildConfiguration(buildConfiguration).SetVersion(version).SetDetailedSummary(detailedSummary || printDeploymentView).SetExcludedPatterns(cliutils.GetStringsArrFlagValue(c, "exclusions")) err = commands.Exec(goPublishCmd) result := goPublishCmd.Result() defer cliutils.CleanupResult(result, &err) diff --git a/go.mod b/go.mod index 36f39aade..a31b5d245 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.20230705084348-c7d33487e393 +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230717092920-cd976eb1e5c3 // 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.20230705083849-6fd087a5e228 +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026 diff --git a/go.sum b/go.sum index e6f01b8bd..a9953b121 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.38.0 h1:lHylMjp0+IbZAUKVWi++keVktpyvI/0UwewIdbCoI/A= -github.com/jfrog/jfrog-cli-core/v2 v2.38.0/go.mod h1:Ws5UvSUITSZGuVVNNb/lDFPG0UAyiwpKv5o86M8By9I= -github.com/jfrog/jfrog-client-go v1.31.1 h1:lmunA5ZpRsrWTXgEGvnvVPIfwEqB3gn6+eVNpV2VBzU= -github.com/jfrog/jfrog-client-go v1.31.1/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230717092920-cd976eb1e5c3 h1:ED7QzMz/KA/7ps2bNvRiWbqBP/BbExWlUrJWcAoGiHM= +github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230717092920-cd976eb1e5c3/go.mod h1:QjTOL5xFgplonx47OnXXXurRtpQGDquGmrTbpe011EY= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026 h1:Xam/SD9ZqanqexbX2iW2H1fH5MLB9qx6vN8SK8wBMhA= +github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026/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= @@ -674,6 +674,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/go_test.go b/go_test.go index d51d422ff..1b00960c0 100644 --- a/go_test.go +++ b/go_test.go @@ -203,6 +203,56 @@ func TestGoPublishWithDeploymentView(t *testing.T) { clientTestUtils.ChangeDirAndAssert(t, wd) } +func TestGoPublishWithExclusions(t *testing.T) { + _, goCleanupFunc := initGoTest(t) + defer goCleanupFunc() + wd, err := os.Getwd() + assert.NoError(t, err, "Failed to get current dir") + searchFilePath, err := tests.CreateSpec(tests.GoPublishRepoExcludes) + assert.NoError(t, err) + + var testData = []struct { + exclusions string + expectedExistFilesPaths []string + expectedNotExistFilesPaths []string + }{ + {"./dir1/*", tests.GetGoPublishWithExclusionsExpectedFiles1(), tests.GetGoPublishWithExclusionsExcludedFiles1()}, + {"./dir1/dir2/*", tests.GetGoPublishWithExclusionsExpectedFiles2(), tests.GetGoPublishWithExclusionsExcludedFiles2()}, + {"*.txt", nil, tests.GetGoPublishWithExclusionsExcludedFiles3()}, + } + for _, test := range testData { + prepareGoProject("project4", t, true) + jfrogCli := tests.NewJfrogCli(execMain, "jf", "") + err = execGo(jfrogCli, "gp", "v1.1.1", "--exclusions", test.exclusions) + assert.NoError(t, err) + + // Verify that go-publish successfully published expected files and directories to Artifactory. + inttestutils.VerifyExistInArtifactory(tests.GetGoPublishWithExclusionsExpectedRepoGo(), searchFilePath, serverDetails, t) + // Creating a temporary directory to download for it the content of the zip file from artifactory. + tmpDir, createTempDirCallback := coretests.CreateTempDirWithCallbackAndAssert(t) + err = os.RemoveAll(tmpDir) + assert.NoError(t, err) + assert.NoError(t, os.Mkdir(tmpDir, 0777)) + runRt(t, "download", tests.GoRepo, tmpDir+"/", "--explode") + // Checking whether the expected files exist in the zip file after downloading from artifactory with unzipping it. + for _, path := range test.expectedExistFilesPaths { + result, err := fileutils.IsFileExists(filepath.Join(tmpDir, path), true) + assert.NoError(t, err) + assert.True(t, result, "This file"+path+"does not exist") + } + // Checking whether the excluded files do not exist in the zip file after downloading from Artifactory with unzipping it. + for _, path := range test.expectedNotExistFilesPaths { + result, err := fileutils.IsFileExists(filepath.Join(tmpDir, path), true) + assert.NoError(t, err) + assert.False(t, result) + } + // Delete the temporary dir. + createTempDirCallback() + // Restore workspace. + clientTestUtils.ChangeDirAndAssert(t, wd) + } +} + func TestGoVcsFallback(t *testing.T) { _, cleanUpFunc := initGoTest(t) defer cleanUpFunc() diff --git a/testdata/filespecs/go_publish_repo_excludes.json b/testdata/filespecs/go_publish_repo_excludes.json new file mode 100644 index 000000000..979476285 --- /dev/null +++ b/testdata/filespecs/go_publish_repo_excludes.json @@ -0,0 +1,7 @@ +{ + "files": [ + { + "pattern": "${GO_REPO}/*" + } + ] +} \ No newline at end of file diff --git a/testdata/go/project3/.jfrog/projects/go.yaml b/testdata/go/project3/.jfrog/projects/go.yaml new file mode 100644 index 000000000..95ed0eca1 --- /dev/null +++ b/testdata/go/project3/.jfrog/projects/go.yaml @@ -0,0 +1,9 @@ +version: 1 +type: go + +resolver: + repo: ${GO_VIRTUAL_REPO} + serverID: default +deployer: + repo: ${GO_REPO} + serverID: default diff --git a/testdata/go/project3/createGoProject_go.mod_suffix b/testdata/go/project3/createGoProject_go.mod_suffix new file mode 100644 index 000000000..744893775 --- /dev/null +++ b/testdata/go/project3/createGoProject_go.mod_suffix @@ -0,0 +1,8 @@ +module github.com/jfrog/dependency + +require ( + github.com/pkg/errors v0.8.0 + rsc.io/quote v1.5.2 +) + +go 1.13 diff --git a/testdata/go/project3/dependency.go b/testdata/go/project3/dependency.go new file mode 100644 index 000000000..fb1446f05 --- /dev/null +++ b/testdata/go/project3/dependency.go @@ -0,0 +1,11 @@ +package dependency + +import ( + "fmt" + "github.com/pkg/errors" +) + +func PrintHello() error { + fmt.Println("Hello") + return errors.New("abc") +} diff --git a/testdata/go/project3/go.sum b/testdata/go/project3/go.sum new file mode 100644 index 000000000..6dd596a45 --- /dev/null +++ b/testdata/go/project3/go.sum @@ -0,0 +1,7 @@ +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/testdata/go/project4/.jfrog/projects/go.yaml b/testdata/go/project4/.jfrog/projects/go.yaml new file mode 100644 index 000000000..95ed0eca1 --- /dev/null +++ b/testdata/go/project4/.jfrog/projects/go.yaml @@ -0,0 +1,9 @@ +version: 1 +type: go + +resolver: + repo: ${GO_VIRTUAL_REPO} + serverID: default +deployer: + repo: ${GO_REPO} + serverID: default diff --git a/testdata/go/project4/createGoProject_go.mod_suffix b/testdata/go/project4/createGoProject_go.mod_suffix new file mode 100644 index 000000000..744893775 --- /dev/null +++ b/testdata/go/project4/createGoProject_go.mod_suffix @@ -0,0 +1,8 @@ +module github.com/jfrog/dependency + +require ( + github.com/pkg/errors v0.8.0 + rsc.io/quote v1.5.2 +) + +go 1.13 diff --git a/testdata/go/project4/dependency.go b/testdata/go/project4/dependency.go new file mode 100644 index 000000000..1ae8343f3 --- /dev/null +++ b/testdata/go/project4/dependency.go @@ -0,0 +1,11 @@ +package dependency + +import ( + "fmt" + "github.com/pkg/errors" +) + +func PrintHello() error { + fmt.Println("Hello World") + return errors.New("abc") +} diff --git a/testdata/go/project4/dir1/a.txt b/testdata/go/project4/dir1/a.txt new file mode 100644 index 000000000..8d14cbf98 --- /dev/null +++ b/testdata/go/project4/dir1/a.txt @@ -0,0 +1 @@ +a.txt \ No newline at end of file diff --git a/testdata/go/project4/dir1/dir2/b.txt b/testdata/go/project4/dir1/dir2/b.txt new file mode 100644 index 000000000..19acdd81a --- /dev/null +++ b/testdata/go/project4/dir1/dir2/b.txt @@ -0,0 +1 @@ +b.txt \ No newline at end of file diff --git a/testdata/go/project4/dir1/dir2/dir3/c.txt b/testdata/go/project4/dir1/dir2/dir3/c.txt new file mode 100644 index 000000000..f632129c1 --- /dev/null +++ b/testdata/go/project4/dir1/dir2/dir3/c.txt @@ -0,0 +1 @@ +c.txt \ No newline at end of file diff --git a/testdata/go/project4/dir4/d.txt b/testdata/go/project4/dir4/d.txt new file mode 100644 index 000000000..a751d6246 --- /dev/null +++ b/testdata/go/project4/dir4/d.txt @@ -0,0 +1 @@ +d.txt \ No newline at end of file diff --git a/testdata/go/project4/go.sum b/testdata/go/project4/go.sum new file mode 100644 index 000000000..6dd596a45 --- /dev/null +++ b/testdata/go/project4/go.sum @@ -0,0 +1,7 @@ +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index 080fea61f..5c77f30eb 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -270,6 +270,9 @@ const ( propsProps = propertiesPrefix + props propsExcludeProps = propertiesPrefix + excludeProps + // Unique go publish flags + goPublishExclusions = GoPublish + exclusions + // Unique build-publish flags buildPublishPrefix = "bp-" bpDryRun = buildPublishPrefix + dryRun @@ -1407,6 +1410,10 @@ var flagsMap = map[string]cli.Flag{ Name: Go, Usage: "[Default: false] Set to true to request audit for a Go project.` `", }, + goPublishExclusions: cli.StringFlag{ + Name: exclusions, + Usage: "[Optional] Semicolon-separated list of exclusions. Exclusions can include the * and the ? wildcards.` `", + }, rescan: cli.BoolFlag{ Name: rescan, Usage: "[Default: false] Set to true when scanning an already successfully scanned build, for example after adding an ignore rule.` `", @@ -1768,7 +1775,7 @@ var commandFlags = map[string][]string{ global, serverIdResolve, serverIdDeploy, repoResolve, repoDeploy, }, GoPublish: { - url, user, password, accessToken, buildName, buildNumber, module, project, detailedSummary, + url, user, password, accessToken, buildName, buildNumber, module, project, detailedSummary, goPublishExclusions, }, Go: { buildName, buildNumber, module, project, noFallback, diff --git a/utils/tests/consts.go b/utils/tests/consts.go index a4c52191c..8373be6d7 100644 --- a/utils/tests/consts.go +++ b/utils/tests/consts.go @@ -94,6 +94,7 @@ const ( SearchAllProdRepo = "search_all_prod_repo.json" SearchDistRepoByInSuffix = "search_dist_repo_by_in_suffix.json" SearchRepo1ByInSuffix = "search_repo1_by_in_suffix.json" + GoPublishRepoExcludes = "go_publish_repo_excludes.json" SearchRepo1IncludeDirs = "search_repo1_include_dirs.json" SearchRepo1NonExistFile = "search_repo1_ant_test_file.json" SearchRepo1NonExistFileAntExclusions = "search_repo1_ant_and_exclusions_test_file.json" @@ -215,6 +216,7 @@ var ( LcRbName1 = "cli-lc-rb1" LcRbName2 = "cli-lc-rb2" LcRbName3 = "cli-lc-rb3" + GoPublishWithExclusionPath = "github.com/jfrog/dependency/@v/github.com/jfrog/dependency@v1.1.1/" // Users UserName1 = "alice" @@ -262,6 +264,16 @@ func GetExpectedExcludeUploadPart2() []string { RtRepo1 + "/", } } +func GetExpectedExcludeUpload2() []string { + return []string{ + RtRepo1 + "/b3.in", + RtRepo1 + "/a2.in", + RtRepo1 + "/a3.in", + RtRepo1 + "/a1.in", + RtRepo1 + "/c", + RtRepo1 + "/", + } +} func GetExpectedExcludeUploadIncludeDir() []string { return []string{ RtRepo1 + "/a2.in", @@ -272,6 +284,14 @@ func GetExpectedExcludeUploadIncludeDir() []string { } } +func GetUploadLegacyPropsExpected() []string { + return []string{ + RtRepo1 + "/data/a1.in", + RtRepo1 + "/data/a2.in", + RtRepo1 + "/data/a3.in", + } +} + func GetSearchAppendedBuildNoPatternExpected() []string { return []string{ RtRepo1 + "/data/a1.in", @@ -2078,3 +2098,54 @@ func GetExpectedLifecycleArtifacts() []string { RtProdRepo + "/c3.in", } } + +func GetGoPublishWithExclusionsExpectedRepoGo() []string { + var expected = []string{ + GoRepo + "/github.com/jfrog/dependency/@v/v1.1.1.info", + GoRepo + "/github.com/jfrog/dependency/@v/v1.1.1.mod", + GoRepo + "/github.com/jfrog/dependency/@v/v1.1.1.zip", + } + return expected +} + +func GetGoPublishWithExclusionsExpectedFiles1() []string { + var expected = []string{ + GoPublishWithExclusionPath + "dir4/d.txt", + } + return expected +} + +func GetGoPublishWithExclusionsExcludedFiles1() []string { + var excluded = []string{ + GoPublishWithExclusionPath + "dir1/a.txt", + GoPublishWithExclusionPath + "dir1/dir2/b.txt", + GoPublishWithExclusionPath + "dir1/dir2/dir3/c.txt", + } + return excluded +} + +func GetGoPublishWithExclusionsExpectedFiles2() []string { + var expected = []string{ + GoPublishWithExclusionPath + "dir4/d.txt", + GoPublishWithExclusionPath + "dir1/a.txt", + } + return expected +} + +func GetGoPublishWithExclusionsExcludedFiles2() []string { + var excluded = []string{ + GoPublishWithExclusionPath + "dir1/dir2/b.txt", + GoPublishWithExclusionPath + "dir1/dir2/dir3/c.txt", + } + return excluded +} + +func GetGoPublishWithExclusionsExcludedFiles3() []string { + var excluded = []string{ + GoPublishWithExclusionPath + "dir1/a.txt", + GoPublishWithExclusionPath + "dir1/dir2/b.txt", + GoPublishWithExclusionPath + "dir1/dir2/dir3/c.txt", + GoPublishWithExclusionPath + "dir4/d.txt", + } + return excluded +} diff --git a/xray_test.go b/xray_test.go index c55d46b76..89527d1c2 100644 --- a/xray_test.go +++ b/xray_test.go @@ -293,7 +293,7 @@ func TestXrayAuditNoTech(t *testing.T) { defer clientTestUtils.ChangeDirAndAssert(t, prevWd) // Run audit on empty folder, expect an error err := xrayCli.Exec("audit") - assert.EqualError(t, err, "could not determine the package manager / build tool used by this project.") + assert.NoError(t, err) } func TestXrayAuditDetectTech(t *testing.T) { From 7e6b04f73d5a59e880a84f4bb67fc5954cfd6314 Mon Sep 17 00:00:00 2001 From: Omer Zidkoni <50792403+omerzi@users.noreply.github.com> Date: Wed, 19 Jul 2023 19:22:38 +0300 Subject: [PATCH 4/4] Promoted version to 2.44.0 (#2082) --- 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 | 8 ++++---- utils/cliutils/cli_consts.go | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/npm/v2-jf/package-lock.json b/build/npm/v2-jf/package-lock.json index c0b4385bc..738e730cd 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.43.1", + "version": "2.44.0", "lockfileVersion": 1 } diff --git a/build/npm/v2-jf/package.json b/build/npm/v2-jf/package.json index 9a29ffc90..9d43c22dc 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.43.1", + "version": "2.44.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 66de95f85..d3e36fd1a 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.43.1", + "version": "2.44.0", "lockfileVersion": 1 } diff --git a/build/npm/v2/package.json b/build/npm/v2/package.json index cfaa4c69b..0ca1a13ed 100644 --- a/build/npm/v2/package.json +++ b/build/npm/v2/package.json @@ -1,6 +1,6 @@ { "name": "jfrog-cli-v2", - "version": "2.43.1", + "version": "2.44.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 a31b5d245..8567954b4 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/gocarina/gocsv v0.0.0-20230616125104-99d496ca653d github.com/jfrog/build-info-go v1.9.6 github.com/jfrog/gofrog v1.3.0 - github.com/jfrog/jfrog-cli-core/v2 v2.38.0 - github.com/jfrog/jfrog-client-go v1.31.1 + github.com/jfrog/jfrog-cli-core/v2 v2.39.2 + github.com/jfrog/jfrog-client-go v1.31.2 github.com/jszwec/csvutil v1.8.0 github.com/mholt/archiver/v3 v3.5.1 github.com/pkg/errors v0.9.1 @@ -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.20230717092920-cd976eb1e5c3 +//replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 dev // 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.20230717090738-b2e0c7bcc026 +//replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026 diff --git a/go.sum b/go.sum index a9953b121..0dc8a1067 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.20230717092920-cd976eb1e5c3 h1:ED7QzMz/KA/7ps2bNvRiWbqBP/BbExWlUrJWcAoGiHM= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230717092920-cd976eb1e5c3/go.mod h1:QjTOL5xFgplonx47OnXXXurRtpQGDquGmrTbpe011EY= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026 h1:Xam/SD9ZqanqexbX2iW2H1fH5MLB9qx6vN8SK8wBMhA= -github.com/jfrog/jfrog-client-go v1.28.1-0.20230717090738-b2e0c7bcc026/go.mod h1:qEJxoe68sUtqHJ1YhXv/7pKYP/9p1D5tJrruzJKYeoI= +github.com/jfrog/jfrog-cli-core/v2 v2.39.2 h1:T0h+acOkaRqwrZyzizzL7lO+Yo2KpGcAypITHxKWSEI= +github.com/jfrog/jfrog-cli-core/v2 v2.39.2/go.mod h1:/HJ9mO3AZsACtQWxkwMj7REWPdXT3yHKjJXjPHlmB34= +github.com/jfrog/jfrog-client-go v1.31.2 h1:foy8owM2lS8jZL7zuBPtcx1RpF1GeIXaXF8hIufyr4I= +github.com/jfrog/jfrog-client-go v1.31.2/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 b0f699b5b..f73b0e643 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.43.1" + CliVersion = "2.44.0" ClientAgent = "jfrog-cli-go" // CLI base commands constants: