package service import ( "log" podman "spud/podman" service_definition "spud/service_definition" ) func CreateService(definition service_definition.ServiceDefinition) { var err error err = podman.CreatePod(definition.Name, definition.Ports) 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) } } } /* * Stops a running service. * * The service and all its containers are stopped but not deleted. */ func StopService(name string) { err := podman.StopPod(name) if err != nil { log.Fatalf("%s", err) } }