mirror of https://gitee.com/openkylin/genmai.git
!63 修改ConfigKernel等名字->ExplorerConfigKernel,添加ExploreConfigBase说明
Merge pull request !63 from a-alpha/alpha-dev
This commit is contained in:
commit
be94d881dd
|
@ -98,17 +98,24 @@ type ConfigCommon struct {
|
|||
// other fields
|
||||
}
|
||||
|
||||
type ExplorerCommonBase interface {
|
||||
type ExplorerConfigBase interface {
|
||||
// 每个结构体实现,应该完成这个函数以返回具体类型的Config
|
||||
// 由于需要用到具体类型,且因为go语言的限制,需要开发者编
|
||||
// 写具体类型。
|
||||
// 比如:
|
||||
// func (ek *ExplorerKernel)GetExplorerConfigKernel() (config *ExplorerConfigKernel, rc error) {
|
||||
//
|
||||
// GetExplorerConfig*() (config *Config*, rc error) {
|
||||
}
|
||||
|
||||
type ExplorerCommon struct {
|
||||
EcConfigParser ConfigParserBase
|
||||
EcConfig ExplorerCommonBase
|
||||
EcConfig ExplorerConfigBase
|
||||
/* */
|
||||
isSetup bool
|
||||
}
|
||||
|
||||
func (ec *ExplorerCommon)Setup(parser ConfigParserBase, config ExplorerCommonBase) {
|
||||
func (ec *ExplorerCommon)Setup(parser ConfigParserBase, config ExplorerConfigBase) {
|
||||
ec.EcConfigParser = parser
|
||||
ec.EcConfig = config
|
||||
/* */
|
||||
|
|
|
@ -39,7 +39,7 @@ import (
|
|||
sandbox "main/src/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ConfigDBus struct {
|
||||
type ExplorerConfigDBus struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
|
|
@ -41,7 +41,7 @@ import (
|
|||
sandbox "main/src/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ConfigKernel struct {
|
||||
type ExplorerConfigKernel struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
@ -55,7 +55,7 @@ type ExplorerKernel struct {
|
|||
ExplorerCommon
|
||||
/* */
|
||||
//EkConfigParser ConfigParserBase
|
||||
//EkConfig ConfigKernel
|
||||
//EkConfig ExplorerConfigKernel
|
||||
/* */
|
||||
EkSandbox sandbox.SandboxBase
|
||||
/* */
|
||||
|
@ -65,8 +65,8 @@ type ExplorerKernel struct {
|
|||
|
||||
///////////////////////////////
|
||||
// ExplorerKernel functions
|
||||
func (ek *ExplorerKernel)GetConfigKernel() (config *ConfigKernel, rc error) {
|
||||
cf, ret := ek.ExplorerCommon.EcConfig.(*ConfigKernel)
|
||||
func (ek *ExplorerKernel)GetExplorerConfigKernel() (config *ExplorerConfigKernel, rc error) {
|
||||
cf, ret := ek.ExplorerCommon.EcConfig.(*ExplorerConfigKernel)
|
||||
/* */
|
||||
if (true == ret) {
|
||||
rc = nil
|
||||
|
@ -109,7 +109,7 @@ func (ek *ExplorerKernel)StartWithPath(path string) error {
|
|||
func (ek *ExplorerKernel)Start() (err error) {
|
||||
fmt.Println("\n>>Start()>>.>")
|
||||
|
||||
config, rc := ek.GetConfigKernel()
|
||||
config, rc := ek.GetExplorerConfigKernel()
|
||||
err = rc
|
||||
if (nil != err) {
|
||||
return err
|
||||
|
|
|
@ -39,7 +39,7 @@ import (
|
|||
sandbox "main/src/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ConfigSystem struct {
|
||||
type ExplorerConfigSystem struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
|
|
@ -37,7 +37,7 @@ import (
|
|||
sandbox "main/src/genmai/Sandbox"
|
||||
)
|
||||
|
||||
type ConfigWeb struct {
|
||||
type ExplorerConfigWeb struct {
|
||||
FormatVer int
|
||||
Id string
|
||||
Belong string
|
||||
|
|
|
@ -77,7 +77,7 @@ func Test() {
|
|||
fmt.Println("\n>>YAML>>\n")
|
||||
fmt.Print(config)
|
||||
|
||||
mystruct := ConfigKernel{}
|
||||
mystruct := ExplorerConfigKernel{}
|
||||
// mystruct.Map2Struct(config["configs"].(map[string]string))
|
||||
//err := MapToStruct(config, &mystruct)
|
||||
err := mapstructure.Decode(config, &mystruct)
|
||||
|
@ -96,7 +96,7 @@ func Test() {
|
|||
fmt.Println("\n>>JSON>>\n")
|
||||
fmt.Print(json_config_c)
|
||||
|
||||
json_struct := ConfigKernel{}
|
||||
json_struct := ExplorerConfigKernel{}
|
||||
json_err := mapstructure.Decode(json_config_c, &json_struct)
|
||||
|
||||
fmt.Println(json_err)
|
||||
|
@ -125,7 +125,7 @@ func Test() {
|
|||
fmt.Println("\n\n>>ExplorerKernel yaml>>\n")
|
||||
|
||||
exp_kernel_y := ExplorerKernel{}
|
||||
exp_kernel_y.Setup(&ConfigParserYAML{}, &ConfigKernel{})
|
||||
exp_kernel_y.Setup(&ConfigParserYAML{}, &ExplorerConfigKernel{})
|
||||
err = exp_kernel_y.LoadConfig("/home/alpha/Developments/kylinprojects/genmai/data/common/CVE-2021-3156.yaml")
|
||||
fmt.Println(err)
|
||||
|
||||
|
@ -145,7 +145,7 @@ func Test() {
|
|||
fmt.Println("\n\n>>ExplorerKernel json>>\n")
|
||||
|
||||
exp_kernel_j := ExplorerKernel{}
|
||||
exp_kernel_j.Setup(&ConfigParserJSON{}, &ConfigKernel{})
|
||||
exp_kernel_j.Setup(&ConfigParserJSON{}, &ExplorerConfigKernel{})
|
||||
err = exp_kernel_j.LoadConfig("/home/alpha/Developments/kylinprojects/genmai/data/common/CVE-2021-3156.json")
|
||||
fmt.Println(err)
|
||||
|
||||
|
|
Loading…
Reference in New Issue