diff --git a/pkg/configmanager/asset/cluster/clusterasset.go b/pkg/configmanager/asset/cluster/clusterasset.go index f975c6d307133543f1d43b3a2c3d07bdbffe0e73..21efdc8f19970924008331a12a2d6bf523085229 100644 --- a/pkg/configmanager/asset/cluster/clusterasset.go +++ b/pkg/configmanager/asset/cluster/clusterasset.go @@ -4,8 +4,8 @@ type ClusterAsset struct { } // TODO: Init inits the cluster asset. -func (ca *ClusterAsset) Initial() ([]byte, error) { - return nil, nil +func (ca *ClusterAsset) Initial() error { + return nil } // TODO: Delete deletes the cluster asset. diff --git a/pkg/configmanager/asset/global/globalasset.go b/pkg/configmanager/asset/global/globalasset.go index ca7b3e404d42ec91e97dec7b849c95f55189cce5..f7a21b7b908ddc8d69c031175298dd2511244240 100644 --- a/pkg/configmanager/asset/global/globalasset.go +++ b/pkg/configmanager/asset/global/globalasset.go @@ -3,9 +3,16 @@ package global type GlobalAsset struct { } +var ( + GlobalConfig GlobalAsset + IsInitial = false +) + // TODO: Init inits the global asset. -func (ga *GlobalAsset) Initial() ([]byte, error) { - return nil, nil +func (ga *GlobalAsset) Initial() error { + // TODO: 将初始化的结果传给GlobalConfig + IsInitial = true + return nil } // TODO: Delete deletes the global asset. diff --git a/pkg/configmanager/manager/manager.go b/pkg/configmanager/manager/manager.go index f598892d65ced976b8d5ba48417074ea7f9eed81..e8902c2c2e10afe3744b01a927365337f224a78b 100644 --- a/pkg/configmanager/manager/manager.go +++ b/pkg/configmanager/manager/manager.go @@ -10,7 +10,6 @@ import ( ) func Init(cmd *cobra.Command) error { - globalAsset := &global.GlobalAsset{} clusterAsset := &cluster.ClusterAsset{} // Parse command line arguments. @@ -32,10 +31,19 @@ func Init(cmd *cobra.Command) error { // TODO: 设置优先级 & 参数解析 // Initialize global assets. - globalAsset.Initial() + if !global.IsInitial { + globalAsset := &global.GlobalAsset{} + err := globalAsset.Initial() + if err != nil { + return nil + } + } // Initialize cluster assets. - clusterAsset.Initial() + err := clusterAsset.Initial() + if err != nil { + return nil + } return nil }