Skip to content

Commit 0feae74

Browse files
LiliumCandidumPaola Nicosia
andauthored
fix: errors in commands with version check (#267)
Co-authored-by: Paola Nicosia <[email protected]>
1 parent edd126c commit 0feae74

File tree

10 files changed

+40
-9
lines changed

10 files changed

+40
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- fixed error management in commands with Console version check
13+
1014
### Changed
1115

1216
- update go version to 1.25.1

internal/cmd/catalog/apply/apply.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ func ApplyCmd(options *clioptions.CLIOptions) *cobra.Command {
8383
cobra.CheckErr(err)
8484

8585
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 0)
86-
if !canUseNewAPI || versionError != nil {
86+
if versionError != nil {
87+
return versionError
88+
}
89+
if !canUseNewAPI {
8790
return catalog.ErrUnsupportedCompanyVersion
8891
}
8992

internal/cmd/catalog/delete.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func DeleteCmd(options *clioptions.CLIOptions) *cobra.Command {
5656
cobra.CheckErr(err)
5757

5858
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 0)
59-
if !canUseNewAPI || versionError != nil {
59+
if versionError != nil {
60+
return versionError
61+
}
62+
if !canUseNewAPI {
6063
return catalog.ErrUnsupportedCompanyVersion
6164
}
6265

internal/cmd/catalog/get.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ func GetCmd(options *clioptions.CLIOptions) *cobra.Command {
5454
cobra.CheckErr(err)
5555

5656
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 0)
57-
if !canUseNewAPI || versionError != nil {
57+
if versionError != nil {
58+
return versionError
59+
}
60+
if !canUseNewAPI {
5861
return catalog.ErrUnsupportedCompanyVersion
5962
}
6063

internal/cmd/catalog/list.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func runListCmd(options *clioptions.CLIOptions) func(cmd *cobra.Command, args []
6262
cobra.CheckErr(err)
6363

6464
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), apiClient, 14, 0)
65-
if !canUseNewAPI || versionError != nil {
65+
if versionError != nil {
66+
return versionError
67+
}
68+
if !canUseNewAPI {
6669
return catalog.ErrUnsupportedCompanyVersion
6770
}
6871

internal/cmd/catalog/list_versions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ The command will output a table with each version of the item. It works with Mia
4040
cobra.CheckErr(err)
4141

4242
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 0)
43-
if !canUseNewAPI || versionError != nil {
43+
if versionError != nil {
44+
return versionError
45+
}
46+
if !canUseNewAPI {
4447
return catalog.ErrUnsupportedCompanyVersion
4548
}
4649

internal/cmd/item-type-definition/delete.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func DeleteCmd(options *clioptions.CLIOptions) *cobra.Command {
5656
cobra.CheckErr(err)
5757

5858
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 1)
59-
if !canUseNewAPI || versionError != nil {
59+
if versionError != nil {
60+
return versionError
61+
}
62+
if !canUseNewAPI {
6063
return itd.ErrUnsupportedCompanyVersion
6164
}
6265

internal/cmd/item-type-definition/get.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ func GetCmd(options *clioptions.CLIOptions) *cobra.Command {
4949
cobra.CheckErr(err)
5050

5151
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 1)
52-
if !canUseNewAPI || versionError != nil {
52+
if versionError != nil {
53+
return versionError
54+
}
55+
if !canUseNewAPI {
5356
return itd.ErrUnsupportedCompanyVersion
5457
}
5558

internal/cmd/item-type-definition/list.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ func runListCmd(options *clioptions.CLIOptions) func(cmd *cobra.Command, args []
7171
cobra.CheckErr(err)
7272

7373
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), apiClient, 14, 1)
74-
if !canUseNewAPI || versionError != nil {
74+
if versionError != nil {
75+
return versionError
76+
}
77+
if !canUseNewAPI {
7578
return itd.ErrUnsupportedCompanyVersion
7679
}
7780

internal/cmd/item-type-definition/put.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ func PutCmd(options *clioptions.CLIOptions) *cobra.Command {
7373
cobra.CheckErr(err)
7474

7575
canUseNewAPI, versionError := util.VersionCheck(cmd.Context(), client, 14, 1)
76-
if !canUseNewAPI || versionError != nil {
76+
if versionError != nil {
77+
return versionError
78+
}
79+
if !canUseNewAPI {
7780
return itd.ErrUnsupportedCompanyVersion
7881
}
7982

0 commit comments

Comments
 (0)