mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-20 22:59:42 -05:00
style: format with gofumpt
https://github.com/mvdan/gofumpt ``` $ gofumpt -l -s -w docker/* ```
This commit is contained in:
parent
cf34e9e1b1
commit
f213e3a348
30 changed files with 149 additions and 161 deletions
|
|
@ -13,55 +13,55 @@ func dataSourceDockerNetwork() *schema.Resource {
|
||||||
Read: dataSourceDockerNetworkRead,
|
Read: dataSourceDockerNetworkRead,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"id": &schema.Schema{
|
"id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"driver": &schema.Schema{
|
"driver": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"options": &schema.Schema{
|
"options": {
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"internal": &schema.Schema{
|
"internal": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"ipam_config": &schema.Schema{
|
"ipam_config": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"subnet": &schema.Schema{
|
"subnet": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"ip_range": &schema.Schema{
|
"ip_range": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"gateway": &schema.Schema{
|
"gateway": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"aux_address": &schema.Schema{
|
"aux_address": {
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -70,7 +70,7 @@ func dataSourceDockerNetwork() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"scope": &schema.Schema{
|
"scope": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
@ -81,7 +81,6 @@ func dataSourceDockerNetwork() *schema.Resource {
|
||||||
type ipamMap map[string]interface{}
|
type ipamMap map[string]interface{}
|
||||||
|
|
||||||
func dataSourceDockerNetworkRead(d *schema.ResourceData, meta interface{}) error {
|
func dataSourceDockerNetworkRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
name, nameOk := d.GetOk("name")
|
name, nameOk := d.GetOk("name")
|
||||||
_, idOk := d.GetOk("id")
|
_, idOk := d.GetOk("id")
|
||||||
|
|
||||||
|
|
@ -92,7 +91,6 @@ func dataSourceDockerNetworkRead(d *schema.ResourceData, meta interface{}) error
|
||||||
client := meta.(*ProviderConfig).DockerClient
|
client := meta.(*ProviderConfig).DockerClient
|
||||||
|
|
||||||
network, err := client.NetworkInspect(context.Background(), name.(string), types.NetworkInspectOptions{})
|
network, err := client.NetworkInspect(context.Background(), name.(string), types.NetworkInspectOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Could not find docker network: %s", err)
|
return fmt.Errorf("Could not find docker network: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ func TestAccDockerNetworkDataSource_basic(t *testing.T) {
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccDockerNetworkDataSourceConfig,
|
Config: testAccDockerNetworkDataSourceConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("data.docker_network.bridge", "name", "bridge"),
|
resource.TestCheckResourceAttr("data.docker_network.bridge", "name", "bridge"),
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ func dataSourceDockerRegistryImageRead(d *schema.ResourceData, meta interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
digest, err := getImageDigest(pullOpts.Registry, pullOpts.Repository, pullOpts.Tag, username, password, false)
|
digest, err := getImageDigest(pullOpts.Registry, pullOpts.Repository, pullOpts.Tag, username, password, false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
digest, err = getImageDigest(pullOpts.Registry, pullOpts.Repository, pullOpts.Tag, username, password, true)
|
digest, err = getImageDigest(pullOpts.Registry, pullOpts.Repository, pullOpts.Tag, username, password, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -116,7 +115,6 @@ func getImageDigest(registry, image, tag, username, password string, fallback bo
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Error during registry request: %s", err)
|
return "", fmt.Errorf("Error during registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +132,6 @@ func getImageDigest(registry, image, tag, username, password string, fallback bo
|
||||||
params.Set("service", auth["service"])
|
params.Set("service", auth["service"])
|
||||||
params.Set("scope", auth["scope"])
|
params.Set("scope", auth["scope"])
|
||||||
tokenRequest, err := http.NewRequest("GET", auth["realm"]+"?"+params.Encode(), nil)
|
tokenRequest, err := http.NewRequest("GET", auth["realm"]+"?"+params.Encode(), nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Error creating registry request: %s", err)
|
return "", fmt.Errorf("Error creating registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +141,6 @@ func getImageDigest(registry, image, tag, username, password string, fallback bo
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenResponse, err := client.Do(tokenRequest)
|
tokenResponse, err := client.Do(tokenRequest)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Error during registry request: %s", err)
|
return "", fmt.Errorf("Error during registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +162,6 @@ func getImageDigest(registry, image, tag, username, password string, fallback bo
|
||||||
|
|
||||||
req.Header.Set("Authorization", "Bearer "+token.Token)
|
req.Header.Set("Authorization", "Bearer "+token.Token)
|
||||||
digestResponse, err := client.Do(req)
|
digestResponse, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Error during registry request: %s", err)
|
return "", fmt.Errorf("Error during registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,12 @@ func mapToLabelSet(labels map[string]string) *schema.Set {
|
||||||
|
|
||||||
var labelSchema = &schema.Resource{
|
var labelSchema = &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"label": &schema.Schema{
|
"label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Description: "Name of the label",
|
Description: "Name of the label",
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"value": &schema.Schema{
|
"value": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Description: "Value of the label",
|
Description: "Value of the label",
|
||||||
Required: true,
|
Required: true,
|
||||||
|
|
@ -70,11 +70,11 @@ var labelSchema = &schema.Resource{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//gatherImmediateSubkeys given an incomplete attribute identifier, find all
|
// gatherImmediateSubkeys given an incomplete attribute identifier, find all
|
||||||
//the strings (if any) that appear after this one in the various dot-separated
|
// the strings (if any) that appear after this one in the various dot-separated
|
||||||
//identifiers.
|
// identifiers.
|
||||||
func gatherImmediateSubkeys(attrs map[string]string, partialKey string) []string {
|
func gatherImmediateSubkeys(attrs map[string]string, partialKey string) []string {
|
||||||
var immediateSubkeys = []string{}
|
immediateSubkeys := []string{}
|
||||||
for k := range attrs {
|
for k := range attrs {
|
||||||
prefix := partialKey + "."
|
prefix := partialKey + "."
|
||||||
if strings.HasPrefix(k, prefix) {
|
if strings.HasPrefix(k, prefix) {
|
||||||
|
|
@ -90,7 +90,7 @@ func gatherImmediateSubkeys(attrs map[string]string, partialKey string) []string
|
||||||
func getLabelMapForPartialKey(attrs map[string]string, partialKey string) map[string]string {
|
func getLabelMapForPartialKey(attrs map[string]string, partialKey string) map[string]string {
|
||||||
setIDs := gatherImmediateSubkeys(attrs, partialKey)
|
setIDs := gatherImmediateSubkeys(attrs, partialKey)
|
||||||
|
|
||||||
var labelMap = map[string]string{}
|
labelMap := map[string]string{}
|
||||||
for _, id := range setIDs {
|
for _, id := range setIDs {
|
||||||
if id == "#" {
|
if id == "#" {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func TestMigrateServiceLabelState_empty_labels(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//first validate that we build that correctly
|
// first validate that we build that correctly
|
||||||
v0Config := terraform.NewResourceConfigRaw(v0State)
|
v0Config := terraform.NewResourceConfigRaw(v0State)
|
||||||
warns, errs := resourceDockerServiceV0().Validate(v0Config)
|
warns, errs := resourceDockerServiceV0().Validate(v0Config)
|
||||||
if len(warns) > 0 || len(errs) > 0 {
|
if len(warns) > 0 || len(errs) > 0 {
|
||||||
|
|
@ -83,7 +83,7 @@ func TestMigrateServiceLabelState_with_labels(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
//first validate that we build that correctly
|
// first validate that we build that correctly
|
||||||
v0Config := terraform.NewResourceConfigRaw(v0State)
|
v0Config := terraform.NewResourceConfigRaw(v0State)
|
||||||
warns, errs := resourceDockerServiceV0().Validate(v0Config)
|
warns, errs := resourceDockerServiceV0().Validate(v0Config)
|
||||||
if len(warns) > 0 || len(errs) > 0 {
|
if len(warns) > 0 || len(errs) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,10 @@ import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testAccProviders map[string]terraform.ResourceProvider
|
var (
|
||||||
var testAccProvider *schema.Provider
|
testAccProviders map[string]terraform.ResourceProvider
|
||||||
|
testAccProvider *schema.Provider
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
testAccProvider = Provider().(*schema.Provider)
|
testAccProvider = Provider().(*schema.Provider)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
@ -62,7 +61,6 @@ func resourceDockerConfigCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
func resourceDockerConfigRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceDockerConfigRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*ProviderConfig).DockerClient
|
client := meta.(*ProviderConfig).DockerClient
|
||||||
config, _, err := client.ConfigInspectWithRaw(context.Background(), d.Id())
|
config, _, err := client.ConfigInspectWithRaw(context.Background(), d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARN] Config (%s) not found, removing from state", d.Id())
|
log.Printf("[WARN] Config (%s) not found, removing from state", d.Id())
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"context"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
)
|
)
|
||||||
|
|
@ -35,6 +35,7 @@ func TestAccDockerConfig_basic(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccDockerConfig_basicUpdatable(t *testing.T) {
|
func TestAccDockerConfig_basicUpdatable(t *testing.T) {
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ func resourceDockerContainer() *schema.Resource {
|
||||||
Version: 1,
|
Version: 1,
|
||||||
Type: resourceDockerContainerV1().CoreConfigSchema().ImpliedType(),
|
Type: resourceDockerContainerV1().CoreConfigSchema().ImpliedType(),
|
||||||
Upgrade: func(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
|
Upgrade: func(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
|
||||||
//TODO do the ohter V0-to-V1 migration, unless we're okay
|
// TODO do the ohter V0-to-V1 migration, unless we're okay
|
||||||
//with breaking for users who straggled on their docker
|
// with breaking for users who straggled on their docker
|
||||||
//provider version
|
// provider version
|
||||||
|
|
||||||
return migrateContainerLabels(rawState), nil
|
return migrateContainerLabels(rawState), nil
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -16,8 +17,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/mount"
|
"github.com/docker/docker/api/types/mount"
|
||||||
|
|
@ -28,9 +27,7 @@ import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var creationTime time.Time
|
||||||
creationTime time.Time
|
|
||||||
)
|
|
||||||
|
|
||||||
func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -431,9 +428,9 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
tw := tar.NewWriter(buf)
|
tw := tar.NewWriter(buf)
|
||||||
if executable {
|
if executable {
|
||||||
mode = 0744
|
mode = 0o744
|
||||||
} else {
|
} else {
|
||||||
mode = 0644
|
mode = 0o644
|
||||||
}
|
}
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
Name: file,
|
Name: file,
|
||||||
|
|
@ -809,9 +806,11 @@ type byPortAndProtocol []string
|
||||||
func (s byPortAndProtocol) Len() int {
|
func (s byPortAndProtocol) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s byPortAndProtocol) Swap(i, j int) {
|
func (s byPortAndProtocol) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s byPortAndProtocol) Less(i, j int) bool {
|
func (s byPortAndProtocol) Less(i, j int) bool {
|
||||||
iSplit := strings.Split(string(s[i]), "/")
|
iSplit := strings.Split(string(s[i]), "/")
|
||||||
iPort, _ := strconv.Atoi(iSplit[0])
|
iPort, _ := strconv.Atoi(iSplit[0])
|
||||||
|
|
@ -821,7 +820,7 @@ func (s byPortAndProtocol) Less(i, j int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenContainerPorts(in nat.PortMap) []interface{} {
|
func flattenContainerPorts(in nat.PortMap) []interface{} {
|
||||||
var out = make([]interface{}, 0)
|
out := make([]interface{}, 0)
|
||||||
|
|
||||||
var internalPortKeys []string
|
var internalPortKeys []string
|
||||||
for portAndProtocolKeys := range in {
|
for portAndProtocolKeys := range in {
|
||||||
|
|
@ -846,8 +845,9 @@ func flattenContainerPorts(in nat.PortMap) []interface{} {
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenContainerNetworks(in *types.NetworkSettings) []interface{} {
|
func flattenContainerNetworks(in *types.NetworkSettings) []interface{} {
|
||||||
var out = make([]interface{}, 0)
|
out := make([]interface{}, 0)
|
||||||
if in == nil || in.Networks == nil || len(in.Networks) == 0 {
|
if in == nil || in.Networks == nil || len(in.Networks) == 0 {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
@ -912,7 +912,6 @@ func mapTypeMapValsToStringSlice(typeMap map[string]interface{}) []string {
|
||||||
|
|
||||||
func fetchDockerContainer(ID string, client *client.Client) (*types.Container, error) {
|
func fetchDockerContainer(ID string, client *client.Client) (*types.Container, error) {
|
||||||
apiContainers, err := client.ContainerList(context.Background(), types.ContainerListOptions{All: true})
|
apiContainers, err := client.ContainerList(context.Background(), types.ContainerListOptions{All: true})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error fetching container information from Docker: %s\n", err)
|
return nil, fmt.Errorf("Error fetching container information from Docker: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -973,6 +972,7 @@ func ulimitsToDockerUlimits(extraUlimits *schema.Set) []*units.Ulimit {
|
||||||
|
|
||||||
return retExtraUlimits
|
return retExtraUlimits
|
||||||
}
|
}
|
||||||
|
|
||||||
func extraHostsSetToDockerExtraHosts(extraHosts *schema.Set) []string {
|
func extraHostsSetToDockerExtraHosts(extraHosts *schema.Set) []string {
|
||||||
retExtraHosts := []string{}
|
retExtraHosts := []string{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,11 @@ type byPort []mappedPort
|
||||||
func (s byPort) Len() int {
|
func (s byPort) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s byPort) Swap(i, j int) {
|
func (s byPort) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s byPort) Less(i, j int) bool {
|
func (s byPort) Less(i, j int) bool {
|
||||||
return s[i].internal < s[j].internal
|
return s[i].internal < s[j].internal
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package docker
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -15,8 +16,6 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
|
|
@ -2071,6 +2070,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerPortConfig = `
|
const testAccDockerContainerPortConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "nginx:latest"
|
name = "nginx:latest"
|
||||||
|
|
@ -2087,6 +2087,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerMultiplePortConfig = `
|
const testAccDockerContainerMultiplePortConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "nginx:latest"
|
name = "nginx:latest"
|
||||||
|
|
@ -2160,6 +2161,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerNoStartConfig = `
|
const testAccDockerContainerNoStartConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "nginx:latest"
|
name = "nginx:latest"
|
||||||
|
|
@ -2173,6 +2175,7 @@ resource "docker_container" "foo" {
|
||||||
must_run = false
|
must_run = false
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerNetworksIPv4AddressConfig = `
|
const testAccDockerContainerNetworksIPv4AddressConfig = `
|
||||||
resource "docker_network" "test" {
|
resource "docker_network" "test" {
|
||||||
name = "tf-test"
|
name = "tf-test"
|
||||||
|
|
@ -2193,6 +2196,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerNetworksIPv6AddressConfig = `
|
const testAccDockerContainerNetworksIPv6AddressConfig = `
|
||||||
resource "docker_network" "test" {
|
resource "docker_network" "test" {
|
||||||
name = "tf-test"
|
name = "tf-test"
|
||||||
|
|
@ -2215,6 +2219,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerNetworksDualStackAddressConfig = `
|
const testAccDockerContainerNetworksDualStackAddressConfig = `
|
||||||
resource "docker_network" "test" {
|
resource "docker_network" "test" {
|
||||||
name = "tf-test"
|
name = "tf-test"
|
||||||
|
|
@ -2242,6 +2247,7 @@ resource "docker_container" "foo" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerRmConfig = `
|
const testAccDockerContainerRmConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "busybox:latest"
|
name = "busybox:latest"
|
||||||
|
|
@ -2254,6 +2260,7 @@ resource "docker_image" "foo" {
|
||||||
rm = true
|
rm = true
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerReadOnlyConfig = `
|
const testAccDockerContainerReadOnlyConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "busybox:latest"
|
name = "busybox:latest"
|
||||||
|
|
@ -2266,6 +2273,7 @@ resource "docker_image" "foo" {
|
||||||
read_only = true
|
read_only = true
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerAttachConfig = `
|
const testAccDockerContainerAttachConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "busybox:latest"
|
name = "busybox:latest"
|
||||||
|
|
@ -2279,6 +2287,7 @@ resource "docker_image" "foo" {
|
||||||
must_run = false
|
must_run = false
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerLogsConfig = `
|
const testAccDockerContainerLogsConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "busybox:latest"
|
name = "busybox:latest"
|
||||||
|
|
@ -2294,6 +2303,7 @@ resource "docker_container" "foo" {
|
||||||
must_run = false
|
must_run = false
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccDockerContainerExitCodeConfig = `
|
const testAccDockerContainerExitCodeConfig = `
|
||||||
resource "docker_image" "foo" {
|
resource "docker_image" "foo" {
|
||||||
name = "busybox:latest"
|
name = "busybox:latest"
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
|
|
||||||
func resourceDockerContainerV1() *schema.Resource {
|
func resourceDockerContainerV1() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
//This is only used for state migration, so the CRUD
|
// This is only used for state migration, so the CRUD
|
||||||
//callbacks are no longer relevant
|
// callbacks are no longer relevant
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"bytes"
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/image/build"
|
"github.com/docker/cli/cli/command/image/build"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ func testAccDockerImageDestroy(s *terraform.State) error {
|
||||||
func TestAccDockerImage_build(t *testing.T) {
|
func TestAccDockerImage_build(t *testing.T) {
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
dfPath := path.Join(wd, "Dockerfile")
|
dfPath := path.Join(wd, "Dockerfile")
|
||||||
ioutil.WriteFile(dfPath, []byte(testDockerFileExample), 0644)
|
ioutil.WriteFile(dfPath, []byte(testDockerFileExample), 0o644)
|
||||||
defer os.Remove(dfPath)
|
defer os.Remove(dfPath)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,8 @@ func resourceDockerNetwork() *schema.Resource {
|
||||||
|
|
||||||
func resourceDockerNetworkV0() *schema.Resource {
|
func resourceDockerNetworkV0() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
//This is only used for state migration, so the CRUD
|
// This is only used for state migration, so the CRUD
|
||||||
//callbacks are no longer relevant
|
// callbacks are no longer relevant
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
|
@ -207,7 +206,7 @@ func resourceDockerNetworkRemoveRefreshFunc(
|
||||||
// TODO mavogel: separate structure file
|
// TODO mavogel: separate structure file
|
||||||
// TODO 2: seems like we can replace the set hash generation with plain lists -> #219
|
// TODO 2: seems like we can replace the set hash generation with plain lists -> #219
|
||||||
func flattenIpamConfigSpec(in []network.IPAMConfig) *schema.Set { // []interface{} {
|
func flattenIpamConfigSpec(in []network.IPAMConfig) *schema.Set { // []interface{} {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
log.Printf("[DEBUG] flatten ipam %d: %#v", i, v)
|
log.Printf("[DEBUG] flatten ipam %d: %#v", i, v)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
|
|
|
||||||
|
|
@ -26,119 +26,119 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Default: false,
|
Default: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
"build": &schema.Schema{
|
"build": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"suppress_output": &schema.Schema{
|
"suppress_output": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"remote_context": &schema.Schema{
|
"remote_context": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"no_cache": &schema.Schema{
|
"no_cache": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"remove": &schema.Schema{
|
"remove": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"force_remove": &schema.Schema{
|
"force_remove": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"pull_parent": &schema.Schema{
|
"pull_parent": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"isolation": &schema.Schema{
|
"isolation": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cpu_set_cpus": &schema.Schema{
|
"cpu_set_cpus": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cpu_set_mems": &schema.Schema{
|
"cpu_set_mems": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cpu_shares": &schema.Schema{
|
"cpu_shares": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cpu_quota": &schema.Schema{
|
"cpu_quota": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cpu_period": &schema.Schema{
|
"cpu_period": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"memory": &schema.Schema{
|
"memory": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"memory_swap": &schema.Schema{
|
"memory_swap": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cgroup_parent": &schema.Schema{
|
"cgroup_parent": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"network_mode": &schema.Schema{
|
"network_mode": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"shm_size": &schema.Schema{
|
"shm_size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"dockerfile": &schema.Schema{
|
"dockerfile": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "Dockerfile",
|
Default: "Dockerfile",
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"ulimit": &schema.Schema{
|
"ulimit": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"hard": &schema.Schema{
|
"hard": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"soft": &schema.Schema{
|
"soft": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -146,7 +146,7 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"build_args": &schema.Schema{
|
"build_args": {
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -154,47 +154,47 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"auth_config": &schema.Schema{
|
"auth_config": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"host_name": &schema.Schema{
|
"host_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"user_name": &schema.Schema{
|
"user_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"password": &schema.Schema{
|
"password": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"auth": &schema.Schema{
|
"auth": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"email": &schema.Schema{
|
"email": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"server_address": &schema.Schema{
|
"server_address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"identity_token": &schema.Schema{
|
"identity_token": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"registry_token": &schema.Schema{
|
"registry_token": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"context": &schema.Schema{
|
"context": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -206,7 +206,7 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
return val.(string) + ":" + contextTarHash
|
return val.(string) + ":" + contextTarHash
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"labels": &schema.Schema{
|
"labels": {
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -214,12 +214,12 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"squash": &schema.Schema{
|
"squash": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"cache_from": &schema.Schema{
|
"cache_from": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -227,7 +227,7 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"security_opt": &schema.Schema{
|
"security_opt": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -235,7 +235,7 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extra_hosts": &schema.Schema{
|
"extra_hosts": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
@ -243,27 +243,27 @@ func resourceDockerRegistryImage() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"target": &schema.Schema{
|
"target": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"session_id": &schema.Schema{
|
"session_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"platform": &schema.Schema{
|
"platform": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"version": &schema.Schema{
|
"version": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"build_id": &schema.Schema{
|
"build_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ type internalPushImageOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createImageBuildOptions(buildOptions map[string]interface{}) types.ImageBuildOptions {
|
func createImageBuildOptions(buildOptions map[string]interface{}) types.ImageBuildOptions {
|
||||||
|
|
||||||
mapOfInterfacesToMapOfStrings := func(mapOfInterfaces map[string]interface{}) map[string]string {
|
mapOfInterfacesToMapOfStrings := func(mapOfInterfaces map[string]interface{}) map[string]string {
|
||||||
mapOfStrings := make(map[string]string, len(mapOfInterfaces))
|
mapOfStrings := make(map[string]string, len(mapOfInterfaces))
|
||||||
for k, v := range mapOfInterfaces {
|
for k, v := range mapOfInterfaces {
|
||||||
|
|
@ -133,7 +132,6 @@ func createImageBuildOptions(buildOptions map[string]interface{}) types.ImageBui
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildDockerRegistryImage(client *client.Client, buildOptions map[string]interface{}, fqName string) error {
|
func buildDockerRegistryImage(client *client.Client, buildOptions map[string]interface{}, fqName string) error {
|
||||||
|
|
||||||
type ErrorDetailMessage struct {
|
type ErrorDetailMessage struct {
|
||||||
Code int `json:"code,omitempty"`
|
Code int `json:"code,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
|
|
@ -213,7 +211,6 @@ func buildDockerImageContextTar(buildContext string) (string, error) {
|
||||||
defer tw.Close()
|
defer tw.Close()
|
||||||
|
|
||||||
err = filepath.Walk(buildContext, func(file string, info os.FileInfo, err error) error {
|
err = filepath.Walk(buildContext, func(file string, info os.FileInfo, err error) error {
|
||||||
|
|
||||||
// return on any error
|
// return on any error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -254,7 +251,6 @@ func buildDockerImageContextTar(buildContext string) (string, error) {
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return tmpFile.Name(), nil
|
return tmpFile.Name(), nil
|
||||||
|
|
@ -358,7 +354,6 @@ func deleteDockerRegistryImage(pushOpts internalPushImageOptions, sha256Digest,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error during registry request: %s", err)
|
return fmt.Errorf("Error during registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -376,7 +371,6 @@ func deleteDockerRegistryImage(pushOpts internalPushImageOptions, sha256Digest,
|
||||||
params.Set("service", auth["service"])
|
params.Set("service", auth["service"])
|
||||||
params.Set("scope", auth["scope"])
|
params.Set("scope", auth["scope"])
|
||||||
tokenRequest, err := http.NewRequest("GET", auth["realm"]+"?"+params.Encode(), nil)
|
tokenRequest, err := http.NewRequest("GET", auth["realm"]+"?"+params.Encode(), nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating registry request: %s", err)
|
return fmt.Errorf("Error creating registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -386,7 +380,6 @@ func deleteDockerRegistryImage(pushOpts internalPushImageOptions, sha256Digest,
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenResponse, err := client.Do(tokenRequest)
|
tokenResponse, err := client.Do(tokenRequest)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error during registry request: %s", err)
|
return fmt.Errorf("Error during registry request: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccDockerRegistryImageResource_mapping(t *testing.T) {
|
func TestAccDockerRegistryImageResource_mapping(t *testing.T) {
|
||||||
|
|
||||||
assert := func(condition bool, msg string) {
|
assert := func(condition bool, msg string) {
|
||||||
if !condition {
|
if !condition {
|
||||||
t.Errorf("assertion failed: wrong build parameter %s", msg)
|
t.Errorf("assertion failed: wrong build parameter %s", msg)
|
||||||
|
|
@ -102,7 +101,6 @@ func TestAccDockerRegistryImageResource_mapping(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccDockerRegistryImageResource_build(t *testing.T) {
|
func TestAccDockerRegistryImageResource_build(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
@ -55,8 +54,8 @@ func resourceDockerSecret() *schema.Resource {
|
||||||
|
|
||||||
func resourceDockerSecretV0() *schema.Resource {
|
func resourceDockerSecretV0() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
//This is only used for state migration, so the CRUD
|
// This is only used for state migration, so the CRUD
|
||||||
//callbacks are no longer relevant
|
// callbacks are no longer relevant
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
@ -111,7 +110,6 @@ func resourceDockerSecretCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
func resourceDockerSecretRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceDockerSecretRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*ProviderConfig).DockerClient
|
client := meta.(*ProviderConfig).DockerClient
|
||||||
secret, _, err := client.SecretInspectWithRaw(context.Background(), d.Id())
|
secret, _, err := client.SecretInspectWithRaw(context.Background(), d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARN] Secret (%s) not found, removing from state", d.Id())
|
log.Printf("[WARN] Secret (%s) not found, removing from state", d.Id())
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
@ -128,7 +126,6 @@ func resourceDockerSecretRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
func resourceDockerSecretDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceDockerSecretDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*ProviderConfig).DockerClient
|
client := meta.(*ProviderConfig).DockerClient
|
||||||
err := client.SecretRemove(context.Background(), d.Id())
|
err := client.SecretRemove(context.Background(), d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,7 @@ func resourceDockerService() *schema.Resource {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Description: "Represents represents the FileMode of the file",
|
Description: "Represents represents the FileMode of the file",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: 0444,
|
Default: 0o444,
|
||||||
ValidateFunc: validateIntegerGeqThan(0),
|
ValidateFunc: validateIntegerGeqThan(0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -482,7 +482,7 @@ func resourceDockerService() *schema.Resource {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Description: "Represents represents the FileMode of the file",
|
Description: "Represents represents the FileMode of the file",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: 0444,
|
Default: 0o444,
|
||||||
ValidateFunc: validateIntegerGeqThan(0),
|
ValidateFunc: validateIntegerGeqThan(0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -958,8 +958,8 @@ func resourceDockerService() *schema.Resource {
|
||||||
|
|
||||||
func resourceDockerServiceV0() *schema.Resource {
|
func resourceDockerServiceV0() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
//This is only used for state migration, so the CRUD
|
// This is only used for state migration, so the CRUD
|
||||||
//callbacks are no longer relevant
|
// callbacks are no longer relevant
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"auth": {
|
"auth": {
|
||||||
Type: schema.TypeMap,
|
Type: schema.TypeMap,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
@ -10,8 +11,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"encoding/base64"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
|
@ -252,7 +251,6 @@ func resourceDockerServiceDelete(d *schema.ResourceData, meta interface{}) error
|
||||||
// fetchDockerService fetches a service by its name or id
|
// fetchDockerService fetches a service by its name or id
|
||||||
func fetchDockerService(ID string, name string, client *client.Client) (*swarm.Service, error) {
|
func fetchDockerService(ID string, name string, client *client.Client) (*swarm.Service, error) {
|
||||||
apiServices, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
|
apiServices, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error fetching service information from Docker: %s", err)
|
return nil, fmt.Errorf("Error fetching service information from Docker: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -599,7 +597,6 @@ func terminalState(state swarm.TaskState) bool {
|
||||||
//////// Mappers
|
//////// Mappers
|
||||||
// createServiceSpec creates the service spec: https://docs.docker.com/engine/api/v1.32/#operation/ServiceCreate
|
// createServiceSpec creates the service spec: https://docs.docker.com/engine/api/v1.32/#operation/ServiceCreate
|
||||||
func createServiceSpec(d *schema.ResourceData) (swarm.ServiceSpec, error) {
|
func createServiceSpec(d *schema.ResourceData) (swarm.ServiceSpec, error) {
|
||||||
|
|
||||||
serviceSpec := swarm.ServiceSpec{
|
serviceSpec := swarm.ServiceSpec{
|
||||||
Annotations: swarm.Annotations{
|
Annotations: swarm.Annotations{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -8,8 +9,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ func resourceDockerVolume() *schema.Resource {
|
||||||
|
|
||||||
func resourceDockerVolumeV0() *schema.Resource {
|
func resourceDockerVolumeV0() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
//This is only used for state migration, so the CRUD
|
// This is only used for state migration, so the CRUD
|
||||||
//callbacks are no longer relevant
|
// callbacks are no longer relevant
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ func flattenServiceMode(in swarm.ServiceMode) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenReplicated(in *swarm.ReplicatedService) []interface{} {
|
func flattenReplicated(in *swarm.ReplicatedService) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if in != nil {
|
if in != nil {
|
||||||
if in.Replicas != nil {
|
if in.Replicas != nil {
|
||||||
|
|
@ -69,7 +69,7 @@ func flattenReplicated(in *swarm.ReplicatedService) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceUpdateOrRollbackConfig(in *swarm.UpdateConfig) []interface{} {
|
func flattenServiceUpdateOrRollbackConfig(in *swarm.UpdateConfig) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ func flattenServiceUpdateOrRollbackConfig(in *swarm.UpdateConfig) []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceEndpoint(in swarm.Endpoint) []interface{} {
|
func flattenServiceEndpoint(in swarm.Endpoint) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["mode"] = string(in.Spec.Mode)
|
m["mode"] = string(in.Spec.Mode)
|
||||||
m["ports"] = flattenServicePorts(in.Ports)
|
m["ports"] = flattenServicePorts(in.Ports)
|
||||||
|
|
@ -96,7 +96,7 @@ func flattenServiceEndpoint(in swarm.Endpoint) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceEndpointSpec(in *swarm.EndpointSpec) []interface{} {
|
func flattenServiceEndpointSpec(in *swarm.EndpointSpec) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["mode"] = string(in.Mode)
|
m["mode"] = string(in.Mode)
|
||||||
m["ports"] = flattenServicePorts(in.Ports)
|
m["ports"] = flattenServicePorts(in.Ports)
|
||||||
|
|
@ -107,7 +107,7 @@ func flattenServiceEndpointSpec(in *swarm.EndpointSpec) []interface{} {
|
||||||
|
|
||||||
///// start TaskSpec
|
///// start TaskSpec
|
||||||
func flattenContainerSpec(in *swarm.ContainerSpec) []interface{} {
|
func flattenContainerSpec(in *swarm.ContainerSpec) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if len(in.Image) > 0 {
|
if len(in.Image) > 0 {
|
||||||
m["image"] = in.Image
|
m["image"] = in.Image
|
||||||
|
|
@ -178,7 +178,7 @@ func flattenPrivileges(in *swarm.Privileges) []interface{} {
|
||||||
return make([]interface{}, 0, 0)
|
return make([]interface{}, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = make([]interface{}, 1, 1)
|
out := make([]interface{}, 1, 1)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
|
|
||||||
if in.CredentialSpec != nil {
|
if in.CredentialSpec != nil {
|
||||||
|
|
@ -205,7 +205,7 @@ func flattenPrivileges(in *swarm.Privileges) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceMounts(in []mount.Mount) *schema.Set {
|
func flattenServiceMounts(in []mount.Mount) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["target"] = v.Target
|
m["target"] = v.Target
|
||||||
|
|
@ -266,7 +266,7 @@ func flattenServiceHealthcheck(in *container.HealthConfig) []interface{} {
|
||||||
return make([]interface{}, 0, 0)
|
return make([]interface{}, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = make([]interface{}, 1, 1)
|
out := make([]interface{}, 1, 1)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if len(in.Test) > 0 {
|
if len(in.Test) > 0 {
|
||||||
m["test"] = in.Test
|
m["test"] = in.Test
|
||||||
|
|
@ -280,7 +280,7 @@ func flattenServiceHealthcheck(in *container.HealthConfig) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceHosts(in []string) *schema.Set {
|
func flattenServiceHosts(in []string) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
split := strings.Split(v, ":")
|
split := strings.Split(v, ":")
|
||||||
|
|
@ -300,7 +300,7 @@ func flattenServiceDNSConfig(in *swarm.DNSConfig) []interface{} {
|
||||||
return make([]interface{}, 0, 0)
|
return make([]interface{}, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = make([]interface{}, 1, 1)
|
out := make([]interface{}, 1, 1)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if len(in.Nameservers) > 0 {
|
if len(in.Nameservers) > 0 {
|
||||||
m["nameservers"] = in.Nameservers
|
m["nameservers"] = in.Nameservers
|
||||||
|
|
@ -316,7 +316,7 @@ func flattenServiceDNSConfig(in *swarm.DNSConfig) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceSecrets(in []*swarm.SecretReference) *schema.Set {
|
func flattenServiceSecrets(in []*swarm.SecretReference) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["secret_id"] = v.SecretID
|
m["secret_id"] = v.SecretID
|
||||||
|
|
@ -343,7 +343,7 @@ func flattenServiceSecrets(in []*swarm.SecretReference) *schema.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenServiceConfigs(in []*swarm.ConfigReference) *schema.Set {
|
func flattenServiceConfigs(in []*swarm.ConfigReference) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["config_id"] = v.ConfigID
|
m["config_id"] = v.ConfigID
|
||||||
|
|
@ -370,7 +370,7 @@ func flattenServiceConfigs(in []*swarm.ConfigReference) *schema.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenTaskResources(in *swarm.ResourceRequirements) []interface{} {
|
func flattenTaskResources(in *swarm.ResourceRequirements) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
if in != nil {
|
if in != nil {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["limits"] = flattenResourceLimitsOrReservations(in.Limits)
|
m["limits"] = flattenResourceLimitsOrReservations(in.Limits)
|
||||||
|
|
@ -381,7 +381,7 @@ func flattenTaskResources(in *swarm.ResourceRequirements) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenResourceLimitsOrReservations(in *swarm.Resources) []interface{} {
|
func flattenResourceLimitsOrReservations(in *swarm.Resources) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
if in != nil {
|
if in != nil {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["nano_cpus"] = in.NanoCPUs
|
m["nano_cpus"] = in.NanoCPUs
|
||||||
|
|
@ -393,7 +393,7 @@ func flattenResourceLimitsOrReservations(in *swarm.Resources) []interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenResourceGenericResource(in []swarm.GenericResource) []interface{} {
|
func flattenResourceGenericResource(in []swarm.GenericResource) []interface{} {
|
||||||
var out = make([]interface{}, 0, 0)
|
out := make([]interface{}, 0, 0)
|
||||||
if in != nil && len(in) > 0 {
|
if in != nil && len(in) > 0 {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
named := make([]string, 0)
|
named := make([]string, 0)
|
||||||
|
|
@ -435,7 +435,7 @@ func flattenTaskPlacement(in *swarm.Placement) []interface{} {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return make([]interface{}, 0, 0)
|
return make([]interface{}, 0, 0)
|
||||||
}
|
}
|
||||||
var out = make([]interface{}, 1, 1)
|
out := make([]interface{}, 1, 1)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if len(in.Constraints) > 0 {
|
if len(in.Constraints) > 0 {
|
||||||
m["constraints"] = newStringSet(schema.HashString, in.Constraints)
|
m["constraints"] = newStringSet(schema.HashString, in.Constraints)
|
||||||
|
|
@ -455,7 +455,7 @@ func flattenPlacementPrefs(in []swarm.PlacementPreference) *schema.Set {
|
||||||
return schema.NewSet(schema.HashString, make([]interface{}, 0, 0))
|
return schema.NewSet(schema.HashString, make([]interface{}, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
out[i] = v.Spread.SpreadDescriptor
|
out[i] = v.Spread.SpreadDescriptor
|
||||||
}
|
}
|
||||||
|
|
@ -463,7 +463,7 @@ func flattenPlacementPrefs(in []swarm.PlacementPreference) *schema.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenPlacementPlatforms(in []swarm.Platform) *schema.Set {
|
func flattenPlacementPlatforms(in []swarm.Platform) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["architecture"] = v.Architecture
|
m["architecture"] = v.Architecture
|
||||||
|
|
@ -477,7 +477,7 @@ func flattenPlacementPlatforms(in []swarm.Platform) *schema.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenTaskNetworks(in []swarm.NetworkAttachmentConfig) *schema.Set {
|
func flattenTaskNetworks(in []swarm.NetworkAttachmentConfig) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
out[i] = v.Target
|
out[i] = v.Target
|
||||||
}
|
}
|
||||||
|
|
@ -489,7 +489,7 @@ func flattenTaskLogDriver(in *swarm.Driver) []interface{} {
|
||||||
return make([]interface{}, 0, 0)
|
return make([]interface{}, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = make([]interface{}, 1, 1)
|
out := make([]interface{}, 1, 1)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["name"] = in.Name
|
m["name"] = in.Name
|
||||||
if len(in.Options) > 0 {
|
if len(in.Options) > 0 {
|
||||||
|
|
@ -502,7 +502,7 @@ func flattenTaskLogDriver(in *swarm.Driver) []interface{} {
|
||||||
///// end TaskSpec
|
///// end TaskSpec
|
||||||
///// start EndpointSpec
|
///// start EndpointSpec
|
||||||
func flattenServicePorts(in []swarm.PortConfig) []interface{} {
|
func flattenServicePorts(in []swarm.PortConfig) []interface{} {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["name"] = v.Name
|
m["name"] = v.Name
|
||||||
|
|
@ -530,7 +530,7 @@ func shortDur(d time.Duration) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStringSet(f schema.SchemaSetFunc, in []string) *schema.Set {
|
func newStringSet(f schema.SchemaSetFunc, in []string) *schema.Set {
|
||||||
var out = make([]interface{}, len(in), len(in))
|
out := make([]interface{}, len(in), len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
out[i] = v
|
out[i] = v
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,6 @@ func validateStringIsBase64Encoded() schema.SchemaValidateFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateDockerContainerPath(v interface{}, k string) (ws []string, errors []error) {
|
func validateDockerContainerPath(v interface{}, k string) (ws []string, errors []error) {
|
||||||
|
|
||||||
value := v.(string)
|
value := v.(string)
|
||||||
if !regexp.MustCompile(`^[a-zA-Z]:\\|^/`).MatchString(value) {
|
if !regexp.MustCompile(`^[a-zA-Z]:\\|^/`).MatchString(value) {
|
||||||
errors = append(errors, fmt.Errorf("%q must be an absolute path", k))
|
errors = append(errors, fmt.Errorf("%q must be an absolute path", k))
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ func TestValidateFloatRatio(t *testing.T) {
|
||||||
t.Fatalf("%v should be an invalid float greater than 1.0", v)
|
t.Fatalf("%v should be an invalid float greater than 1.0", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateStringIsFloatRatio(t *testing.T) {
|
func TestValidateStringIsFloatRatio(t *testing.T) {
|
||||||
v := "0.9"
|
v := "0.9"
|
||||||
if _, error := validateStringIsFloatRatio()(v, "name"); error != nil {
|
if _, error := validateStringIsFloatRatio()(v, "name"); error != nil {
|
||||||
|
|
@ -86,6 +87,7 @@ func TestValidateStringIsFloatRatio(t *testing.T) {
|
||||||
t.Fatalf("%v should be an invalid float because it is an int out of range", v)
|
t.Fatalf("%v should be an invalid float because it is an int out of range", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateDurationGeq0(t *testing.T) {
|
func TestValidateDurationGeq0(t *testing.T) {
|
||||||
v := "1ms"
|
v := "1ms"
|
||||||
if _, error := validateDurationGeq0()(v, "name"); error != nil {
|
if _, error := validateDurationGeq0()(v, "name"); error != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue