2024-06-02 06:03:47 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
podman "spud/podman"
|
|
|
|
service_definition "spud/service_definition"
|
|
|
|
)
|
|
|
|
|
|
|
|
func CreateService(definition service_definition.ServiceDefinition) {
|
|
|
|
var err error
|
|
|
|
|
2024-06-03 03:49:37 +00:00
|
|
|
err = podman.CreatePod(definition.Name, definition.Ports)
|
2024-06-02 06:03:47 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("%s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
knownVolumes := map[string]string{}
|
|
|
|
|
|
|
|
for _, volume := range definition.Volumes {
|
|
|
|
namespacedName := definition.Name + "_" + volume.Name
|
|
|
|
podman.CreateVolume(namespacedName, true)
|
|
|
|
knownVolumes[volume.Name] = namespacedName
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, container := range definition.Containers {
|
|
|
|
if err = podman.CreateContainer(container, knownVolumes, definition.Name); err != nil {
|
|
|
|
log.Fatalf("%s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|