This commit is contained in:
Mitchell Hashimoto 2015-06-23 22:31:24 -07:00
parent 823a9fa878
commit cddd54c3de
13 changed files with 60 additions and 67 deletions

View File

@ -27,9 +27,9 @@ func resourceAwsIAMServerCertificate() *schema.Resource {
}, },
"certificate_chain": &schema.Schema{ "certificate_chain": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
StateFunc: normalizeCert, StateFunc: normalizeCert,
}, },

View File

@ -5,10 +5,10 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/sns" "github.com/aws/aws-sdk-go/service/sns"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/aws/aws-sdk-go/aws/awserr"
) )
func TestAccAWSSNSTopicSubscription_basic(t *testing.T) { func TestAccAWSSNSTopicSubscription_basic(t *testing.T) {
@ -28,7 +28,6 @@ func TestAccAWSSNSTopicSubscription_basic(t *testing.T) {
}) })
} }
func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error { func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).snsconn conn := testAccProvider.Meta().(*AWSClient).snsconn
@ -42,7 +41,6 @@ func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error {
SubscriptionARN: aws.String(rs.Primary.ID), SubscriptionARN: aws.String(rs.Primary.ID),
} }
_, err := conn.GetSubscriptionAttributes(req) _, err := conn.GetSubscriptionAttributes(req)
if err == nil { if err == nil {
@ -59,7 +57,6 @@ func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error {
return nil return nil
} }
func testAccCheckAWSSNSTopicSubscriptionExists(n string) resource.TestCheckFunc { func testAccCheckAWSSNSTopicSubscriptionExists(n string) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n] rs, ok := s.RootModule().Resources[n]

View File

@ -5,10 +5,10 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/sns" "github.com/aws/aws-sdk-go/service/sns"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/aws/aws-sdk-go/aws/awserr"
) )
func TestAccAWSSNSTopic_basic(t *testing.T) { func TestAccAWSSNSTopic_basic(t *testing.T) {
@ -27,7 +27,6 @@ func TestAccAWSSNSTopic_basic(t *testing.T) {
}) })
} }
func testAccCheckAWSSNSTopicDestroy(s *terraform.State) error { func testAccCheckAWSSNSTopicDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).snsconn conn := testAccProvider.Meta().(*AWSClient).snsconn
@ -55,7 +54,6 @@ func testAccCheckAWSSNSTopicDestroy(s *terraform.State) error {
return nil return nil
} }
func testAccCheckAWSSNSTopicExists(n string) resource.TestCheckFunc { func testAccCheckAWSSNSTopicExists(n string) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n] rs, ok := s.RootModule().Resources[n]

View File

@ -85,7 +85,7 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
d.SetId(retContainer.ID) d.SetId(retContainer.ID)
hostConfig := &dc.HostConfig{ hostConfig := &dc.HostConfig{
Privileged: d.Get("privileged").(bool), Privileged: d.Get("privileged").(bool),
PublishAllPorts: d.Get("publish_all_ports").(bool), PublishAllPorts: d.Get("publish_all_ports").(bool),
} }

View File

@ -13,8 +13,8 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
"golang.org/x/oauth2/jwt" "golang.org/x/oauth2/jwt"
"google.golang.org/api/compute/v1"
computeBeta "google.golang.org/api/compute/v0.beta" computeBeta "google.golang.org/api/compute/v0.beta"
"google.golang.org/api/compute/v1"
"google.golang.org/api/dns/v1" "google.golang.org/api/dns/v1"
"google.golang.org/api/storage/v1" "google.golang.org/api/storage/v1"
) )
@ -26,10 +26,10 @@ type Config struct {
Project string Project string
Region string Region string
clientCompute *compute.Service clientCompute *compute.Service
clientComputeBeta *computeBeta.Service clientComputeBeta *computeBeta.Service
clientDns *dns.Service clientDns *dns.Service
clientStorage *storage.Service clientStorage *storage.Service
} }
func (c *Config) loadAndValidate() error { func (c *Config) loadAndValidate() error {

View File

@ -7,9 +7,9 @@ import (
) )
type DnsChangeWaiter struct { type DnsChangeWaiter struct {
Service *dns.Service Service *dns.Service
Change *dns.Change Change *dns.Change
Project string Project string
ManagedZone string ManagedZone string
} }

View File

@ -101,7 +101,7 @@ func resourceComputeInstance() *schema.Resource {
}, },
"device_name": &schema.Schema{ "device_name": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
}, },
@ -148,9 +148,9 @@ func resourceComputeInstance() *schema.Resource {
}, },
"network": &schema.Schema{ "network": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Deprecated: "Please use network_interface", Deprecated: "Please use network_interface",
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -229,7 +229,7 @@ func resourceComputeInstance() *schema.Resource {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Set: stringHashcode, Set: stringHashcode,
}, },
"metadata_fingerprint": &schema.Schema{ "metadata_fingerprint": &schema.Schema{
@ -327,7 +327,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
disk.Source = diskData.SelfLink disk.Source = diskData.SelfLink
} else { } else {
// Create a new disk // Create a new disk
disk.InitializeParams = &compute.AttachedDiskInitializeParams{ } disk.InitializeParams = &compute.AttachedDiskInitializeParams{}
} }
if v, ok := d.GetOk(prefix + ".scratch"); ok { if v, ok := d.GetOk(prefix + ".scratch"); ok {
@ -367,7 +367,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
disk.InitializeParams.DiskSizeGb = int64(diskSizeGb) disk.InitializeParams.DiskSizeGb = int64(diskSizeGb)
} }
if v, ok := d.GetOk(prefix + ".device_name"); ok { if v, ok := d.GetOk(prefix + ".device_name"); ok {
disk.DeviceName = v.(string) disk.DeviceName = v.(string)
} }

View File

@ -6,7 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -127,7 +127,6 @@ func migrateStateV1toV2(is *terraform.InstanceState) (*terraform.InstanceState,
delete(is.Attributes, k) delete(is.Attributes, k)
} }
for service_acct_index, newScopes := range newScopesMap { for service_acct_index, newScopes := range newScopesMap {
for _, newScope := range newScopes { for _, newScope := range newScopes {
hash := hashcode.String(canonicalizeServiceScope(newScope)) hash := hashcode.String(canonicalizeServiceScope(newScope))

View File

@ -30,8 +30,8 @@ func TestComputeInstanceMigrateState(t *testing.T) {
"change scope from list to set": { "change scope from list to set": {
StateVersion: 1, StateVersion: 1,
Attributes: map[string]string{ Attributes: map[string]string{
"service_account.#": "1", "service_account.#": "1",
"service_account.0.email": "xxxxxx-compute@developer.gserviceaccount.com", "service_account.0.email": "xxxxxx-compute@developer.gserviceaccount.com",
"service_account.0.scopes.#": "4", "service_account.0.scopes.#": "4",
"service_account.0.scopes.0": "https://www.googleapis.com/auth/compute", "service_account.0.scopes.0": "https://www.googleapis.com/auth/compute",
"service_account.0.scopes.1": "https://www.googleapis.com/auth/datastore", "service_account.0.scopes.1": "https://www.googleapis.com/auth/datastore",
@ -39,12 +39,12 @@ func TestComputeInstanceMigrateState(t *testing.T) {
"service_account.0.scopes.3": "https://www.googleapis.com/auth/logging.write", "service_account.0.scopes.3": "https://www.googleapis.com/auth/logging.write",
}, },
Expected: map[string]string{ Expected: map[string]string{
"service_account.#": "1", "service_account.#": "1",
"service_account.0.email": "xxxxxx-compute@developer.gserviceaccount.com", "service_account.0.email": "xxxxxx-compute@developer.gserviceaccount.com",
"service_account.0.scopes.#": "4", "service_account.0.scopes.#": "4",
"service_account.0.scopes.1693978638": "https://www.googleapis.com/auth/devstorage.full_control", "service_account.0.scopes.1693978638": "https://www.googleapis.com/auth/devstorage.full_control",
"service_account.0.scopes.172152165": "https://www.googleapis.com/auth/logging.write", "service_account.0.scopes.172152165": "https://www.googleapis.com/auth/logging.write",
"service_account.0.scopes.299962681": "https://www.googleapis.com/auth/compute", "service_account.0.scopes.299962681": "https://www.googleapis.com/auth/compute",
"service_account.0.scopes.3435931483": "https://www.googleapis.com/auth/datastore", "service_account.0.scopes.3435931483": "https://www.googleapis.com/auth/datastore",
}, },
}, },

View File

@ -50,18 +50,18 @@ func resourceDnsManagedZone() *schema.Resource {
func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) error { func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
// Build the parameter // Build the parameter
zone := &dns.ManagedZone{ zone := &dns.ManagedZone{
Name: d.Get("name").(string), Name: d.Get("name").(string),
DnsName: d.Get("dns_name").(string), DnsName: d.Get("dns_name").(string),
} }
// Optional things // Optional things
if v, ok := d.GetOk("description"); ok { if v, ok := d.GetOk("description"); ok {
zone.Description = v.(string) zone.Description = v.(string)
} }
if v, ok := d.GetOk("dns_name"); ok { if v, ok := d.GetOk("dns_name"); ok {
zone.DnsName = v.(string) zone.DnsName = v.(string)
} }
log.Printf("[DEBUG] DNS ManagedZone create request: %#v", zone) log.Printf("[DEBUG] DNS ManagedZone create request: %#v", zone)
zone, err := config.clientDns.ManagedZones.Create(config.Project, zone).Do() zone, err := config.clientDns.ManagedZones.Create(config.Project, zone).Do()
@ -90,7 +90,7 @@ func resourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error reading DNS ManagedZone: %#v", err) return fmt.Errorf("Error reading DNS ManagedZone: %#v", err)
} }
d.Set("name_servers", zone.NameServers) d.Set("name_servers", zone.NameServers)
return nil return nil
} }

View File

@ -61,17 +61,17 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
// Build the change // Build the change
chg := &dns.Change{ chg := &dns.Change{
Additions: []*dns.ResourceRecordSet { Additions: []*dns.ResourceRecordSet{
&dns.ResourceRecordSet { &dns.ResourceRecordSet{
Name: d.Get("name").(string), Name: d.Get("name").(string),
Type: d.Get("type").(string), Type: d.Get("type").(string),
Ttl: int64(d.Get("ttl").(int)), Ttl: int64(d.Get("ttl").(int)),
Rrdatas: make([]string, rrdatasCount), Rrdatas: make([]string, rrdatasCount),
}, },
}, },
} }
for i := 0; i < rrdatasCount ; i++ { for i := 0; i < rrdatasCount; i++ {
rrdata := fmt.Sprintf("rrdatas.%d", i) rrdata := fmt.Sprintf("rrdatas.%d", i)
chg.Additions[0].Rrdatas[i] = d.Get(rrdata).(string) chg.Additions[0].Rrdatas[i] = d.Get(rrdata).(string)
} }
@ -85,9 +85,9 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
d.SetId(chg.Id) d.SetId(chg.Id)
w := &DnsChangeWaiter{ w := &DnsChangeWaiter{
Service: config.clientDns, Service: config.clientDns,
Change: chg, Change: chg,
Project: config.Project, Project: config.Project,
ManagedZone: zone, ManagedZone: zone,
} }
state := w.Conf() state := w.Conf()
@ -126,7 +126,6 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Only expected 1 record set, got %d", len(resp.Rrsets)) return fmt.Errorf("Only expected 1 record set, got %d", len(resp.Rrsets))
} }
d.Set("ttl", resp.Rrsets[0].Ttl) d.Set("ttl", resp.Rrsets[0].Ttl)
d.Set("rrdatas", resp.Rrsets[0].Rrdatas) d.Set("rrdatas", resp.Rrsets[0].Rrdatas)
@ -142,17 +141,17 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error
// Build the change // Build the change
chg := &dns.Change{ chg := &dns.Change{
Deletions: []*dns.ResourceRecordSet { Deletions: []*dns.ResourceRecordSet{
&dns.ResourceRecordSet { &dns.ResourceRecordSet{
Name: d.Get("name").(string), Name: d.Get("name").(string),
Type: d.Get("type").(string), Type: d.Get("type").(string),
Ttl: int64(d.Get("ttl").(int)), Ttl: int64(d.Get("ttl").(int)),
Rrdatas: make([]string, rrdatasCount), Rrdatas: make([]string, rrdatasCount),
}, },
}, },
} }
for i := 0; i < rrdatasCount ; i++ { for i := 0; i < rrdatasCount; i++ {
rrdata := fmt.Sprintf("rrdatas.%d", i) rrdata := fmt.Sprintf("rrdatas.%d", i)
chg.Deletions[0].Rrdatas[i] = d.Get(rrdata).(string) chg.Deletions[0].Rrdatas[i] = d.Get(rrdata).(string)
} }
@ -163,9 +162,9 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error
} }
w := &DnsChangeWaiter{ w := &DnsChangeWaiter{
Service: config.clientDns, Service: config.clientDns,
Change: chg, Change: chg,
Project: config.Project, Project: config.Project,
ManagedZone: zone, ManagedZone: zone,
} }
state := w.Conf() state := w.Conf()

View File

@ -82,7 +82,7 @@ func (c *SwiftClient) Get() (*Payload, error) {
hash := md5.Sum(bytes) hash := md5.Sum(bytes)
payload := &Payload{ payload := &Payload{
Data: bytes, Data: bytes,
MD5: hash[:md5.Size], MD5: hash[:md5.Size],
} }
return payload, nil return payload, nil

View File

@ -2,8 +2,8 @@ package remote
import ( import (
"net/http" "net/http"
"testing"
"os" "os"
"testing"
) )
func TestSwiftClient_impl(t *testing.T) { func TestSwiftClient_impl(t *testing.T) {