feat: service 完成
This commit is contained in:
@@ -3,6 +3,8 @@ package deploy
|
||||
import (
|
||||
"embed"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"git.icechen.cn/pkg/wujian_develop_tool/config"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
@@ -13,24 +15,40 @@ import (
|
||||
//go:embed "*"
|
||||
var deployDir embed.FS
|
||||
|
||||
func GenDeploy(namespace string, name string, aliasName string) error {
|
||||
func GenDeploy(namespace string, api config.Api) error {
|
||||
color.Green("正在生成deploy...")
|
||||
|
||||
// deploy 文件夹
|
||||
deployDirPath := "app/api/" + name + "/deploy"
|
||||
deployDirPath := api.Root + "/deploy"
|
||||
err := os.MkdirAll(deployDirPath, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
host := api.Host
|
||||
if host == "" {
|
||||
host = "api.seamlesser.com"
|
||||
}
|
||||
|
||||
path := api.Path
|
||||
if path == "" {
|
||||
path = fmt.Sprintf("/%s/%s/?(.*)", namespace, api.Name)
|
||||
}
|
||||
|
||||
data := map[string]string{
|
||||
"NameSpace": namespace,
|
||||
"AppName": api.Name,
|
||||
"AliasName": api.AliasName,
|
||||
"Port": api.Port,
|
||||
"Host": host,
|
||||
"Path": path}
|
||||
|
||||
// value.yaml
|
||||
valuesTemplate, err := deployDir.ReadFile("values.tpl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = util.TemplateToFile(deployDirPath+"/values.yaml",
|
||||
string(valuesTemplate),
|
||||
map[string]string{"NameSpace": namespace, "AppName": name, "AliasName": aliasName})
|
||||
err = util.TemplateToFile(deployDirPath+"/values.yaml", string(valuesTemplate), data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -40,15 +58,13 @@ func GenDeploy(namespace string, name string, aliasName string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = util.TemplateToFile(deployDirPath+"/Chart.yaml",
|
||||
string(chartTemplate),
|
||||
map[string]string{"NameSpace": namespace, "AppName": name, "AliasName": aliasName})
|
||||
err = util.TemplateToFile(deployDirPath+"/Chart.yaml", string(chartTemplate), data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// templates 文件夹
|
||||
templatesDirPath := "app/api/" + name + "/deploy/templates"
|
||||
templatesDirPath := api.Root + "/deploy/templates"
|
||||
err = os.MkdirAll(templatesDirPath, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,6 +2,6 @@ nameSpace: {{ .NameSpace }}
|
||||
aliasName: {{ .AliasName }}
|
||||
image: reg.icechen.cn/{{ .NameSpace }}/api-{{ .AppName }}
|
||||
imageTag: latest
|
||||
port: 8080
|
||||
host: api.seamlesser.com
|
||||
path: /{{ .NameSpace }}/{{ .AppName }}/?(.*)
|
||||
port: {{ .Port }}
|
||||
host: {{ .Host }}
|
||||
path: {{ .Path }}
|
||||
Reference in New Issue
Block a user