Commit 8977d362 authored by Jaime Martinez's avatar Jaime Martinez 🔴
Browse files

Merge branch '50-json-file-as-param' into 'master'

Add flag to pass a yml file as argument

Closes #50

See merge request !125



Merged-by: default avatarJaime Martinez <jmartinez@gitlab.com>
Approved-by: default avatarAlishan Ladhani <aladhani@gitlab.com>
Approved-by: default avatarJaime Martinez <jmartinez@gitlab.com>
Reviewed-by: Vladimir Shushlin's avatarVladimir Shushlin <vshushlin@gitlab.com>
Reviewed-by: default avatarJaime Martinez <jmartinez@gitlab.com>
Reviewed-by: default avatarEtienne Baqué <ebaque@gitlab.com>
Co-authored-by: default avatarEtienne Baqué <ebaque@gitlab.com>
parents fbf15136 d89d7e56
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -93,6 +93,28 @@ OPTIONS:
   --help, -h                 Show help (default: false)
```

### Create a new release using a file

This command uses the [Create a Release](https://docs.gitlab.com/ee/api/releases/) API.

```shell
release-cli --server-url https://gitlab.com --job-token=SOME_JOB_TOKEN --project-id 12345 create-from-file help
```

The output is:

```plaintext
NAME:
   help create-from-file - Create a Release uaing GitLab's Releases API https://docs.gitlab.com/ee/api/releases/#create-a-release

USAGE:
   help create-from-file [command options] [arguments...]

OPTIONS:
   --file value               YML file which content holds data to create a release. Does not need use of any other parameters.`
   --help, -h                 Show help (default: false)
```

### Get an existing release by tag name

The `get` command uses the [Get a Release by tag name](https://docs.gitlab.com/ee/api/releases/#get-a-release-by-a-tag-name) endpoint
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ require (
)

require (
	github.com/BurntSushi/toml v0.3.1 // indirect
	github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -22,5 +23,6 @@ require (
	github.com/russross/blackfriday/v2 v2.1.0 // indirect
	github.com/stretchr/objx v0.3.0 // indirect
	golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
	gopkg.in/yaml.v2 v2.2.8 // indirect
	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
+2 −0
Original line number Diff line number Diff line
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
@@ -40,6 +41,7 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ Get started with release-cli https://gitlab.com/gitlab-org/release-cli.`,
		},
		Commands: []*cli.Command{
			commands.Create(log, newHTTPClient),
			commands.CreateFromFile(log, newHTTPClient),
			commands.Get(log, newHTTPClient),
			commands.Update(log, newHTTPClient),
		},
+5 −0
Original line number Diff line number Diff line
@@ -152,6 +152,11 @@ func TestApp(t *testing.T) {
			args:       []string{"get"},
			wantErrStr: "Required flag \"tag-name\" not set",
		},
		"success_with_release_file": {
			res:            testdata.ResponseCreateReleaseSuccess,
			args:           []string{"create-from-file", "--file", "testdata/release.yml"},
			wantLogEntries: []string{"Creating Release...", "release created successfully!"},
		},
	}

	for tn, tt := range tests {
Loading