drone_plugin/config_handler/real_config.go

47 lines
1.0 KiB
Go
Raw 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 {
Name string `json:"name" yaml:"name"`
Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"`
}
)
type (
ServiceList []Service
Service struct {
Name string `json:"name" yaml:"name"`
Root string `json:"root" yaml:"root"`
Type string `json:"type" yaml:"type"`
}
)
// 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
}