mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-24 10:01:04 +01:00
- Introduced ContainerRuntime field in AgentConfig and AgentEnvConfig. - Added IterAgents and NumAgents functions for agent pool management. - Updated agent creation and verification endpoints to handle container runtime. - Enhanced Docker Compose template to support different container runtimes. - Added runtime endpoint to retrieve agent runtime information.
34 lines
915 B
Go
34 lines
915 B
Go
package agent
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
)
|
|
|
|
var (
|
|
installScript = `AGENT_NAME="{{.Name}}" \
|
|
AGENT_PORT="{{.Port}}" \
|
|
AGENT_CA_CERT="{{.CACert}}" \
|
|
AGENT_SSL_CERT="{{.SSLCert}}" \
|
|
{{ if eq .ContainerRuntime "nerdctl" -}}
|
|
DOCKER_SOCKET="/var/run/containerd/containerd.sock" \
|
|
RUNTIME="nerdctl" \
|
|
{{ else if eq .ContainerRuntime "podman" -}}
|
|
DOCKER_SOCKET="/var/run/podman/podman.sock" \
|
|
RUNTIME="podman" \
|
|
{{ else -}}
|
|
DOCKER_SOCKET="/var/run/docker.sock" \
|
|
RUNTIME="docker" \
|
|
{{ end -}}
|
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/yusing/godoxy/main/scripts/install-agent.sh)"`
|
|
installScriptTemplate = template.Must(template.New("install.sh").Parse(installScript))
|
|
)
|
|
|
|
func (c *AgentEnvConfig) Generate() (string, error) {
|
|
buf := bytes.NewBuffer(make([]byte, 0, 4096))
|
|
if err := installScriptTemplate.Execute(buf, c); err != nil {
|
|
return "", err
|
|
}
|
|
return buf.String(), nil
|
|
}
|