Skip to content

Commit

Permalink
Move to path.Join for repo + image_name: (#607)
Browse files Browse the repository at this point in the history
## Description


With this a tink-worker can be started without a registry defined and templates in Tink server can specify any registry.

## Why is this needed


Currently, if a container registry is not specified then the container image will start with a `/`. This will cause tink worker to fail to pull/run the container. With this change, if a container registry is not specified the `/` will not be added and the contain image will be pulled from the container runtime's default registry. For containerd and docker (which is what Hook runs) the default registry is `docker.io`.

Fixes: #

## How Has This Been Tested?





## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
mergify[bot] authored Apr 18, 2022
2 parents 4769080 + 442fabd commit 685a7f6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/tink-worker/worker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"io"
"path"

"github.com/docker/docker/api/types"
"github.com/pkg/errors"
Expand Down Expand Up @@ -42,7 +43,7 @@ func (m *containerManager) PullImage(ctx context.Context, image string) error {
}
authStr := base64.URLEncoding.EncodeToString(encodedJSON)

out, err := m.cli.ImagePull(ctx, m.registryDetails.Registry+"/"+image, types.ImagePullOptions{RegistryAuth: authStr})
out, err := m.cli.ImagePull(ctx, path.Join(m.registryDetails.Registry, image), types.ImagePullOptions{RegistryAuth: authStr})
if err != nil {
return errors.Wrap(err, "DOCKER PULL")
}
Expand Down

0 comments on commit 685a7f6

Please sign in to comment.