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

View File

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

View File

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

View File

@ -14,7 +14,6 @@ import (
"golang.org/x/oauth2/jwt" "golang.org/x/oauth2/jwt"
) )
// Config is the configuration structure used to instantiate the Google // Config is the configuration structure used to instantiate the Google
// provider. // provider.
type Config struct { 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. // 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) { func resolveImage(c *Config, name string) (string, error) {
if strings.HasPrefix(name, "https://www.googleapis.com/compute/v1/") { if strings.HasPrefix(name, "https://www.googleapis.com/compute/v1/") {
return name, nil return name, nil

View File

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

View File

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

View File

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

View File

@ -106,7 +106,7 @@ func resourceComputeInstance() *schema.Resource {
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"nat_ip": &schema.Schema{ "nat_ip": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Optional: true, Optional: true,
}, },
@ -248,7 +248,6 @@ func resourceOperationWaitZone(
return nil return nil
} }
func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error { func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
@ -308,7 +307,6 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
if v, ok := d.GetOk(prefix + ".image"); ok { if v, ok := d.GetOk(prefix + ".image"); ok {
imageName := v.(string) imageName := v.(string)
imageUrl, err := resolveImage(config, imageName) imageUrl, err := resolveImage(config, imageName)
if err != nil { if err != nil {
return fmt.Errorf( return fmt.Errorf(
@ -557,7 +555,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
internalIP = iface.NetworkIP internalIP = iface.NetworkIP
} }
} }
} }
@ -654,7 +651,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
for i := 0; i < networkInterfacesCount; i++ { for i := 0; i < networkInterfacesCount; i++ {
prefix := fmt.Sprintf("network_interface.%d", i) prefix := fmt.Sprintf("network_interface.%d", i)
instNetworkInterface := instance.NetworkInterfaces[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) // TODO: This sanity check is broken by #929, disabled for now (by forcing the equality)
networkName = instNetworkInterface.Name 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) 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 // 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 // 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. // necessary, and also add before removing.
// Delete any accessConfig that currently exists in instNetworkInterface // Delete any accessConfig that currently exists in instNetworkInterface
for _, ac := range(instNetworkInterface.AccessConfigs) { for _, ac := range instNetworkInterface.AccessConfigs {
op, err := config.clientCompute.Instances.DeleteAccessConfig( 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 { if err != nil {
return fmt.Errorf("Error deleting old access_config: %s", err) 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), NatIP: d.Get(acPrefix + ".nat_ip").(string),
} }
op, err := config.clientCompute.Instances.AddAccessConfig( 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 { if err != nil {
return fmt.Errorf("Error adding new access_config: %s", err) 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 { func convertStringArr(ifaceArr []interface{}) []string {
arr := make([]string, len(ifaceArr)) arr := make([]string, len(ifaceArr))
for i, v := range ifaceArr { for i, v := range ifaceArr {
arr[i] = v.(string) arr[i] = v.(string)
} }
return arr return arr
} }
func waitOp(config *Config, op *compute.Operation, func waitOp(config *Config, op *compute.Operation,
@ -151,11 +151,11 @@ func resourceComputeTargetPoolCreate(d *schema.ResourceData, meta interface{}) e
// Build the parameter // Build the parameter
tpool := &compute.TargetPool{ tpool := &compute.TargetPool{
BackupPool: d.Get("backup_pool").(string), BackupPool: d.Get("backup_pool").(string),
Description: d.Get("description").(string), Description: d.Get("description").(string),
HealthChecks: hchkUrls, HealthChecks: hchkUrls,
Instances: instanceUrls, Instances: instanceUrls,
Name: d.Get("name").(string), Name: d.Get("name").(string),
SessionAffinity: d.Get("session_affinity").(string), SessionAffinity: d.Get("session_affinity").(string),
} }
if d.Get("failover_ratio") != nil { if d.Get("failover_ratio") != nil {
@ -215,7 +215,6 @@ func calcAddRemove(from []string, to []string) ([]string, []string) {
return add, remove return add, remove
} }
func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error { func resourceComputeTargetPoolUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)

View File

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