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

feat: support Docker plugin #35

Merged
merged 36 commits into from
Jan 8, 2021
Merged

feat: support Docker plugin #35

merged 36 commits into from
Jan 8, 2021

Conversation

suzuki-shunsuke
Copy link
Collaborator

@suzuki-shunsuke suzuki-shunsuke commented Dec 22, 2020

Close #24

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Dec 22, 2020
@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch 4 times, most recently from bce6936 to c4a2ee1 Compare December 29, 2020 09:34
@suzuki-shunsuke
Copy link
Collaborator Author

suzuki-shunsuke commented Dec 29, 2020

I have implemented the basic feature.

Example

resource "docker_plugin" "sample-volume-plugin" {
  plugin_reference      = "docker.io/tiborvass/sample-volume-plugin:latest"
  alias                 = "sample-volume-plugin:latest"
  disabled              = true
  grant_all_permissions = true
  disable_when_set      = true
  force_destroy         = true
  enable_timeout        = 60
  force_disable         = true
  env = [
    "DEBUG=1"
  ]
}

Note

plugin_reference and alias must be full path. Otherwise, after terraform apply is run, there would be diffs of them.

For example,

resource "docker_plugin" "sample-volume-plugin" {
  plugin_reference      = "tiborvass/sample-volume-plugin" # must be "docker.io/tiborvass/sample-volume-plugin:latest"
  alias                 = "sample" # must be "sample:latest"
}
$ terraform apply
docker_plugin.sshfs: Refreshing state... [id=7973bfc2ba539a01b7598c55facf1d9c61f016fd49735072f1bd0848aee53b75]
docker_plugin.sample-volume-plugin: Refreshing state... [id=98169cdf6c522ac34f5f67217534b56017722087ab8671135f76f62c8bb12ba8]

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_plugin.sample-volume-plugin will be created
  + resource "docker_plugin" "sample-volume-plugin" {
      + alias            = "sample"
      + env              = (known after apply)
      + id               = (known after apply)
      + plugin_reference = "tiborvass/sample-volume-plugin"
    }

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_plugin.sample-volume-plugin: Creating...
docker_plugin.sample-volume-plugin: Still creating... [10s elapsed]
docker_plugin.sample-volume-plugin: Creation complete after 11s [id=27784976e1471c1e473a901a0a02055ddc8bc1c9dec9c44d81a49d516c0c28f9]

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

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

docker_plugin.sample-volume-plugin: Refreshing state... [id=27784976e1471c1e473a901a0a02055ddc8bc1c9dec9c44d81a49d516c0c28f9]
docker_plugin.sshfs: Refreshing state... [id=7973bfc2ba539a01b7598c55facf1d9c61f016fd49735072f1bd0848aee53b75]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # docker_plugin.sample-volume-plugin must be replaced
-/+ resource "docker_plugin" "sample-volume-plugin" {
      ~ alias            = "sample:latest" -> "sample" # forces replacement
      - disabled         = false -> null
      ~ env              = [
          - "DEBUG=0",
        ] -> (known after apply)
      ~ id               = "27784976e1471c1e473a901a0a02055ddc8bc1c9dec9c44d81a49d516c0c28f9" -> (known after apply)
      ~ plugin_reference = "docker.io/tiborvass/sample-volume-plugin:latest" -> "tiborvass/sample-volume-plugin" # forces replacement
    }

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

Check List

@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from c4a2ee1 to c43ecb5 Compare December 29, 2020 09:44
@suzuki-shunsuke suzuki-shunsuke changed the title [WIP] feat: support Docker plugin feat: support Docker plugin Dec 29, 2020
@suzuki-shunsuke suzuki-shunsuke marked this pull request as ready for review December 29, 2020 09:56
@suzuki-shunsuke suzuki-shunsuke removed the request for review from mavogel December 29, 2020 10:27
@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from e07dacb to e892830 Compare December 29, 2020 10:30
@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from e892830 to 26624c6 Compare December 29, 2020 10:41
@mavogel
Copy link
Contributor

mavogel commented Dec 30, 2020

I propose that we will first merge this PR here and then rebase #102 for the TF SDK update on it. We are ready4review right @suzuki-shunsuke ?

@mavogel mavogel added this to the v2.10.0 milestone Dec 30, 2020
@suzuki-shunsuke
Copy link
Collaborator Author

@mavogel Yes. Please review.

@innovate-invent
Copy link
Contributor

For some reason a critical comment is being hidden by github: #35 (comment)

@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from 58fccc6 to 03b2187 Compare December 30, 2020 23:56
@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from cb8b75d to 735df8a Compare December 31, 2020 00:04
@suzuki-shunsuke
Copy link
Collaborator Author

suzuki-shunsuke commented Dec 31, 2020

I'm writing tests of getDockerPluginGrantPermissions and found that it doesn't work as expected.
I'm investigating the issue.

@suzuki-shunsuke
Copy link
Collaborator Author

#35 (comment)

I'm writing tests of getDockerPluginGrantPermissions and found that it doesn't work as expected.
I'm investigating the issue.

Oh, sorry. There is a typo in tests.
It has been solved.

Copy link
Contributor

@mavogel mavogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See conversations for details. Awesome work till here. Let's get this ready

@suzuki-shunsuke
Copy link
Collaborator Author

Updated. Please review.
#35 (comment)

docker/resource_docker_plugin.go Outdated Show resolved Hide resolved
docker/data_source_docker_plugin.go Outdated Show resolved Hide resolved
```
$ cd docker
$ ag -l 'Description:.*\.",' | xargs -n 1 sed -i 's/Description:\(.*\)\.",/Description:\1",/'
```
@suzuki-shunsuke suzuki-shunsuke force-pushed the feat/support-docker-plugin branch from 0950bba to b82956b Compare January 8, 2021 03:16
Copy link
Contributor

@mavogel mavogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @suzuki-shunsuke and @innovate-invent for the fruitful discussion 🚀

@mavogel mavogel merged commit c927a8c into master Jan 8, 2021
@mavogel mavogel deleted the feat/support-docker-plugin branch January 8, 2021 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for docker plugins
3 participants