[ Cmii ] [ Octopus ] - real project modify to use cmii operator

This commit is contained in:
zeaslity
2024-02-23 15:13:24 +08:00
parent 6e629f84df
commit 9447801212
19 changed files with 151 additions and 33 deletions

View File

@@ -81,14 +81,8 @@ func (op *CmiiK8sOperator) changeOperatorEnv(cmiiEnv string) {
// ok
op.checkAndBuildCmiiK8sOperator()
if strings.Contains(cmiiEnv, "dev") {
op.CurrentClient = op.DevClient
op.CurrentConfig = op.DevConfig
} else {
op.CurrentClient = op.CoreClient
op.CurrentConfig = op.CoreConfig
}
// first key
op.CurrentNamespace = ""
if strings.Contains(cmiiEnv, "dev") {
if strings.Contains(cmiiEnv, "devf") {
@@ -120,13 +114,38 @@ func (op *CmiiK8sOperator) changeOperatorEnv(cmiiEnv string) {
op.CurrentNamespace = uavms
}
// key feature
if op.CurrentNamespace == "" {
op.CurrentNamespace = dev
op.CurrentNamespace = cmiiEnv
} else {
if strings.Contains(cmiiEnv, "dev") {
op.CurrentClient = op.DevClient
op.CurrentConfig = op.DevConfig
} else {
op.CurrentClient = op.CoreClient
op.CurrentConfig = op.CoreConfig
}
}
log.InfoF("[k8s env] - current env is => %s", op.CurrentNamespace)
}
func (op *CmiiK8sOperator) BuildCurrentClientFromConfig(realClientConfig string) {
log.InfoF("[BuildCurrentClientFromConfig] - build real k8s operator client !")
realEnvConfig, err := clientcmd.RESTConfigFromKubeConfig([]byte(realClientConfig))
if err != nil {
msg := "[BuildCurrentClientFromConfig] - build real k8s operator error !"
log.Error(msg)
panic(msg)
}
op.CurrentConfig = realEnvConfig
op.CurrentClient, err = kubernetes.NewForConfig(realEnvConfig)
if err != nil {
panic(err.Error())
}
}
func (op *CmiiK8sOperator) DeploymentAll(cmiiEnv string) []v1.Deployment {
op.changeOperatorEnv(cmiiEnv)