Skip to content

Commit a2ee562

Browse files
ToreMerkelyclaude
andauthored
Marked kosli approval commands as depricated server/#5125 (#890)
* Marked kosli approval commands as depricated server/#5125 * Depricate kosli report and kosli request * test: consolidate per-file deprecation constants into a shared helper Replaces four near-identical per-file constants (assertApprovalCmdDeprecation, getApprovalCmdDeprecation, reportApprovalCmdDeprecation, approvalsCmdDeprecation) with a single cmdDeprecationLine(cmd) helper in testHelpers.go. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fea11f0 commit a2ee562

18 files changed

Lines changed: 79 additions & 61 deletions

cmd/kosli/assertApproval.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ func newAssertApprovalCmd(out io.Writer) *cobra.Command {
4444
o := new(assertApprovalOptions)
4545
o.fingerprintOptions = new(fingerprintOptions)
4646
cmd := &cobra.Command{
47-
Use: "approval [IMAGE-NAME | FILE-PATH | DIR-PATH]",
48-
Short: assertApprovalShortDesc,
49-
Long: assertApprovalLongDesc,
50-
Example: assertApprovalExample,
47+
Use: "approval [IMAGE-NAME | FILE-PATH | DIR-PATH]",
48+
Short: assertApprovalShortDesc,
49+
Long: assertApprovalLongDesc,
50+
Example: assertApprovalExample,
51+
Deprecated: "this command is deprecated and will be removed in a future release.",
5152
PreRunE: func(cmd *cobra.Command, args []string) error {
5253
err := RequireGlobalFlags(global, []string{"Org", "ApiToken"})
5354
if err != nil {

cmd/kosli/assertApproval_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,30 @@ func (suite *AssertApprovalCommandTestSuite) TestAssertApprovalCmd() {
5252
wantError: true,
5353
name: "1 missing --org fails",
5454
cmd: fmt.Sprintf(`assert approval --fingerprint 8e568bd886069f1290def0caabc1e97ce0e7b80c105e611258b57d76fcef234c --flow %s --api-token secret`, suite.flowName),
55-
golden: "Error: --org is not set\nUsage: kosli assert approval [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]\n",
55+
golden: cmdDeprecationLine("approval") + "Error: --org is not set\nUsage: kosli assert approval [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]\n",
5656
},
5757
{
5858
wantError: true,
5959
name: "2 asserting approval for a non existing artifact fails",
6060
cmd: fmt.Sprintf(`assert approval --fingerprint 8e568bd886069f1290def0caabc1e97ce0e7b80c105e611258b57d76fcef234c --flow %s %s`, suite.flowName, suite.defaultKosliArguments),
61-
golden: "Error: Artifact with fingerprint '8e568bd886069f1290def0caabc1e97ce0e7b80c105e611258b57d76fcef234c' does not exist in flow 'assert-approval' belonging to organization 'docs-cmd-test-user'\n",
61+
golden: cmdDeprecationLine("approval") + "Error: Artifact with fingerprint '8e568bd886069f1290def0caabc1e97ce0e7b80c105e611258b57d76fcef234c' does not exist in flow 'assert-approval' belonging to organization 'docs-cmd-test-user'\n",
6262
},
6363
{
6464
wantError: true,
6565
name: "3 asserting an existing artifact that does not have an approval (using --fingerprint) works and exits with non-zero code",
6666
cmd: fmt.Sprintf(`assert approval --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
67-
golden: "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 has no approvals created\n",
67+
golden: cmdDeprecationLine("approval") + "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 has no approvals created\n",
6868
},
6969
{
7070
wantError: true,
7171
name: "4 asserting approval of an existing artifact that does not have an approval (using --artifact-type) works and exits with non-zero code",
7272
cmd: fmt.Sprintf(`assert approval %s --artifact-type file --flow %s %s`, suite.artifactPath, suite.flowName, suite.defaultKosliArguments),
73-
golden: "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 has no approvals created\n",
73+
golden: cmdDeprecationLine("approval") + "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 has no approvals created\n",
7474
},
7575
{
7676
name: "5 asserting approval of an existing artifact that has an approval (using --artifact-type) works and exits with zero code",
7777
cmd: fmt.Sprintf(`assert approval %s --artifact-type file --flow %s %s`, suite.artifactPath, suite.flowName, suite.defaultKosliArguments),
78-
golden: "artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is approved (approval no. [1])\n",
78+
golden: cmdDeprecationLine("approval") + "artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is approved (approval no. [1])\n",
7979
additionalConfig: assertApprovalTestConfig{
8080
createApproval: true,
8181
isRequest: false,
@@ -85,31 +85,31 @@ func (suite *AssertApprovalCommandTestSuite) TestAssertApprovalCmd() {
8585
{
8686
name: "6 asserting approval of an existing artifact that has an approval (using --fingerprint) works and exits with zero code",
8787
cmd: fmt.Sprintf(`assert approval --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
88-
golden: "artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is approved (approval no. [1])\n",
88+
golden: cmdDeprecationLine("approval") + "artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is approved (approval no. [1])\n",
8989
},
9090
{
9191
wantError: true,
9292
name: "7 not providing --fingerprint nor --artifact-type fails",
9393
cmd: fmt.Sprintf(`assert approval --flow %s %s`, suite.flowName, suite.defaultKosliArguments),
94-
golden: "Error: docker image name or file/dir path is required when --fingerprint is not provided\nUsage: kosli assert approval [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]\n",
94+
golden: cmdDeprecationLine("approval") + "Error: docker image name or file/dir path is required when --fingerprint is not provided\nUsage: kosli assert approval [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]\n",
9595
},
9696
{
9797
wantError: true,
9898
name: "8 providing both --fingerprint and --artifact-type fails",
9999
cmd: fmt.Sprintf(`assert approval --artifact-type file --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
100-
golden: "Error: only one of --fingerprint, --artifact-type is allowed\n",
100+
golden: cmdDeprecationLine("approval") + "Error: only one of --fingerprint, --artifact-type is allowed\n",
101101
},
102102
{
103103
wantError: true,
104104
name: "9 missing --flow fails",
105105
cmd: fmt.Sprintf(`assert approval --fingerprint %s %s`, suite.fingerprint, suite.defaultKosliArguments),
106-
golden: "Error: required flag(s) \"flow\" not set\n",
106+
golden: cmdDeprecationLine("approval") + "Error: required flag(s) \"flow\" not set\n",
107107
},
108108
{
109109
wantError: true,
110110
name: "10 asserting approval of an unapproved existing artifact (using --artifact-type) works and exits with non-zero code",
111111
cmd: fmt.Sprintf(`assert approval %s --artifact-type file --flow %s %s`, suite.artifactPath, suite.flowName, suite.defaultKosliArguments),
112-
golden: "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is not approved\n",
112+
golden: cmdDeprecationLine("approval") + "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is not approved\n",
113113
additionalConfig: assertApprovalTestConfig{
114114
createApproval: true,
115115
isRequest: true,
@@ -120,7 +120,7 @@ func (suite *AssertApprovalCommandTestSuite) TestAssertApprovalCmd() {
120120
wantError: true,
121121
name: "11 asserting approval of an unapproved existing artifact (using --fingerprint) works and exits with non-zero code",
122122
cmd: fmt.Sprintf(`assert approval --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
123-
golden: "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is not approved\n",
123+
golden: cmdDeprecationLine("approval") + "Error: artifact with fingerprint fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02 is not approved\n",
124124
},
125125
}
126126

cmd/kosli/getApproval.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ type getApprovalOptions struct {
5151
func newGetApprovalCmd(out io.Writer) *cobra.Command {
5252
o := new(getApprovalOptions)
5353
cmd := &cobra.Command{
54-
Use: "approval EXPRESSION",
55-
Short: getApprovalShortDesc,
56-
Long: getApprovalLongDesc,
57-
Example: getApprovalExample,
58-
Args: cobra.ExactArgs(1),
54+
Use: "approval EXPRESSION",
55+
Short: getApprovalShortDesc,
56+
Long: getApprovalLongDesc,
57+
Example: getApprovalExample,
58+
Args: cobra.ExactArgs(1),
59+
Deprecated: "this command is deprecated and will be removed in a future release.",
5960
PreRunE: func(cmd *cobra.Command, args []string) error {
6061
err := RequireGlobalFlags(global, []string{"Org", "ApiToken"})
6162
if err != nil {

cmd/kosli/getApproval_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ func (suite *GetApprovalCommandTestSuite) TestGetApprovalCmd() {
5454
wantError: true,
5555
name: "get an approval with more than one argument fails",
5656
cmd: fmt.Sprintf("get approval %s xxx %s", suite.flowName, suite.defaultKosliArguments),
57-
golden: "Error: accepts 1 arg(s), received 2\n",
57+
golden: cmdDeprecationLine("approval") + "Error: accepts 1 arg(s), received 2\n",
5858
},
5959
{
6060
wantError: true,
6161
name: "get approval on a non-existing flow fails",
6262
cmd: "get approval get-approval-123#20" + suite.defaultKosliArguments,
63-
golden: "Error: Flow named 'get-approval-123' does not exist for organization 'docs-cmd-test-user'\n",
63+
golden: cmdDeprecationLine("approval") + "Error: Flow named 'get-approval-123' does not exist for organization 'docs-cmd-test-user'\n",
6464
},
6565
{
6666
wantError: true,
6767
name: "get non-existing approval fails",
6868
cmd: fmt.Sprintf("get approval %s#23 %s", suite.flowName, suite.defaultKosliArguments),
69-
golden: "Error: Approval number '23' does not exist in flow 'get-approval' belonging to organization 'docs-cmd-test-user'\n",
69+
golden: cmdDeprecationLine("approval") + "Error: Approval number '23' does not exist in flow 'get-approval' belonging to organization 'docs-cmd-test-user'\n",
7070
},
7171
{
7272
wantError: true,
7373
name: "missing --org fails",
7474
cmd: fmt.Sprintf("get approval %s --api-token secret", suite.flowName),
75-
golden: "Error: --org is not set\nUsage: kosli get approval EXPRESSION [flags]\n",
75+
golden: cmdDeprecationLine("approval") + "Error: --org is not set\nUsage: kosli get approval EXPRESSION [flags]\n",
7676
},
7777
}
7878

cmd/kosli/listApprovals.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ type listApprovalsOptions struct {
4848
func newListApprovalsCmd(out io.Writer) *cobra.Command {
4949
o := new(listApprovalsOptions)
5050
cmd := &cobra.Command{
51-
Use: "approvals",
52-
Short: listApprovalsShortDesc,
53-
Long: listApprovalsLongDesc,
54-
Example: listApprovalsExample,
55-
Args: cobra.NoArgs,
51+
Use: "approvals",
52+
Short: listApprovalsShortDesc,
53+
Long: listApprovalsLongDesc,
54+
Example: listApprovalsExample,
55+
Args: cobra.NoArgs,
56+
Deprecated: "this command is deprecated and will be removed in a future release.",
5657
PreRunE: func(cmd *cobra.Command, args []string) error {
5758
err := RequireGlobalFlags(global, []string{"Org", "ApiToken"})
5859
if err != nil {

cmd/kosli/listApprovals_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ func (suite *ListApprovalsCommandTestSuite) TestListApprovalsCmd() {
5050
wantError: true,
5151
name: "missing --flow flag arg causes an error",
5252
cmd: fmt.Sprintf(`list approvals %s`, suite.defaultKosliArguments),
53-
golden: "Error: required flag(s) \"flow\" not set\n",
53+
golden: cmdDeprecationLine("approvals") + "Error: required flag(s) \"flow\" not set\n",
5454
},
5555
{
5656
wantError: true,
5757
name: "non-existing flow causes an error",
5858
cmd: fmt.Sprintf(`list approvals --flow non-existing %s`, suite.defaultKosliArguments),
59-
golden: "Error: Flow named 'non-existing' does not exist for organization 'docs-cmd-test-user'\n",
59+
golden: cmdDeprecationLine("approvals") + "Error: Flow named 'non-existing' does not exist for organization 'docs-cmd-test-user'\n",
6060
},
6161
// TODO: the correct error is overwritten by the hack flag value check in root.go
6262
{
6363
wantError: true,
6464
name: "negative page number causes an error",
6565
cmd: fmt.Sprintf(`list approvals --flow foo --page -1 %s`, suite.defaultKosliArguments),
66-
golden: "Error: flag '--page' has value '-1' which is illegal\n",
66+
golden: cmdDeprecationLine("approvals") + "Error: flag '--page' has value '-1' which is illegal\n",
6767
},
6868
{
6969
wantError: true,
7070
name: "negative page limit causes an error",
7171
cmd: fmt.Sprintf(`list approvals --flow foo --page-limit -1 %s`, suite.defaultKosliArguments),
72-
golden: "Error: flag '--page-limit' has value '-1' which is illegal\n",
72+
golden: cmdDeprecationLine("approvals") + "Error: flag '--page-limit' has value '-1' which is illegal\n",
7373
},
7474
{
7575
name: "listing approvals on an empty flow works",
7676
cmd: fmt.Sprintf(`list approvals --flow %s %s`, suite.flowName1, suite.defaultKosliArguments),
77-
golden: "No approvals were found.\n",
77+
golden: cmdDeprecationLine("approvals") + "No approvals were found.\n",
7878
},
7979
{
80-
name: "listing approvals on an empty flow with --output json works",
81-
cmd: fmt.Sprintf(`list approvals --flow %s --output json %s`, suite.flowName1, suite.defaultKosliArguments),
82-
goldenJson: []jsonCheck{{"", "[]"}},
80+
name: "listing approvals on an empty flow with --output json works",
81+
cmd: fmt.Sprintf(`list approvals --flow %s --output json %s`, suite.flowName1, suite.defaultKosliArguments),
82+
golden: cmdDeprecationLine("approvals") + "[]",
8383
},
8484
{
8585
name: "listing approvals on a flow works",

cmd/kosli/report.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ const reportDesc = `All Kosli report commands.`
1010

1111
func newReportCmd(out io.Writer) *cobra.Command {
1212
cmd := &cobra.Command{
13-
Use: "report",
14-
Short: reportDesc,
15-
Long: reportDesc,
13+
Use: "report",
14+
Short: reportDesc,
15+
Long: reportDesc,
16+
Deprecated: "this command is deprecated and will be removed in a future release.",
1617
}
1718

1819
// Add subcommands

cmd/kosli/reportApproval.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ func newReportApprovalCmd(out io.Writer) *cobra.Command {
8383
o := new(reportApprovalOptions)
8484
o.fingerprintOptions = new(fingerprintOptions)
8585
cmd := &cobra.Command{
86-
Use: "approval [IMAGE-NAME | FILE-PATH | DIR-PATH]",
87-
Short: reportApprovalShortDesc,
88-
Long: reportApprovalLongDesc,
89-
Example: reportApprovalExample,
86+
Use: "approval [IMAGE-NAME | FILE-PATH | DIR-PATH]",
87+
Short: reportApprovalShortDesc,
88+
Long: reportApprovalLongDesc,
89+
Example: reportApprovalExample,
90+
Deprecated: "this command is deprecated and will be removed in a future release.",
9091
PreRunE: func(cmd *cobra.Command, args []string) error {
9192
err := RequireGlobalFlags(global, []string{"Org", "ApiToken"})
9293
if err != nil {

cmd/kosli/reportApproval_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,28 @@ func (suite *ApprovalReportTestSuite) TestApprovalReportCmd() {
5757
tests := []cmdTestCase{
5858
{
5959
name: "report approval with a range of commits works ",
60-
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../..
60+
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../..
6161
--newest-commit HEAD --oldest-commit HEAD~3` + suite.defaultKosliArguments,
62-
golden: fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
62+
golden: cmdDeprecationLine("approval") + fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
6363
},
6464
{
6565
name: "report approval with an environment name works",
66-
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../..
66+
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../..
6767
--newest-commit HEAD --oldest-commit HEAD~3` + ` --environment staging` + suite.defaultKosliArguments,
68-
golden: fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
68+
golden: cmdDeprecationLine("approval") + fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
6969
},
7070
{
7171
wantError: true,
7272
name: "report approval with no environment name and no oldest commit fails",
7373
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../.. ` +
7474
suite.defaultKosliArguments,
75-
golden: "Error: at least one of --environment, --oldest-commit is required\n",
75+
golden: cmdDeprecationLine("approval") + "Error: at least one of --environment, --oldest-commit is required\n",
7676
},
7777
{
7878
name: "report approval with an environment name and no oldest-commit and no newest-commit works",
7979
cmd: `report approval --fingerprint ` + suite.artifactFingerprint + ` --flow ` + suite.flowName + ` --repo-root ../.. ` +
8080
` --environment ` + suite.envName + suite.defaultKosliArguments,
81-
golden: fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
81+
golden: cmdDeprecationLine("approval") + fmt.Sprintf("approval created for artifact: %s\n", suite.artifactFingerprint),
8282
additionalConfig: reportApprovalTestConfig{
8383
createSnapshot: true,
8484
},

cmd/kosli/request.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ const requestDesc = `All Kosli request commands.`
1010

1111
func newRequestCmd(out io.Writer) *cobra.Command {
1212
cmd := &cobra.Command{
13-
Use: "request",
14-
Short: requestDesc,
15-
Long: requestDesc,
13+
Use: "request",
14+
Short: requestDesc,
15+
Long: requestDesc,
16+
Deprecated: "this command is deprecated and will be removed in a future release.",
1617
}
1718

1819
// Add subcommands

0 commit comments

Comments
 (0)