Skip to content

Commit

Permalink
fix: account for docker.io
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Nov 13, 2023
1 parent ca55738 commit 389a5f2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docker_executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package docker_executor
import (
"fmt"
"net/http"
"strings"
"time"
)

Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions docker_executor/template_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package docker_executor
import (
"fmt"
"net/http"
"strings"
"time"
)

Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down
22 changes: 22 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions tasks/Taskfile.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 389a5f2

Please # to comment.