Skip to content

Commit 4ac21cd

Browse files
Alexandre CatalanAlexandre Catalan
authored andcommitted
feat(container-registry): display error description in artifactory describe
Display the artifactory error description in table output when present, providing users with context when an artifactory is in an error state. Also add test coverage for the error description field. Relates to STACKITCRE-382
1 parent 6067cb8 commit 4ac21cd

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎internal/cmd/container-registry/artifactory/describe/describe.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func outputResult(p *print.Printer, outputFormat string, artifactory *registry.A
101101
table.AddRow("NAME", artifactory.Name)
102102
table.AddSeparator()
103103
table.AddRow("STATE", string(artifactory.State))
104+
if artifactory.ErrorDescription != nil && *artifactory.ErrorDescription != "" {
105+
table.AddSeparator()
106+
table.AddRow("ERROR DESCRIPTION", *artifactory.ErrorDescription)
107+
}
104108
table.AddSeparator()
105109
table.AddRow("URL", artifactory.Url)
106110
table.AddSeparator()

‎internal/cmd/container-registry/artifactory/describe/describe_test.go‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ func TestOutputResult(t *testing.T) {
174174
artifactory *registry.Artifactory
175175
}
176176
desc := "docker hub mirror"
177+
errDesc := "failed to provision artifactory backend"
178+
emptyErrDesc := ""
177179
tests := []struct {
178180
name string
179181
args args
@@ -193,6 +195,36 @@ func TestOutputResult(t *testing.T) {
193195
},
194196
wantErr: false,
195197
},
198+
{
199+
name: "with error description",
200+
args: args{
201+
artifactory: &registry.Artifactory{
202+
Id: testArtifactoryId,
203+
Name: "my-artifactory",
204+
State: registry.ARTIFACTORYSTATE_ERROR,
205+
ErrorDescription: &errDesc,
206+
Url: "https://example.com",
207+
ConsumedQuotaBytes: 1024,
208+
CreateTime: time.Now(),
209+
},
210+
},
211+
wantErr: false,
212+
},
213+
{
214+
name: "with empty error description",
215+
args: args{
216+
artifactory: &registry.Artifactory{
217+
Id: testArtifactoryId,
218+
Name: "my-artifactory",
219+
State: registry.ARTIFACTORYSTATE_ERROR,
220+
ErrorDescription: &emptyErrDesc,
221+
Url: "https://example.com",
222+
ConsumedQuotaBytes: 1024,
223+
CreateTime: time.Now(),
224+
},
225+
},
226+
wantErr: false,
227+
},
196228
{
197229
name: "with proxy",
198230
args: args{

0 commit comments

Comments
 (0)