Files
kubevela/pkg/controller/setup.go
wyike ff6fcd9f10 support component revision based rollout (#1919)
* WIP almost finish main logic

WIP make reviewable

finish manual test

fix rollout plan related test

WIP refactro some logic

WIP finish e2e-test

* fix failed e2e-test

* fix failed interagtion test

* move rollout to trait packege

* modify e2e-test testdata change apiVersion

* add v1alpha1 to scheme in test

* more wait time

* fix comment

* split rollout test

fix makefile

* rename test name

delete equal quata

try to fix

fix

* add more test
2021-07-20 16:53:39 +08:00

73 lines
2.5 KiB
Go

/*
Copyright 2019 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package controller
import (
ctrl "sigs.k8s.io/controller-runtime"
"github.com/oam-dev/kubevela/pkg/controller/standard.oam.dev/v1alpha1/rollout"
controller "github.com/oam-dev/kubevela/pkg/controller/core.oam.dev"
"github.com/oam-dev/kubevela/pkg/controller/core.oam.dev/v1alpha2/core/scopes/healthscope"
"github.com/oam-dev/kubevela/pkg/controller/core.oam.dev/v1alpha2/core/traits/manualscalertrait"
"github.com/oam-dev/kubevela/pkg/controller/core.oam.dev/v1alpha2/core/workloads/containerizedworkload"
"github.com/oam-dev/kubevela/pkg/controller/common"
"github.com/oam-dev/kubevela/pkg/controller/standard.oam.dev/v1alpha1/podspecworkload"
"github.com/oam-dev/kubevela/pkg/controller/utils"
)
// Setup workload controllers.
func Setup(mgr ctrl.Manager, disableCaps string, args controller.Args) error {
var functions []func(ctrl.Manager, controller.Args) error
switch disableCaps {
case common.DisableNoneCaps:
functions = []func(ctrl.Manager, controller.Args) error{
podspecworkload.Setup,
manualscalertrait.Setup,
containerizedworkload.Setup,
healthscope.Setup,
rollout.Setup,
}
case common.DisableAllCaps:
default:
disableCapsSet := utils.StoreInSet(disableCaps)
if !disableCapsSet.Contains(common.PodspecWorkloadControllerName) {
functions = append(functions, podspecworkload.Setup)
}
if !disableCapsSet.Contains(common.ManualScalerTraitControllerName) {
functions = append(functions, manualscalertrait.Setup)
}
if !disableCapsSet.Contains(common.ContainerizedWorkloadControllerName) {
functions = append(functions, containerizedworkload.Setup)
}
if !disableCapsSet.Contains(common.HealthScopeControllerName) {
functions = append(functions, healthscope.Setup)
}
if !disableCapsSet.Contains(common.RolloutControllerName) {
functions = append(functions, rollout.Setup)
}
}
for _, setup := range functions {
if err := setup(mgr, args); err != nil {
return err
}
}
return nil
}