Skip to content

Commit d94eae9

Browse files
set installer ls response correctly (#182)
1 parent 2bb060b commit d94eae9

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

cli/test/kots_installer_create_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ spec:
8888

8989
req.Contains(stdout.String(), `SEQUENCE: 2`)
9090
req.Contains(stdout.String(), `successfully set to installer 2`)
91+
92+
rootCmd.SetArgs([]string{"installer", "ls", "--app", app.Slug})
93+
94+
err = cmd.Execute(rootCmd, nil, &stdout, &stderr)
95+
req.NoError(err)
96+
97+
req.Empty(stderr.String(), "Expected no stderr output")
98+
req.NotEmpty(stdout.String(), "Expected stdout output")
9199
})
92100
})
93101

pkg/kotsclient/installer.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@ import (
44
"fmt"
55
"net/http"
66

7+
"github.com/pkg/errors"
78
"github.com/replicatedhq/replicated/pkg/types"
9+
"github.com/replicatedhq/replicated/pkg/util"
810
)
911

1012
func (c *VendorV3Client) ListInstallers(appID string) ([]types.InstallerSpec, error) {
11-
var response []types.InstallerSpec
13+
var response types.ListInstallersResponse
1214

1315
url := fmt.Sprintf("/v3/app/%s/installers", appID)
1416
err := c.DoJSON("GET", url, http.StatusOK, nil, &response)
1517
if err != nil {
1618
return nil, err
1719
}
1820

19-
return response, nil
21+
for i, installerSpec := range response.Body {
22+
createdAtTime, err := util.ParseTime(installerSpec.CreatedAtString)
23+
if err != nil {
24+
return nil, errors.Wrap(err, "parsing time string to CreatedAt time")
25+
}
26+
response.Body[i].CreatedAt = util.Time{createdAtTime}
27+
}
28+
29+
return response.Body, nil
2030
}
2131

2232
func (c *VendorV3Client) CreateInstaller(appID string, yaml string) (*types.InstallerSpec, error) {

pkg/types/installer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ type InstallerSpec struct {
1111
YAML string `json:"yaml"`
1212
ActiveChannels []Channel `json:"channels"`
1313
CreatedAt util.Time `json:"created"`
14+
CreatedAtString string `json:"createdAt"`
1415
Immutable bool `json:"isInstallerNotEditable"`
1516
}
1617

1718
type InstallerSpecResponse struct {
1819
Body InstallerSpec `json:"installer"`
1920
}
2021

22+
type ListInstallersResponse struct {
23+
Body []InstallerSpec `json:"installers"`
24+
}
25+
2126
type CreateInstallerRequest struct {
2227
Yaml string `json:"yaml"`
2328
}

0 commit comments

Comments
 (0)