Create a list of known jobs

This commit is contained in:
nemunaire 2021-05-09 18:02:23 +02:00
commit 1fd0a2d8f3
5 changed files with 46 additions and 17 deletions

View file

@ -41,7 +41,7 @@ func PsName() (ret map[string]string, err error) {
return ret, err
}
func Run(image string, cmd []string, mounts []mount.Mount) (string, error) {
func Run(jobtype string, image string, cmd []string, mounts []mount.Mount) (string, error) {
cli, err := newCli()
if err != nil {
return "", err
@ -63,7 +63,7 @@ func Run(image string, cmd []string, mounts []mount.Mount) (string, error) {
Architecture: "amd64",
OS: "linux",
},
genContainerName(image),
genContainerName(jobtype),
)
if err != nil {
return "", err

View file

@ -7,12 +7,12 @@ import (
"github.com/nemunaire/minifaas/engine"
)
func genContainerName(image string) string {
func genContainerName(jobtype string) string {
uuid := make([]byte, 24)
_, err := rand.Read(uuid)
if err != nil {
panic(err.Error())
}
return fmt.Sprintf("%s-%x", engine.GenContainerPrefix(image), uuid)
return fmt.Sprintf("%s%x", engine.GenContainerPrefix(jobtype), uuid)
}

View file

@ -5,6 +5,6 @@ import (
"fmt"
)
func GenContainerPrefix(image string) string {
return fmt.Sprintf("minifaas-%x-", sha256.Sum224([]byte(image)))
func GenContainerPrefix(jobtype string) string {
return fmt.Sprintf("minifaas-%x-", sha256.Sum224([]byte(jobtype)))
}