2021-03-18 03:30:54 -04:00
|
|
|
package provider
|
2020-03-24 10:34:14 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
|
2021-03-18 03:30:54 -04:00
|
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
2020-03-24 10:34:14 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func resourceDockerRegistryImage() *schema.Resource {
|
|
|
|
|
return &schema.Resource{
|
2021-03-18 03:30:54 -04:00
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
|
2020-12-02 06:06:39 -05:00
|
|
|
"build": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
MaxItems: 1,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2020-12-02 06:06:39 -05:00
|
|
|
"suppress_output": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"remote_context": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"no_cache": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"remove": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"force_remove": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"pull_parent": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"isolation": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cpu_set_cpus": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cpu_set_mems": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cpu_shares": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cpu_quota": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cpu_period": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"memory": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"memory_swap": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cgroup_parent": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"network_mode": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"shm_size": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"dockerfile": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "Dockerfile",
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"ulimit": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2020-12-02 06:06:39 -05:00
|
|
|
"name": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"hard": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"soft": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeInt,
|
|
|
|
|
Required: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"build_args": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeMap,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"auth_config": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Elem: &schema.Resource{
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2020-12-02 06:06:39 -05:00
|
|
|
"host_name": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"user_name": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"password": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"auth": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"email": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"server_address": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"identity_token": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"registry_token": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"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
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"labels": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeMap,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"squash": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"cache_from": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"security_opt": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"extra_hosts": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeList,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
Elem: &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"target": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"session_id": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"platform": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"version": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
2020-12-02 06:06:39 -05:00
|
|
|
"build_id": {
|
2020-03-24 10:34:14 -04:00
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
ForceNew: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"sha256_digest": {
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|