terraform-provider-docker/internal/provider/resource_docker_registry_image.go

282 lines
6.4 KiB
Go
Raw Normal View History

package provider
2020-03-24 10:34:14 -04:00
import (
"os"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2020-03-24 10:34:14 -04:00
)
func resourceDockerRegistryImage() *schema.Resource {
return &schema.Resource{
CreateContext: resourceDockerRegistryImageCreate,
ReadContext: resourceDockerRegistryImageRead,
DeleteContext: resourceDockerRegistryImageDelete,
UpdateContext: resourceDockerRegistryImageUpdate,
2020-03-24 10:34:14 -04:00
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"keep_remotely": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"build": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"suppress_output": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"remote_context": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"no_cache": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"remove": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"force_remove": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"pull_parent": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"isolation": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"cpu_set_cpus": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"cpu_set_mems": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"cpu_shares": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"cpu_quota": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"cpu_period": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"memory": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"memory_swap": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"cgroup_parent": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"network_mode": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"shm_size": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"dockerfile": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
Default: "Dockerfile",
ForceNew: true,
},
"ulimit": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"hard": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Required: true,
ForceNew: true,
},
"soft": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeInt,
Required: true,
ForceNew: true,
},
},
},
},
"build_args": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"auth_config": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"host_name": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Required: true,
},
"user_name": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"password": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"auth": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"email": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"server_address": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"identity_token": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
"registry_token": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
},
},
},
},
"context": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: func(val interface{}) string {
// the context hash is stored to identify changes in the context files
dockerContextTarPath, _ := buildDockerImageContextTar(val.(string))
defer os.Remove(dockerContextTarPath)
contextTarHash, _ := getDockerImageContextTarHash(dockerContextTarPath)
return val.(string) + ":" + contextTarHash
},
},
"labels": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"squash": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"cache_from": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"security_opt": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"extra_hosts": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"target": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"session_id": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"platform": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"version": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"build_id": {
2020-03-24 10:34:14 -04:00
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
},
},
"sha256_digest": {
Type: schema.TypeString,
Computed: true,
},
},
}
}