docs: add plugin resource generation

This commit is contained in:
Manuel Vogel 2021-05-14 09:16:00 +02:00
parent 1594343e66
commit 2d5d9b41d8
No known key found for this signature in database
GPG key ID: 24E54F214569A8A5
4 changed files with 78 additions and 25 deletions

View file

@ -3,14 +3,33 @@
page_title: "docker_plugin Resource - terraform-provider-docker"
subcategory: ""
description: |-
Manages the lifecycle of a Docker plugin.
---
# docker_plugin (Resource)
Manages the lifecycle of a Docker plugin.
## Example Usage
```terraform
resource "docker_plugin" "sample-volume-plugin" {
name = "docker.io/tiborvass/sample-volume-plugin:latest"
}
resource "docker_plugin" "sample-volume-plugin" {
name = "tiborvass/sample-volume-plugin"
alias = "sample-volume-plugin"
enabled = false
grant_all_permissions = true
force_destroy = true
enable_timeout = 60
force_disable = true
env = [
"DEBUG=1"
]
}
```
<!-- schema generated by tfplugindocs -->
## Schema
@ -23,12 +42,12 @@ description: |-
- **alias** (String) Docker Plugin alias
- **enable_timeout** (Number) HTTP client timeout to enable the plugin
- **enabled** (Boolean)
- **env** (Set of String)
- **force_destroy** (Boolean)
- **force_disable** (Boolean) If true, then the plugin is disabled forcibly when the plugin is disabled
- **enabled** (Boolean) If `true` the plugin is enabled
- **env** (Set of String) The environment variables in the from of `KEY=VALUE`, e.g. `DEBUG=0`
- **force_destroy** (Boolean) If true, then the plugin is destroyed forcibly
- **force_disable** (Boolean) If true, then the plugin is disabled forcibly
- **grant_all_permissions** (Boolean) If true, grant all permissions necessary to run the plugin
- **grant_permissions** (Block Set) (see [below for nested schema](#nestedblock--grant_permissions))
- **grant_permissions** (Block Set) Grant specific permissions only (see [below for nested schema](#nestedblock--grant_permissions))
- **id** (String) The ID of this resource.
### Read-Only
@ -40,7 +59,14 @@ description: |-
Required:
- **name** (String)
- **value** (Set of String)
- **name** (String) The name of the permission
- **value** (Set of String) The value of the permission
## Import
Import is supported using the following syntax:
```shell
#!/bin/bash
terraform import docker_plugin.sample-volume-plugin "$(docker plugin inspect -f "{{.ID}}" tiborvass/sample-volume-plugin:latest)"
```

View file

@ -0,0 +1,2 @@
#!/bin/bash
terraform import docker_plugin.sample-volume-plugin "$(docker plugin inspect -f "{{.ID}}" tiborvass/sample-volume-plugin:latest)"

View file

@ -0,0 +1,16 @@
resource "docker_plugin" "sample-volume-plugin" {
name = "docker.io/tiborvass/sample-volume-plugin:latest"
}
resource "docker_plugin" "sample-volume-plugin" {
name = "tiborvass/sample-volume-plugin"
alias = "sample-volume-plugin"
enabled = false
grant_all_permissions = true
force_destroy = true
enable_timeout = 60
force_disable = true
env = [
"DEBUG=1"
]
}

View file

@ -6,6 +6,8 @@ import (
func resourceDockerPlugin() *schema.Resource {
return &schema.Resource{
Description: "Manages the lifecycle of a Docker plugin.",
Create: resourceDockerPluginCreate,
Read: resourceDockerPluginRead,
Update: resourceDockerPluginUpdate,
@ -13,29 +15,31 @@ func resourceDockerPlugin() *schema.Resource {
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Description: "Docker Plugin name",
Required: true,
ForceNew: true,
Description: "Docker Plugin name",
DiffSuppressFunc: diffSuppressFuncPluginName,
ValidateFunc: validateFuncPluginName,
},
"alias": {
Type: schema.TypeString,
Description: "Docker Plugin alias",
Computed: true,
Optional: true,
ForceNew: true,
Description: "Docker Plugin alias",
DiffSuppressFunc: func(k, oldV, newV string, d *schema.ResourceData) bool {
return complementTag(oldV) == complementTag(newV)
},
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Type: schema.TypeBool,
Description: "If `true` the plugin is enabled",
Optional: true,
Default: true,
},
"grant_all_permissions": {
Type: schema.TypeBool,
@ -45,18 +49,21 @@ func resourceDockerPlugin() *schema.Resource {
},
"grant_permissions": {
Type: schema.TypeSet,
Description: "Grant specific permissions only",
Optional: true,
ConflictsWith: []string{"grant_all_permissions"},
Set: dockerPluginGrantPermissionsSetFunc,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Description: "The name of the permission",
Required: true,
},
"value": {
Type: schema.TypeSet,
Required: true,
Type: schema.TypeSet,
Description: "The value of the permission",
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
@ -65,10 +72,11 @@ func resourceDockerPlugin() *schema.Resource {
},
},
"env": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeSet,
Description: "The environment variables in the from of `KEY=VALUE`, e.g. `DEBUG=0`",
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"plugin_reference": {
Type: schema.TypeString,
@ -77,18 +85,19 @@ func resourceDockerPlugin() *schema.Resource {
},
"force_destroy": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Description: "If true, then the plugin is destroyed forcibly",
Optional: true,
},
"enable_timeout": {
Type: schema.TypeInt,
Optional: true,
Description: "HTTP client timeout to enable the plugin",
Optional: true,
},
"force_disable": {
Type: schema.TypeBool,
Description: "If true, then the plugin is disabled forcibly",
Optional: true,
Description: "If true, then the plugin is disabled forcibly when the plugin is disabled",
},
},
}