mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 05:07:44 +08:00
31 lines
616 B
Go
31 lines
616 B
Go
package boot
|
|
|
|
import (
|
|
"github.com/gogf/gf/contrib/config/kubecm/v2"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
)
|
|
|
|
const (
|
|
configmapName = "test-configmap"
|
|
dataItemInConfigmap = "config.yaml"
|
|
)
|
|
|
|
func init() {
|
|
var (
|
|
err error
|
|
ctx = gctx.GetInitCtx()
|
|
)
|
|
// Create kubecm Client that implements gcfg.Adapter.
|
|
adapter, err := kubecm.New(gctx.GetInitCtx(), kubecm.Config{
|
|
ConfigMap: configmapName,
|
|
DataItem: dataItemInConfigmap,
|
|
})
|
|
if err != nil {
|
|
g.Log().Fatalf(ctx, `%+v`, err)
|
|
}
|
|
|
|
// Change the adapter of default configuration instance.
|
|
g.Cfg().SetAdapter(adapter)
|
|
}
|