Skip to content

Commit

Permalink
Implement "upgrade plan" support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedosin committed May 3, 2024
1 parent 1e93d52 commit 8b61e23
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 53 deletions.
3 changes: 0 additions & 3 deletions cmd/plugin/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ type initOptions struct {

const (
capiOperatorProviderName = "capi-operator"
// We have to specify a version here, because if we set "latest", clusterctl libs will try to fetch metadata.yaml file for the latest
// release and fail since CAPI operator doesn't provide this file.
capiOperatorManifestsURL = "https://github.com/kubernetes-sigs/cluster-api-operator/releases/v0.1.0/operator-components.yaml"
)

var initOpts = &initOptions{}
Expand Down
12 changes: 3 additions & 9 deletions cmd/plugin/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,9 @@ func init() {

func sortUpgradeItems(plan upgradePlan) {
sort.Slice(plan.Providers, func(i, j int) bool {
return plan.Providers[i].GetType() < plan.Providers[j].GetType() ||
(plan.Providers[i].GetType() == plan.Providers[j].GetType() && plan.Providers[i].GetName() < plan.Providers[j].GetName()) ||
(plan.Providers[i].GetType() == plan.Providers[j].GetType() && plan.Providers[i].GetName() == plan.Providers[j].GetName() && plan.Providers[i].GetNamespace() < plan.Providers[j].GetNamespace())
})
}

func sortUpgradePlans(upgradePlans []upgradePlan) {
sort.Slice(upgradePlans, func(i, j int) bool {
return upgradePlans[i].Contract < upgradePlans[j].Contract
return plan.Providers[i].Type < plan.Providers[j].Type ||
(plan.Providers[i].Type == plan.Providers[j].Type && plan.Providers[i].Name < plan.Providers[j].Name) ||
(plan.Providers[i].Type == plan.Providers[j].Type && plan.Providers[i].Name == plan.Providers[j].Name && plan.Providers[i].Namespace < plan.Providers[j].Namespace)
})
}

Expand Down
Loading

0 comments on commit 8b61e23

Please sign in to comment.