MCPcopy Create free account
hub / github.com/devld/go-drive / init_

Function init_

drive/script/utils.go:156–187  ·  view source on GitHub ↗
(ctx context.Context, data, config types.SM, driveUtils drive_util.DriveUtils)

Source from the content-addressed store, hash-verified

154}
155
156func init_(ctx context.Context, data, config types.SM, driveUtils drive_util.DriveUtils) error {
157 cfg, e := driveUtils.Data.Load("_script")
158 if e != nil {
159 return e
160 }
161 if cfg["_script"] != "" {
162 // _script is not modifiable
163 delete(data, "_script")
164 } else if data["_script"] != "" {
165 cfg["_script"] = data["_script"]
166 if e := driveUtils.Data.Save(types.SM{"_script": data["_script"]}); e != nil {
167 return e
168 }
169 }
170
171 vm, e := createVm(ctx, driveUtils.Config, cfg["_script"])
172 if e != nil {
173 return e
174 }
175 defer func() { _ = vm.Dispose() }()
176
177 initConfigVal, e := vm.GetValue("__driveInit")
178 if e != nil {
179 return e
180 }
181 if initConfigVal.IsNil() {
182 return nil
183 }
184
185 _, e = vm.Call(ctx, "__driveInit", s.NewContext(vm, ctx), data, config, newScriptDriveUtils(driveUtils))
186 return e
187}
188
189// parsePoolConfig parses config like this: MaxTotal,MaxIdle,MinIdle,IdleTime
190func parsePoolConfig(arg string) (*s.VMPoolConfig, error) {

Callers

nothing calls this directly

Calls 8

createVmFunction · 0.85
newScriptDriveUtilsFunction · 0.85
IsNilMethod · 0.80
LoadMethod · 0.65
SaveMethod · 0.65
DisposeMethod · 0.65
GetValueMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected