MCPcopy
hub / github.com/TarsCloud/TarsGo / getConfig

Method getConfig

tars/rconfig.go:114–132  ·  view source on GitHub ↗

GetConfig gets the remote config and save it to the path, also return the content.

(info configf.ConfigInfo)

Source from the content-addressed store, hash-verified

112
113// GetConfig gets the remote config and save it to the path, also return the content.
114func (c *RConf) getConfig(info configf.ConfigInfo) (config string, err error) {
115 var set string
116 if v, ok := c.comm.GetProperty("setdivision"); ok {
117 set = v
118 }
119 info.Setdivision = set
120 ret, err := c.tc.LoadConfigByInfo(&info, &config, c.comm.Client.Context())
121 if err != nil {
122 return config, err
123 }
124 if ret != 0 {
125 return config, fmt.Errorf("ret %d", ret)
126 }
127 err = saveFile(c.path, info.Filename, config)
128 if err != nil {
129 return config, err
130 }
131 return config, nil
132}
133
134func saveFile(path string, filename string, content string) error {
135 err := os.WriteFile(fmt.Sprintf("%s/%s", path, filename), []byte(content), 0644)

Callers 2

GetAppConfigMethod · 0.95
GetConfigMethod · 0.95

Calls 5

saveFileFunction · 0.85
GetPropertyMethod · 0.80
LoadConfigByInfoMethod · 0.65
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected