/
upgrade.go
44 lines (36 loc) · 928 Bytes
/
upgrade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package qliksense
import (
_ "os/exec"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
type UpgradeAction struct {
Steps []UpgradeStep `yaml:"upgrade"`
}
// UpgradeStep represents the structure of an Upgrade action
type UpgradeStep struct {
UpgradeArguments `yaml:"qliksense"`
}
// UpgradeArguments are the arguments available for the Upgrade action
type UpgradeArguments struct {
Step `yaml:",inline"`
Cr map[string]interface{} `yaml:"cr"`
}
// Upgrade deletes a provided set of Kustomize releases, supplying optional flags/params
func (m *Mixin) Upgrade() error {
payload, err := m.getPayloadData()
if err != nil {
return err
}
var action UpgradeAction
err = yaml.Unmarshal(payload, &action)
if err != nil {
return err
}
if len(action.Steps) != 1 {
return errors.Errorf("expected a single step, but got %d", len(action.Steps))
}
step := action.Steps[0]
m.executeQliksense(step.Cr)
return nil
}