1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00

Fix error when upgrade an app deployed from project level catalog

Problem:
Cannot upgrade an app deployed from project level catalog. When constructing the externalId filter, catalog id gets url-encoded twice, therefore fails to get the templateversion.

Solution:
Construct the query properly.
This commit is contained in:
gitlawr
2019-01-23 15:25:01 +08:00
committed by Craig Jellick
parent 68301b6ce7
commit 95ffbbd2ab

View File

@@ -323,17 +323,13 @@ func appUpgrade(ctx *cli.Context) error {
return err
}
u, err := url.Parse(app.ExternalID)
externalID, err := updateExternalIDVersion(app.ExternalID, ctx.Args().Get(1))
if err != nil {
return err
}
q := u.Query()
q.Set("version", ctx.Args().Get(1))
filter := defaultListOpts(ctx)
filter.Filters["externalId"] = "catalog://?" + q.Encode()
filter.Filters["externalId"] = externalID
template, err := c.ManagementClient.TemplateVersion.List(filter)
if err != nil {
@@ -352,6 +348,22 @@ func appUpgrade(ctx *cli.Context) error {
return c.ProjectClient.App.ActionUpgrade(app, au)
}
func updateExternalIDVersion(externalID string, version string) (string, error) {
u, err := url.Parse(externalID)
if err != nil {
return "", err
}
q := u.Query()
q.Set("version", version)
// Need to unescape here to get the raw string for the externalId filter
catalogQuery, err := url.QueryUnescape(q.Encode())
if err != nil {
return "", err
}
return "catalog://?" + catalogQuery, nil
}
func appRollback(ctx *cli.Context) error {
c, err := GetClient(ctx)
if err != nil {