[Agent][Deploy] - cmii update

This commit is contained in:
zeaslity
2024-06-14 10:37:40 +08:00
parent 540d69ede2
commit d86bc43b28
799 changed files with 48148 additions and 203 deletions

85
agent-deploy/z_dep/G.go Normal file → Executable file
View File

@@ -4,47 +4,45 @@ import (
"bytes"
"fmt"
"github.com/go-playground/validator/v10"
"os"
"runtime"
"text/template"
"wdd.io/agent-common/assert"
"wdd.io/agent-common/logger"
"wdd.io/agent-common/utils"
)
var ApplyFilePrefix = ""
var (
K8sDashboardApplyFilePath = ""
EmqxApplyFilePath = ""
MongoApplyFilePath = ""
RabbitMQApplyFilePath = ""
RedisApplyFilePath = ""
MySQLApplyFilePath = ""
NacosApplyFilePath = ""
PVCApplyFilePath = ""
NfsApplyFilePath = ""
NfsTestApplyFilePath = ""
BackendApplyFilePath = ""
FrontendApplyFilePath = ""
SRSApplyFilePath = ""
IngresApplyFilePath = ""
ConfigMapApplyFilePath = ""
var Asserter = assert.Asserter
var log = logger.Log
func init() {
switch runtime.GOOS {
case "linux":
ApplyFilePrefix = "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/z_bjtg/"
case "darwin": // macOS
ApplyFilePrefix = "MacOS value"
case "windows":
ApplyFilePrefix = "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\agent-deploy\\z_xjyd\\"
default:
ApplyFilePrefix = "Unknown OS"
}
_ = os.Mkdir(ApplyFilePrefix, os.ModePerm)
fmt.Printf("ApplyFilePrefix: %s\n", ApplyFilePrefix)
}
log = logger.Log
Asserter = assert.Asserter
)
type CommonEnvironmentConfig struct {
WebIP string `json:"web_ip,omitempty" valid:"required"` //A1C1IP
WebPort string `json:"web_port,omitempty" valid:"required"` //A1C1JS
HarborIP string `json:"harbor_ip,omitempty" valid:"required"` //A1C2IP
HarborPort string `json:"harbor_port,omitempty" valid:"required"` // default 8033
Namespace string `json:"namespace,omitempty" valid:"required"` // SUPREME
TagVersion string `json:"tag_version,omitempty" valid:"required"` // KIMMY
TenantEnv string `json:"tenant_env,omitempty"` // TENANT_ENV 只在内部使用
MinioPublicIP string `json:"minio_public_ip,omitempty"` // M2C1IP
MinioInnerIP string `json:"minio_inner_ip,omitempty"` // M2D2IP
NFSServerIP string `json:"nfs_server_ip,omitempty"` // N1C2IP
WebIP string `json:"web_ip,omitempty" valid:"required"` //A1C1IP
WebPort string `json:"web_port,omitempty" valid:"required"` //A1C1JS
HarborIP string `json:"harbor_ip,omitempty" valid:"required"` //A1C2IP
HarborPort string `json:"harbor_port,omitempty" valid:"required"` // default 8033
Namespace string `json:"namespace,omitempty" valid:"required"` // SUPREME
TagVersion string `json:"tag_version,omitempty" valid:"required"` // KIMMY
TenantEnv string `json:"tenant_env,omitempty"` // TENANT_ENV 只在内部使用
MinioPublicIP string `json:"minio_public_ip,omitempty"` // M2C1IP
MinioInnerIP string `json:"minio_inner_ip,omitempty"` // M2D2IP
NFSServerIP string `json:"nfs_server_ip,omitempty"` // N1C2IP
ApplyFilePrefix string
}
//func (env *CommonEnvironmentConfig) CompactEnv() {
@@ -80,6 +78,29 @@ func (env *CommonEnvironmentConfig) ParseCommonEnvToApplyFile(applyTemplate stri
return ParseEnvToApplyFile(env, applyTemplate, applyFilePath)
}
func (env *CommonEnvironmentConfig) GenerateApplyFilePath() {
Asserter.NotEmpty(env.ApplyFilePrefix, "apply file prefix is empty!")
K8sDashboardApplyFilePath = env.ApplyFilePrefix + "k8s-dashboard.yaml"
EmqxApplyFilePath = env.ApplyFilePrefix + "k8s-emqx.yaml"
MongoApplyFilePath = env.ApplyFilePrefix + "k8s-mongo.yaml"
RabbitMQApplyFilePath = env.ApplyFilePrefix + "k8s-rabbitmq.yaml"
RedisApplyFilePath = env.ApplyFilePrefix + "k8s-redis.yaml"
MySQLApplyFilePath = env.ApplyFilePrefix + "k8s-mysql.yaml"
NacosApplyFilePath = env.ApplyFilePrefix + "k8s-nacos.yaml"
PVCApplyFilePath = env.ApplyFilePrefix + "k8s-pvc.yaml"
NfsApplyFilePath = env.ApplyFilePrefix + "k8s-nfs.yaml"
NfsTestApplyFilePath = env.ApplyFilePrefix + "k8s-nfs-test.yaml"
BackendApplyFilePath = env.ApplyFilePrefix + "k8s-backend.yaml"
FrontendApplyFilePath = env.ApplyFilePrefix + "k8s-frontend.yaml"
SRSApplyFilePath = env.ApplyFilePrefix + "k8s-srs.yaml"
IngresApplyFilePath = env.ApplyFilePrefix + "k8s-ingress.yaml"
ConfigMapApplyFilePath = env.ApplyFilePrefix + "k8s-configmap.yaml"
}
func ParseEnvToApplyFile(environment any, applyTemplate string, applyFilePath string) bool {
randomString := utils.GenerateRandomString(8)