Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused func param #92

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions pkg/providers/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ func (d *docker) GetID() string {
func newDocker(imageURL string) (Provider, error) {
imageURL = strings.TrimPrefix(imageURL, "docker://")

repo, tag, err := parseImage(imageURL)
if err != nil {
return nil, err
}
repo, tag := parseImage(imageURL)

client, err := client.NewClientWithOpts()
if err != nil {
Expand All @@ -70,10 +67,9 @@ func newDocker(imageURL string) (Provider, error) {
return &docker{repo: repo, tag: tag, client: client}, nil
}

// parseImage parses the image returning the repository, tag
// and an error if it fails. ParseImage handles non-canonical
// URLs like `hashicorp/terraform`.
func parseImage(imageURL string) (string, string, error) {
// parseImage parses the image returning the repository and tag.
// It handles non-canonical URLs like `hashicorp/terraform`.
func parseImage(imageURL string) (string, string) {
image := imageURL
tag := "latest"
if i := strings.LastIndex(imageURL, ":"); i > -1 {
Expand All @@ -85,5 +81,5 @@ func parseImage(imageURL string) (string, string, error) {
image = "library/" + image
}

return image, tag, nil
return image, tag
}
4 changes: 1 addition & 3 deletions pkg/providers/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ func TestParseImage(t *testing.T) {

for _, test := range cases {
t.Run(test.name, func(t *testing.T) {
repo, tag, err := parseImage(test.imageURL)
repo, tag := parseImage(test.imageURL)
switch {
case test.expectedRepo != repo:
t.Errorf("expected repo was %s, got %s", test.expectedRepo, repo)
case test.expectedTag != tag:
t.Errorf("expected tag was %s, got %s", test.expectedTag, tag)
case test.withErr != (err != nil):
t.Errorf("expected err != nil to be %v", test.withErr)
}
})
}
Expand Down