This commit is contained in:
Mitchell Hashimoto 2015-02-20 10:22:26 -08:00
parent 4a11b1ce1f
commit 523639b5cd
11 changed files with 34 additions and 46 deletions

View File

@ -1,8 +1,8 @@
package aws
import (
"github.com/mitchellh/goamz/ec2"
"fmt"
"github.com/mitchellh/goamz/ec2"
)
func expandNetworkAclEntries(configured []interface{}, entryType string) ([]ec2.NetworkAclEntry, error) {
@ -11,7 +11,7 @@ func expandNetworkAclEntries(configured []interface{}, entryType string) ([]ec2.
data := eRaw.(map[string]interface{})
protocol := data["protocol"].(string)
_, ok := protocolIntegers()[protocol]
if(!ok){
if !ok {
return nil, fmt.Errorf("Invalid Protocol %s for rule %#v", protocol, data)
}
p := extractProtocolInteger(data["protocol"].(string))
@ -69,7 +69,7 @@ func protocolIntegers() map[string]int {
"udp": 17,
"tcp": 6,
"icmp": 1,
"all": -1,
"all": -1,
}
return protocolIntegers
}

View File

@ -216,4 +216,3 @@ resource "aws_vpc" "bar" {
cidr_block = "10.2.0.0/16"
}
`

View File

@ -297,8 +297,8 @@ func Test_flattenParameters(t *testing.T) {
},
Output: []map[string]interface{}{
map[string]interface{}{
"name": "character_set_client",
"value": "utf8",
"name": "character_set_client",
"value": "utf8",
},
},
},

View File

@ -14,7 +14,6 @@ import (
"golang.org/x/oauth2/jwt"
)
// Config is the configuration structure used to instantiate the Google
// provider.
type Config struct {

View File

@ -10,7 +10,6 @@ import (
// If it is of the form name then look in the configured project and then hosted image projects.
func resolveImage(c *Config, name string) (string, error) {
if strings.HasPrefix(name, "https://www.googleapis.com/compute/v1/") {
return name, nil

View File

@ -32,7 +32,6 @@ func resourceComputeAddress() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
},
}
}

View File

@ -68,12 +68,12 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{
config := meta.(*Config)
frule := &compute.ForwardingRule{
IPAddress: d.Get("ip_address").(string),
IPProtocol: d.Get("ip_protocol").(string),
IPAddress: d.Get("ip_address").(string),
IPProtocol: d.Get("ip_protocol").(string),
Description: d.Get("description").(string),
Name: d.Get("name").(string),
PortRange: d.Get("port_range").(string),
Target: d.Get("target").(string),
Name: d.Get("name").(string),
PortRange: d.Get("port_range").(string),
Target: d.Get("target").(string),
}
log.Printf("[DEBUG] ForwardingRule insert request: %#v", frule)
@ -216,4 +216,3 @@ func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{
d.SetId("")
return nil
}

View File

@ -122,4 +122,3 @@ resource "google_compute_forwarding_rule" "foobar" {
target = "${google_compute_target_pool.foobar-tp.self_link}"
}
`

View File

@ -106,7 +106,7 @@ func resourceComputeInstance() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"nat_ip": &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
Optional: true,
},
@ -248,7 +248,6 @@ func resourceOperationWaitZone(
return nil
}
func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
@ -308,7 +307,6 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
if v, ok := d.GetOk(prefix + ".image"); ok {
imageName := v.(string)
imageUrl, err := resolveImage(config, imageName)
if err != nil {
return fmt.Errorf(
@ -557,7 +555,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
internalIP = iface.NetworkIP
}
}
}
@ -654,7 +651,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
for i := 0; i < networkInterfacesCount; i++ {
prefix := fmt.Sprintf("network_interface.%d", i)
instNetworkInterface := instance.NetworkInterfaces[i]
networkName := d.Get(prefix+".name").(string)
networkName := d.Get(prefix + ".name").(string)
// TODO: This sanity check is broken by #929, disabled for now (by forcing the equality)
networkName = instNetworkInterface.Name
@ -663,7 +660,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Instance networkInterface had unexpected name: %s", instNetworkInterface.Name)
}
if d.HasChange(prefix+".access_config") {
if d.HasChange(prefix + ".access_config") {
// TODO: This code deletes then recreates accessConfigs. This is bad because it may
// leave the machine inaccessible from either ip if the creation part fails (network
@ -672,9 +669,9 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
// necessary, and also add before removing.
// Delete any accessConfig that currently exists in instNetworkInterface
for _, ac := range(instNetworkInterface.AccessConfigs) {
for _, ac := range instNetworkInterface.AccessConfigs {
op, err := config.clientCompute.Instances.DeleteAccessConfig(
config.Project, zone, d.Id(), networkName, ac.Name).Do();
config.Project, zone, d.Id(), networkName, ac.Name).Do()
if err != nil {
return fmt.Errorf("Error deleting old access_config: %s", err)
}
@ -693,7 +690,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
NatIP: d.Get(acPrefix + ".nat_ip").(string),
}
op, err := config.clientCompute.Instances.AddAccessConfig(
config.Project, zone, d.Id(), networkName, ac).Do();
config.Project, zone, d.Id(), networkName, ac).Do()
if err != nil {
return fmt.Errorf("Error adding new access_config: %s", err)
}

View File

@ -72,11 +72,11 @@ func resourceComputeTargetPool() *schema.Resource {
}
func convertStringArr(ifaceArr []interface{}) []string {
arr := make([]string, len(ifaceArr))
for i, v := range ifaceArr {
arr[i] = v.(string)
}
return arr
arr := make([]string, len(ifaceArr))
for i, v := range ifaceArr {
arr[i] = v.(string)
}
return arr
}
func waitOp(config *Config, op *compute.Operation,
@ -151,11 +151,11 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e
// Build the parameter
tpool := &compute.TargetPool{
BackupPool: d.Get("backup_pool").(string),
Description: d.Get("description").(string),
HealthChecks: hchkUrls,
Instances: instanceUrls,
Name: d.Get("name").(string),
BackupPool: d.Get("backup_pool").(string),
Description: d.Get("description").(string),
HealthChecks: hchkUrls,
Instances: instanceUrls,
Name: d.Get("name").(string),
SessionAffinity: d.Get("session_affinity").(string),
}
if d.Get("failover_ratio") != nil {
@ -215,7 +215,6 @@ func calcAddRemove(from []string, to []string) ([]string, []string) {
return add, remove
}
func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

View File

@ -2,9 +2,9 @@ package heroku
import (
"fmt"
"io/ioutil"
"os"
"testing"
"os"
"io/ioutil"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/resource"
@ -13,11 +13,11 @@ import (
func TestAccHerokuCert_Basic(t *testing.T) {
var endpoint heroku.SSLEndpoint
wd, _ := os.Getwd()
certificateChainFile := wd + "/test-fixtures/terraform.cert"
certificateChainBytes, _ := ioutil.ReadFile(certificateChainFile)
certificateChain := string(certificateChainBytes)
testAccCheckHerokuCertConfig_basic := `
wd, _ := os.Getwd()
certificateChainFile := wd + "/test-fixtures/terraform.cert"
certificateChainBytes, _ := ioutil.ReadFile(certificateChainFile)
certificateChain := string(certificateChainBytes)
testAccCheckHerokuCertConfig_basic := `
resource "heroku_app" "foobar" {
name = "terraform-test-cert-app"
region = "eu"
@ -47,7 +47,7 @@ func TestAccHerokuCert_Basic(t *testing.T) {
testAccCheckHerokuCertExists("heroku_cert.ssl_certificate", &endpoint),
testAccCheckHerokuCertificateChain(&endpoint, certificateChain),
resource.TestCheckResourceAttr(
"heroku_cert.ssl_certificate", "cname", "terraform-test-cert-app.herokuapp.com"),
"heroku_cert.ssl_certificate", "cname", "terraform-test-cert-app.herokuapp.com"),
),
},
},
@ -112,5 +112,3 @@ func testAccCheckHerokuCertExists(n string, endpoint *heroku.SSLEndpoint) resour
return nil
}
}