Skip to content

Commit caf7b74

Browse files
committed
fix: update golden files for exit codes section + correct 3 wantExitCode annotations
- Add exit codes table to 4 docs golden files (hugo/mintlify × snyk/artifact) - Change wantExitCode from 4 to 1 for 3 RunE validation errors that are plain fmt.Errorf (not wrapped via ErrorBeforePrintingUsage as ErrUsage)
1 parent a4169c9 commit caf7b74

7 files changed

Lines changed: 43 additions & 3 deletions

File tree

cmd/kosli/assertApproval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (suite *AssertApprovalCommandTestSuite) TestAssertApprovalCmd() {
100100
},
101101
{
102102
wantError: true,
103-
wantExitCode: 4,
103+
wantExitCode: 1,
104104
name: "8 providing both --fingerprint and --artifact-type fails",
105105
cmd: fmt.Sprintf(`assert approval --artifact-type file --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
106106
golden: "Error: only one of --fingerprint, --artifact-type is allowed\n",

cmd/kosli/assertArtifact_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (suite *AssertArtifactCommandTestSuite) TestAssertArtifactCmd() {
186186
},
187187
{
188188
wantError: true,
189-
wantExitCode: 4,
189+
wantExitCode: 1,
190190
name: "15 providing both --environment and --polices fails",
191191
cmd: fmt.Sprintf(`assert artifact --fingerprint %s --environment %s --policy %s %s`, suite.fingerprint1, suite.envName, suite.policyName1, suite.defaultKosliArguments),
192192
golden: "Error: Cannot specify both 'environment_name' and 'policy_name' at the same time\n",

cmd/kosli/assertPRBitbucket_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (suite *AssertPRBitbucketCommandTestSuite) TestAssertPRBitbucketCmd() {
3838
},
3939
{
4040
wantError: true,
41-
wantExitCode: 4,
41+
wantExitCode: 1,
4242
name: "assert Bitbucket PR evidence fails when both password and access token are provided",
4343
cmd: `assert pullrequest bitbucket --bitbucket-workspace kosli-dev --repository cli-test
4444
--commit fd54040fc90e7e83f7b152619bfa18917b72c34f --bitbucket-password xxxx` + suite.defaultKosliArguments,

cmd/kosli/testdata/output/docs/hugo/artifact.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ artifact {IMAGE-NAME | FILE-PATH | DIR-PATH} [flags]
3535
| --repo-root string | [defaulted] The directory where the source git repository is available. (default ".") |
3636

3737

38+
## Exit Codes
39+
| Code | Meaning |
40+
| :---: | :--- |
41+
| 0 | No error. |
42+
| 1 | Unexpected error. |
43+
| 2 | Kosli server is unreachable or returned a server error. |
44+
| 3 | Invalid API token or unauthorized access. |
45+
| 4 | CLI usage error (e.g. missing or invalid flags). |
46+
47+
3848
## Examples
3949

4050
```shell

cmd/kosli/testdata/output/docs/hugo/snyk.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ binding the attestation to the right artifact.
6060
| -u, --user-data string | [optional] The path to a JSON file containing additional data you would like to attach to the attestation. |
6161

6262

63+
## Exit Codes
64+
| Code | Meaning |
65+
| :---: | :--- |
66+
| 0 | No error. |
67+
| 1 | Unexpected error. |
68+
| 2 | Kosli server is unreachable or returned a server error. |
69+
| 3 | Invalid API token or unauthorized access. |
70+
| 4 | CLI usage error (e.g. missing or invalid flags). |
71+
72+
6373
## Examples Use Cases
6474

6575
These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](https://docs.kosli.com/getting_started/install/#assigning-flags-via-environment-variables).

cmd/kosli/testdata/output/docs/mintlify/artifact.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ images in registries or "docker" for local docker images.
4242
| --repo-root string | [defaulted] The directory where the source git repository is available. (default ".") |
4343

4444

45+
## Exit Codes
46+
| Code | Meaning |
47+
| :---: | :--- |
48+
| 0 | No error. |
49+
| 1 | Unexpected error. |
50+
| 2 | Kosli server is unreachable or returned a server error. |
51+
| 3 | Invalid API token or unauthorized access. |
52+
| 4 | CLI usage error (e.g. missing or invalid flags). |
53+
54+
4555
## Examples Use Cases
4656

4757
These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](/getting_started/install/#assigning-flags-via-environment-variables).

cmd/kosli/testdata/output/docs/mintlify/snyk.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ binding the attestation to the right artifact.
5858
| -u, --user-data string | [optional] The path to a JSON file containing additional data you would like to attach to the attestation. |
5959

6060

61+
## Exit Codes
62+
| Code | Meaning |
63+
| :---: | :--- |
64+
| 0 | No error. |
65+
| 1 | Unexpected error. |
66+
| 2 | Kosli server is unreachable or returned a server error. |
67+
| 3 | Invalid API token or unauthorized access. |
68+
| 4 | CLI usage error (e.g. missing or invalid flags). |
69+
70+
6171
## Examples Use Cases
6272

6373
These examples all assume that the flags `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](/getting_started/install/#assigning-flags-via-environment-variables).

0 commit comments

Comments
 (0)