This commit is contained in:
Matti Savolainen 2015-07-06 10:45:17 +03:00
commit 41a16b5719
7 changed files with 227 additions and 9 deletions

View File

@ -6,6 +6,7 @@ BUG FIXES:
preventing `key_file` from being read without explicitly
setting `agent = false` [GH-2615]
* core: don't prompt for variables with defaults [GH-2613]
* core: Return correct number of planned updates [GH-2620]
* providers/aws: Allow uppercase characters in `aws_elb.name` [GH-2580]
* providers/aws: Allow underscores in `aws_db_subnet_group.name` (undocumented by AWS) [GH-2604]

View File

@ -20,7 +20,10 @@ func (p *Provisioner) linuxInstallChefClient(
// Build up the command prefix
prefix := ""
if p.HTTPProxy != "" {
prefix += fmt.Sprintf("proxy_http='%s' ", p.HTTPProxy)
prefix += fmt.Sprintf("http_proxy='%s' ", p.HTTPProxy)
}
if p.HTTPSProxy != "" {
prefix += fmt.Sprintf("https_proxy='%s' ", p.HTTPSProxy)
}
if p.NOProxy != nil {
prefix += fmt.Sprintf("no_proxy='%s' ", strings.Join(p.NOProxy, ","))

View File

@ -58,9 +58,27 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) {
}),
Commands: map[string]bool{
"proxy_http='http://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true,
"proxy_http='http://proxy.local' bash ./install.sh -v \"\"": true,
"proxy_http='http://proxy.local' rm -f install.sh": true,
"http_proxy='http://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true,
"http_proxy='http://proxy.local' bash ./install.sh -v \"\"": true,
"http_proxy='http://proxy.local' rm -f install.sh": true,
},
},
"HTTPSProxy": {
Config: testConfig(t, map[string]interface{}{
"https_proxy": "https://proxy.local",
"node_name": "nodename1",
"prevent_sudo": true,
"run_list": []interface{}{"cookbook::recipe"},
"server_url": "https://chef.local",
"validation_client_name": "validator",
"validation_key_path": "validator.pem",
}),
Commands: map[string]bool{
"https_proxy='https://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true,
"https_proxy='https://proxy.local' bash ./install.sh -v \"\"": true,
"https_proxy='https://proxy.local' rm -f install.sh": true,
},
},
@ -77,11 +95,11 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) {
}),
Commands: map[string]bool{
"proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"curl -LO https://www.chef.io/chef/install.sh": true,
"proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"bash ./install.sh -v \"\"": true,
"proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " +
"rm -f install.sh": true,
},
},

View File

@ -97,7 +97,7 @@ func (h *CountHook) PostDiff(
h.ToAdd += 1
case terraform.DiffDestroy:
h.ToRemove += 1
default:
case terraform.DiffUpdate:
h.ToChange += 1
}

View File

@ -1,6 +1,7 @@
package command
import (
"reflect"
"testing"
"github.com/hashicorp/terraform/terraform"
@ -9,3 +10,175 @@ import (
func TestCountHook_impl(t *testing.T) {
var _ terraform.Hook = new(CountHook)
}
func TestCountHookPostDiff_DestroyOnly(t *testing.T) {
h := new(CountHook)
resources := map[string]*terraform.InstanceDiff{
"foo": &terraform.InstanceDiff{Destroy: true},
"bar": &terraform.InstanceDiff{Destroy: true},
"lorem": &terraform.InstanceDiff{Destroy: true},
"ipsum": &terraform.InstanceDiff{Destroy: true},
}
n := &terraform.InstanceInfo{} // TODO
for _, d := range resources {
h.PostDiff(n, d)
}
expected := new(CountHook)
expected.ToAdd = 0
expected.ToChange = 0
expected.ToRemoveAndAdd = 0
expected.ToRemove = 4
if !reflect.DeepEqual(expected, h) {
t.Fatalf("Expected %#v, got %#v instead.",
expected, h)
}
}
func TestCountHookPostDiff_AddOnly(t *testing.T) {
h := new(CountHook)
resources := map[string]*terraform.InstanceDiff{
"foo": &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{RequiresNew: true},
},
},
"bar": &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{RequiresNew: true},
},
},
"lorem": &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{RequiresNew: true},
},
},
}
n := &terraform.InstanceInfo{}
for _, d := range resources {
h.PostDiff(n, d)
}
expected := new(CountHook)
expected.ToAdd = 3
expected.ToChange = 0
expected.ToRemoveAndAdd = 0
expected.ToRemove = 0
if !reflect.DeepEqual(expected, h) {
t.Fatalf("Expected %#v, got %#v instead.",
expected, h)
}
}
func TestCountHookPostDiff_ChangeOnly(t *testing.T) {
h := new(CountHook)
resources := map[string]*terraform.InstanceDiff{
"foo": &terraform.InstanceDiff{
Destroy: false,
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{},
},
},
"bar": &terraform.InstanceDiff{
Destroy: false,
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{},
},
},
"lorem": &terraform.InstanceDiff{
Destroy: false,
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{},
},
},
}
n := &terraform.InstanceInfo{}
for _, d := range resources {
h.PostDiff(n, d)
}
expected := new(CountHook)
expected.ToAdd = 0
expected.ToChange = 3
expected.ToRemoveAndAdd = 0
expected.ToRemove = 0
if !reflect.DeepEqual(expected, h) {
t.Fatalf("Expected %#v, got %#v instead.",
expected, h)
}
}
func TestCountHookPostDiff_Mixed(t *testing.T) {
h := new(CountHook)
resources := map[string]*terraform.InstanceDiff{
"foo": &terraform.InstanceDiff{
Destroy: true,
},
"bar": &terraform.InstanceDiff{},
"lorem": &terraform.InstanceDiff{
Destroy: false,
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{},
},
},
"ipsum": &terraform.InstanceDiff{Destroy: true},
}
n := &terraform.InstanceInfo{}
for _, d := range resources {
h.PostDiff(n, d)
}
expected := new(CountHook)
expected.ToAdd = 0
expected.ToChange = 1
expected.ToRemoveAndAdd = 0
expected.ToRemove = 2
if !reflect.DeepEqual(expected, h) {
t.Fatalf("Expected %#v, got %#v instead.",
expected, h)
}
}
func TestCountHookPostDiff_NoChange(t *testing.T) {
h := new(CountHook)
resources := map[string]*terraform.InstanceDiff{
"foo": &terraform.InstanceDiff{},
"bar": &terraform.InstanceDiff{},
"lorem": &terraform.InstanceDiff{},
"ipsum": &terraform.InstanceDiff{},
}
n := &terraform.InstanceInfo{}
for _, d := range resources {
h.PostDiff(n, d)
}
expected := new(CountHook)
expected.ToAdd = 0
expected.ToChange = 0
expected.ToRemoveAndAdd = 0
expected.ToRemove = 0
if !reflect.DeepEqual(expected, h) {
t.Fatalf("Expected %#v, got %#v instead.",
expected, h)
}
}

View File

@ -24,12 +24,34 @@ resource "aws_ecs_task_definition" "jenkins" {
}
```
### task-definitions/jenkins.json
The below would be passed into the `container_definitions` attribute. This is a small subset of the available parameters, see the [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) for a full list.
```
[
{
"name": "jenkins",
"image": "jenkins",
"cpu": 10,
"memory": 500,
"essential": true,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
]
}
]
```
## Argument Reference
The following arguments are supported:
* `family` - (Required) The family, unique name for your task definition.
* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html) for syntax.
* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html) for syntax. Note, you only need the containerDefinitions array, not the parent hash including the family and volumes keys.
* `volume` - (Optional) A volume block. Volumes documented below.
Volumes support the following:

View File

@ -35,6 +35,7 @@ The following arguments are supported:
* `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC.
* `user_data` - (Optional) The user data to provide when launching the instance.
* `enable_monitoring` - (Optional) Enables/disables detailed monitoring. This is enabled by default.
* `ebs_optimized` - (Optional) If true, the launched EC2 instance will be EBS-optimized.
* `block_device_mapping` - (Optional) A list of block devices to add. Their keys are documented below.
<a id="block-devices"></a>