[ Cmii ] [ Octopus ] - real project modify to use cmii operator
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user