From 389a5f2031ae2e7d9762f269018026ab871b980f Mon Sep 17 00:00:00 2001 From: kirinnee Date: Mon, 13 Nov 2023 23:01:34 +0800 Subject: [PATCH] fix: account for docker.io --- docker_executor/executor.go | 5 +++-- docker_executor/template_executor.go | 5 +++-- main.go | 22 ++++++++++++++++++++++ tasks/Taskfile.docker.yaml | 4 ++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docker_executor/executor.go b/docker_executor/executor.go index cee9c7c..254da78 100644 --- a/docker_executor/executor.go +++ b/docker_executor/executor.go @@ -3,6 +3,7 @@ package docker_executor import ( "fmt" "net/http" + "strings" "time" ) @@ -24,7 +25,7 @@ func (e Executor) missingPluginsImages(images []DockerImageReference) []DockerIm } found := false for _, i := range images { - if i.Reference == plugin.DockerReference && i.Tag == plugin.DockerTag { + if strings.HasSuffix(plugin.DockerReference, i.Reference) && i.Tag == plugin.DockerTag { found = true break } @@ -45,7 +46,7 @@ func (e Executor) missingProcessorImages(images []DockerImageReference) []Docker } found := false for _, i := range images { - if i.Reference == processor.DockerReference && i.Tag == processor.DockerTag { + if strings.HasSuffix(processor.DockerReference, i.Reference) && i.Tag == processor.DockerTag { found = true break } diff --git a/docker_executor/template_executor.go b/docker_executor/template_executor.go index 6a9859c..215ec6d 100644 --- a/docker_executor/template_executor.go +++ b/docker_executor/template_executor.go @@ -3,6 +3,7 @@ package docker_executor import ( "fmt" "net/http" + "strings" "time" ) @@ -49,7 +50,7 @@ func (de TemplateExecutor) missingTemplateVolumeImage(images []DockerImageRefere Tag: template.BlobDockerTag, } for _, image := range images { - if image.Reference == i.Reference && image.Tag == i.Tag { + if strings.HasSuffix(i.Reference, image.Reference) && image.Tag == i.Tag { return false, i } } @@ -63,7 +64,7 @@ func (de TemplateExecutor) missingTemplateImages(images []DockerImageReference) Tag: template.TemplateDockerTag, } for _, image := range images { - if image.Reference == i.Reference && image.Tag == i.Tag { + if strings.HasSuffix(i.Reference, image.Reference) && image.Tag == i.Tag { return false, i } } diff --git a/main.go b/main.go index adf2351..cb0b0c5 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/AtomiCloud/sulfone.boron/docker_executor" + "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/urfave/cli/v2" "log" @@ -16,6 +17,27 @@ func main() { app := &cli.App{ Name: "sulfone-boron", Commands: []*cli.Command{ + { + Name: "s", + Action: func(c *cli.Context) error { + ctx := context.Background() + dCli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) + if err != nil { + panic(err) + } + defer func(dCli *client.Client) { + _ = dCli.Close() + }(dCli) + images, err := dCli.ImageList(ctx, types.ImageListOptions{}) + if err != nil { + panic(err) + } + for _, image := range images { + fmt.Println(image.RepoTags) + } + return nil + }, + }, { Name: "start", Flags: []cli.Flag{ diff --git a/tasks/Taskfile.docker.yaml b/tasks/Taskfile.docker.yaml index a760af3..36170d6 100644 --- a/tasks/Taskfile.docker.yaml +++ b/tasks/Taskfile.docker.yaml @@ -4,12 +4,12 @@ tasks: build: desc: "Build docker images" cmds: - - docker build . -t {{.USER}}{{.PLATFORM}}-{{.SERVICE}}:{{.CLI_ARGS |default "latest"}} + - docker build . --load -t {{.USER}}{{.PLATFORM}}-{{.SERVICE}}:{{.CLI_ARGS |default "latest"}} run: desc: "Run docker images" cmds: - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock {{.USER}}{{.PLATFORM}}-{{.SERVICE}}:{{.CLI_ARGS |default "latest"}} setup - - docker run --rm -it -p 9000:9000 --network cyanprint -v /var/run/docker.sock:/var/run/docker.sock {{.USER}}{{.PLATFORM}}-{{.SERVICE}}:{{.CLI_ARGS |default "latest"}} start -r {{.REGISTRY_HOST}} + - docker run --rm -it -p 9000:9000 --network cyanprint -v /var/run/docker.sock:/var/run/docker.sock {{.USER}}{{.PLATFORM}}-{{.SERVICE}}:{{.CLI_ARGS |default "latest"}} # start -r {{.REGISTRY_HOST}} push: desc: "Push docker images" cmds: