docs: add plugin data source generation

This commit is contained in:
Manuel Vogel 2021-05-14 08:48:05 +02:00
parent 7b7a5d83e0
commit 00ee4507f9
No known key found for this signature in database
GPG key ID: 24E54F214569A8A5
3 changed files with 32 additions and 18 deletions

View file

@ -3,29 +3,35 @@
page_title: "docker_plugin Data Source - terraform-provider-docker"
subcategory: ""
description: |-
Reads the local Docker plugin. The plugin must be installed locally.
---
# docker_plugin (Data Source)
Reads the local Docker plugin. The plugin must be installed locally.
## Example Usage
```terraform
data "docker_plugin" "sample-volume-plugin" {
alias = "sample-volume-plugin:latest"
}
```
<!-- schema generated by tfplugindocs -->
## Schema
### Optional
- **alias** (String) Docker Plugin alias
- **alias** (String) The alias of the Docker plugin. If the tag is omitted, `:latest` is complemented to the attribute value.
- **id** (String) The ID of this resource.
- **name** (String)
- **name** (String) The plugin name. If the tag is omitted, `:latest` is complemented to the attribute value.
### Read-Only
- **enabled** (Boolean)
- **env** (Set of String)
- **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`
- **grant_all_permissions** (Boolean) If true, grant all permissions necessary to run the plugin
- **plugin_reference** (String) Docker Plugin Reference
- **plugin_reference** (String) The Docker Plugin Reference

View file

@ -0,0 +1,3 @@
data "docker_plugin" "sample-volume-plugin" {
alias = "sample-volume-plugin:latest"
}

View file

@ -10,6 +10,8 @@ import (
func dataSourceDockerPlugin() *schema.Resource {
return &schema.Resource{
Description: "Reads the local Docker plugin. The plugin must be installed locally.",
Read: dataSourceDockerPluginRead,
Schema: map[string]*schema.Schema{
@ -18,38 +20,41 @@ func dataSourceDockerPlugin() *schema.Resource {
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Description: "The plugin name. If the tag is omitted, `:latest` is complemented to the attribute value.",
Optional: true,
},
"alias": {
Type: schema.TypeString,
Description: "The alias of the Docker plugin. If the tag is omitted, `:latest` is complemented to the attribute value.",
Optional: true,
Description: "Docker Plugin alias",
},
"plugin_reference": {
Type: schema.TypeString,
Description: "Docker Plugin Reference",
Description: "The Docker Plugin Reference",
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Type: schema.TypeBool,
Description: "If `true` the plugin is enabled",
Computed: true,
},
"grant_all_permissions": {
Type: schema.TypeBool,
Computed: true,
Description: "If true, grant all permissions necessary to run the plugin",
Computed: true,
},
"env": {
Type: schema.TypeSet,
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`",
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}
var errDataSourceKeyIsMissing = errors.New("One of id or alias must be assigned")
var errDataSourceKeyIsMissing = errors.New("one of id or alias must be assigned")
func getDataSourcePluginKey(d *schema.ResourceData) (string, error) {
id, idOK := d.GetOk("id")