agentScriptsFromProto converts a slice of proto scripts into the agentScriptsParams struct needed for database insertion.
(scripts []*sdkproto.Script)
| 3541 | // agentScriptsFromProto converts a slice of proto scripts into the |
| 3542 | // agentScriptsParams struct needed for database insertion. |
| 3543 | func agentScriptsFromProto(scripts []*sdkproto.Script) agentScriptsParams { |
| 3544 | params := agentScriptsParams{ |
| 3545 | LogSourceIDs: make([]uuid.UUID, 0, len(scripts)), |
| 3546 | LogSourceDisplayNames: make([]string, 0, len(scripts)), |
| 3547 | LogSourceIcons: make([]string, 0, len(scripts)), |
| 3548 | |
| 3549 | ScriptIDs: make([]uuid.UUID, 0, len(scripts)), |
| 3550 | ScriptDisplayNames: make([]string, 0, len(scripts)), |
| 3551 | ScriptLogPaths: make([]string, 0, len(scripts)), |
| 3552 | ScriptSources: make([]string, 0, len(scripts)), |
| 3553 | ScriptCron: make([]string, 0, len(scripts)), |
| 3554 | ScriptTimeout: make([]int32, 0, len(scripts)), |
| 3555 | ScriptStartBlocksLogin: make([]bool, 0, len(scripts)), |
| 3556 | ScriptRunOnStart: make([]bool, 0, len(scripts)), |
| 3557 | ScriptRunOnStop: make([]bool, 0, len(scripts)), |
| 3558 | } |
| 3559 | |
| 3560 | for _, script := range scripts { |
| 3561 | params.LogSourceIDs = append(params.LogSourceIDs, uuid.New()) |
| 3562 | params.LogSourceDisplayNames = append(params.LogSourceDisplayNames, script.GetDisplayName()) |
| 3563 | params.LogSourceIcons = append(params.LogSourceIcons, script.GetIcon()) |
| 3564 | |
| 3565 | params.ScriptIDs = append(params.ScriptIDs, uuid.New()) |
| 3566 | params.ScriptDisplayNames = append(params.ScriptDisplayNames, script.GetDisplayName()) |
| 3567 | params.ScriptLogPaths = append(params.ScriptLogPaths, script.GetLogPath()) |
| 3568 | params.ScriptSources = append(params.ScriptSources, script.GetScript()) |
| 3569 | params.ScriptCron = append(params.ScriptCron, script.GetCron()) |
| 3570 | params.ScriptTimeout = append(params.ScriptTimeout, script.GetTimeoutSeconds()) |
| 3571 | params.ScriptStartBlocksLogin = append(params.ScriptStartBlocksLogin, script.GetStartBlocksLogin()) |
| 3572 | params.ScriptRunOnStart = append(params.ScriptRunOnStart, script.GetRunOnStart()) |
| 3573 | params.ScriptRunOnStop = append(params.ScriptRunOnStop, script.GetRunOnStop()) |
| 3574 | } |
| 3575 | |
| 3576 | return params |
| 3577 | } |
| 3578 | |
| 3579 | // insertAgentScriptsAndLogSources inserts log sources and scripts for an agent (or |
| 3580 | // subagent). It expects the caller to have built the agentScriptsParams, |
no test coverage detected