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

fix: set "latest" tag when tag isn't specified #117

Merged
merged 1 commit into from
Jan 6, 2021

Conversation

suzuki-shunsuke
Copy link
Collaborator

@suzuki-shunsuke suzuki-shunsuke commented Jan 6, 2021

Close #116

FqName: fmt.Sprintf("%s/%s:%s", pullOpts.Registry, pullOpts.Repository, pullOpts.Tag),

When pullOpts.Tag is empty, FqName is invalid format %s/%s:.

Test

$ terraform version
Terraform v0.13.5
+ provider registry.terraform.io/kreuzwerker/docker v2.9.0
resource "docker_registry_image" "eshopwebmvc" {
  name = "suzukishunsuke/test"

  build {
    context = "."
  }
}

Dockerfile

FROM alpine:3.11.6

AS IS

$ terraform apply
Error: Error building docker image: Error response from daemon: invalid reference format
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # docker_registry_image.eshopwebmvc will be created
  + resource "docker_registry_image" "eshopwebmvc" {
      + id            = (known after apply)
      + keep_remotely = false
      + name          = "suzukishunsuke/test"
      + sha256_digest = (known after apply)

      + build {
          + context    = ".:8fffdc288f367f3686c3e5f35cce89a9848e75efb0de71aeec67209d7c4a43c7"
          + dockerfile = "Dockerfile"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

docker_registry_image.eshopwebmvc: Creating...

Error: Error building docker image: Error response from daemon: invalid reference format

  on main.tf line 19, in resource "docker_registry_image" "eshopwebmvc":
  19: resource "docker_registry_image" "eshopwebmvc" {

TO BE

$ terraform apply
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # docker_registry_image.eshopwebmvc will be created
  + resource "docker_registry_image" "eshopwebmvc" {
      + id            = (known after apply)
      + keep_remotely = false
      + name          = "suzukishunsuke/test"
      + sha256_digest = (known after apply)

      + build {
          + context    = ".:815ed2590ead7bbd8a61066d5b80ddf72c6db697bd0d36bac13e71f102791d5b"
          + dockerfile = "Dockerfile"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

docker_registry_image.eshopwebmvc: Creating...
docker_registry_image.eshopwebmvc: Still creating... [10s elapsed]
docker_registry_image.eshopwebmvc: Creation complete after 17s [id=sha256:39eda93d15866957feaee28f8fc5adb545276a64147445c64992ef69804dbf01]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

@suzuki-shunsuke suzuki-shunsuke added the bug Something isn't working label Jan 6, 2021
@suzuki-shunsuke suzuki-shunsuke marked this pull request as draft January 6, 2021 15:32
@suzuki-shunsuke suzuki-shunsuke added r/image Relates to the image resource r/registry_image labels Jan 6, 2021
@suzuki-shunsuke suzuki-shunsuke changed the title [WIP] fix: set "latest" to tag when tag isn't specified [WIP] fix: set "latest" tag when tag isn't specified Jan 6, 2021
@suzuki-shunsuke suzuki-shunsuke changed the title [WIP] fix: set "latest" tag when tag isn't specified fix: set "latest" tag when tag isn't specified Jan 6, 2021
@suzuki-shunsuke suzuki-shunsuke marked this pull request as ready for review January 6, 2021 15:57
@mavogel mavogel added this to the v2.10.0 milestone Jan 6, 2021
@mavogel mavogel merged commit 0ef85ad into master Jan 6, 2021
@mavogel mavogel deleted the fix/complement-latest-tag-when-tag-is-empty branch January 6, 2021 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r/image Relates to the image resource r/registry_image
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building with tagless name fails with "invalid reference format"
2 participants