Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func parseRequestAndResponse(req *http.Request, resp *http.Response) *Response {
rawResponse: resp,
rawRequest: req,
body: body,
header: resp.Header,
statusCode: resp.StatusCode,
}
}
5 changes: 5 additions & 0 deletions internal/client/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Response struct {
rawRequest *http.Request

body []byte
header http.Header
statusCode int
err error
}
Expand All @@ -67,6 +68,10 @@ func (r *Response) RawRequest() *http.Request {
return r.rawRequest
}

func (r *Response) Header() http.Header {
return r.header
}

// Error return the response status code
func (r *Response) StatusCode() int {
return r.statusCode
Expand Down
8 changes: 7 additions & 1 deletion internal/cmd/marketplace/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ func deleteItemByItemIDAndVersion(ctx context.Context, client *client.APIClient,
return fmt.Errorf("error executing request: %w", err)
}

return checkDeleteResponseErrors(resp)
if err := checkDeleteResponseErrors(resp); err != nil {
return err
}

latestVersion := resp.Header().Get("X-Marketplace-Item-Latest-Version")
fmt.Printf("\nasd %s\n", latestVersion)
return nil
}

func checkDeleteResponseErrors(resp *client.Response) error {
Expand Down
7 changes: 6 additions & 1 deletion internal/cmd/marketplace/list_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,22 @@ func getItemVersions(ctx context.Context, client *client.APIClient, companyID, i
}

func printItemVersionList(releases *[]marketplace.Release, p printer.IPrinter) {
p.Keys("Version", "Name", "Description")
p.Keys("Version", "Name", "Description", "Latest")

for _, release := range *releases {
description := "-"
if release.Description != "" {
description = release.Description
}
latestCheck := ""
if release.Latest {
latestCheck = "✅"
}
p.Record(
release.Version,
release.Name,
description,
latestCheck,
)
}
p.Print()
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/marketplace/list_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
"version": "1.0.0",
"reference": "655342ce0f991db238fd73e4",
"security": false,
"isLatest": true,
"releaseNote": "-",
"visibility": {
"public": true
Expand Down Expand Up @@ -89,6 +90,7 @@ func TestGetItemVersions(t *testing.T) {
{
Name: "Some Awesome Service",
Description: "The Awesome Service allows to do some amazing stuff.",
Latest: true,
Version: "1.0.0",
},
{
Expand Down
1 change: 1 addition & 0 deletions internal/resources/marketplace/marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
type Release struct {
Version string `json:"version"`
Name string `json:"name"`
Latest bool `json:"isLatest"`

Check failure on line 70 in internal/resources/marketplace/marketplace.go

View workflow job for this annotation

GitHub Actions / Lint Code

json(camel): got 'isLatest' want 'latest' (tagliatelle)
Description string `json:"description"`
}

Expand Down
Loading