drone_plugin/config_handler/real_config.go

55 lines
1.4 KiB
Go
Raw Permalink Normal View History

2021-12-28 20:42:51 +08:00
package config_handler
import (
"git.icechen.cn/pkg/drone_plugin/git"
"gopkg.in/yaml.v3"
)
const TypeMonorepo = "monorepo" // 单库类型
type Config struct {
Kind string `json:"kind" yaml:"kind"`
Type string `json:"type" yaml:"type"`
Name string `json:"name" yaml:"name"`
Api ApiList `json:"api" yaml:"api"`
Service ServiceList `json:"service" yaml:"service"`
}
type (
ApiList []Api
Api struct {
2022-01-10 17:51:52 +08:00
Namespace string `json:"namespace" yaml:"namespace"`
2022-01-04 00:21:33 +08:00
Name string `json:"name" yaml:"name"`
2022-01-10 22:10:01 +08:00
AliasName string `json:"alias_name" yaml:"alias_name"`
2022-01-04 00:21:33 +08:00
Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"`
Port string `json:"port" yaml:"port"`
Host string `json:"host" yaml:"host"`
Path string `json:"path" yaml:"path"`
2021-12-28 20:42:51 +08:00
}
)
2022-01-10 17:51:52 +08:00
2021-12-28 20:42:51 +08:00
type (
ServiceList []Service
Service struct {
2022-01-10 17:51:52 +08:00
Namespace string `json:"namespace" yaml:"namespace"`
2022-01-04 00:21:33 +08:00
Name string `json:"name" yaml:"name"`
2022-01-10 22:10:01 +08:00
AliasName string `json:"alias_name" yaml:"alias_name"`
2022-01-04 00:21:33 +08:00
Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"`
Port string `json:"port" yaml:"port"`
2021-12-28 20:42:51 +08:00
}
)
// getRealConfig 获取原始配置文件内容
func getRealConfig(client git.Client) (Config, error) {
var c Config
realConfigContent, err := client.GetRealConfig()
if err != nil {
return c, err
}
err = yaml.Unmarshal([]byte(realConfigContent), &c)
return c, err
}