Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/fastly: upgrade go-fastly to fix #12910 #13648

Merged
merged 2 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions builtin/providers/fastly/resource_fastly_service_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resourceServiceV1() *schema.Resource {
// creating and activating. It's used internally, but also exported for
// users to see.
"active_version": {
Type: schema.TypeString,
Type: schema.TypeInt,
Computed: true,
},

Expand Down Expand Up @@ -866,14 +866,14 @@ func resourceServiceV1Update(d *schema.ResourceData, meta interface{}) error {
}

if needsChange {
latestVersion := d.Get("active_version").(string)
if latestVersion == "" {
latestVersion := d.Get("active_version").(int)
if latestVersion == 0 {
// If the service was just created, there is an empty Version 1 available
// that is unlocked and can be updated
latestVersion = "1"
latestVersion = 1
} else {
// Clone the latest version, giving us an unlocked version we can modify
log.Printf("[DEBUG] Creating clone of version (%s) for updates", latestVersion)
log.Printf("[DEBUG] Creating clone of version (%d) for updates", latestVersion)
newVersion, err := conn.CloneVersion(&gofastly.CloneVersionInput{
Service: d.Id(),
Version: latestVersion,
Expand Down Expand Up @@ -1684,7 +1684,7 @@ func resourceServiceV1Update(d *schema.ResourceData, meta interface{}) error {
Version: latestVersion,
})
if err != nil {
return fmt.Errorf("[ERR] Error activating version (%s): %s", latestVersion, err)
return fmt.Errorf("[ERR] Error activating version (%d): %s", latestVersion, err)
}

// Only if the version is valid and activated do we set the active_version.
Expand Down Expand Up @@ -1726,7 +1726,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
// If CreateService succeeds, but initial updates to the Service fail, we'll
// have an empty ActiveService version (no version is active, so we can't
// query for information on it)
if s.ActiveVersion.Number != "" {
if s.ActiveVersion.Number != 0 {
settingsOpts := gofastly.GetSettingsInput{
Service: d.Id(),
Version: s.ActiveVersion.Number,
Expand All @@ -1735,7 +1735,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
d.Set("default_host", settings.DefaultHost)
d.Set("default_ttl", settings.DefaultTTL)
} else {
return fmt.Errorf("[ERR] Error looking up Version settings for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Version settings for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

// TODO: update go-fastly to support an ActiveVersion struct, which contains
Expand All @@ -1748,7 +1748,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Domains for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Domains for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

// Refresh Domains
Expand All @@ -1766,7 +1766,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Backends for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Backends for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

bl := flattenBackends(backendList)
Expand All @@ -1783,7 +1783,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Headers for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Headers for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

hl := flattenHeaders(headerList)
Expand All @@ -1800,7 +1800,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Gzips for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Gzips for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

gl := flattenGzips(gzipsList)
Expand All @@ -1817,7 +1817,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Healthcheck for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Healthcheck for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

hcl := flattenHealthchecks(healthcheckList)
Expand All @@ -1834,7 +1834,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up S3 Logging for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up S3 Logging for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

sl := flattenS3s(s3List)
Expand All @@ -1851,7 +1851,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Papertrail for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Papertrail for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

pl := flattenPapertrails(papertrailList)
Expand All @@ -1868,7 +1868,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Sumologic for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Sumologic for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

sul := flattenSumologics(sumologicList)
Expand All @@ -1884,7 +1884,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Response Object for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Response Object for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

rol := flattenResponseObjects(responseObjectList)
Expand All @@ -1901,7 +1901,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Conditions for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Conditions for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

cl := flattenConditions(conditionList)
Expand All @@ -1918,7 +1918,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up Request Settings for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Request Settings for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

rl := flattenRequestSettings(rsList)
Expand All @@ -1934,7 +1934,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
Version: s.ActiveVersion.Number,
})
if err != nil {
return fmt.Errorf("[ERR] Error looking up VCLs for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up VCLs for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

vl := flattenVCLs(vclList)
Expand All @@ -1950,7 +1950,7 @@ func resourceServiceV1Read(d *schema.ResourceData, meta interface{}) error {
Version: s.ActiveVersion.Number,
})
if err != nil {
return fmt.Errorf("[ERR] Error looking up Cache Settings for (%s), version (%s): %s", d.Id(), s.ActiveVersion.Number, err)
return fmt.Errorf("[ERR] Error looking up Cache Settings for (%s), version (%d): %s", d.Id(), s.ActiveVersion.Number, err)
}

csl := flattenCacheSettings(cslList)
Expand Down Expand Up @@ -1981,7 +1981,7 @@ func resourceServiceV1Delete(d *schema.ResourceData, meta interface{}) error {
return err
}

if s.ActiveVersion.Number != "" {
if s.ActiveVersion.Number != 0 {
_, err := conn.DeactivateVersion(&gofastly.DeactivateVersionInput{
Service: d.Id(),
Version: s.ActiveVersion.Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ func TestAccFastlyServiceV1_gzips_basic(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.Gzip{
Version: "1",
Version: 1,
Name: "gzip file types",
Extensions: "js css",
CacheCondition: "testing_condition",
}

log2 := gofastly.Gzip{
Version: "1",
Version: 1,
Name: "gzip extensions",
ContentTypes: "text/css text/html",
}

log3 := gofastly.Gzip{
Version: "1",
Version: 1,
Name: "all",
Extensions: "js html css",
ContentTypes: "text/javascript application/x-javascript application/javascript text/css text/html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestAccFastlyServiceV1_headers_basic(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.Header{
Version: "1",
Version: 1,
Name: "remove x-amz-request-id",
Destination: "http.x-amz-request-id",
Type: "cache",
Expand All @@ -90,7 +90,7 @@ func TestAccFastlyServiceV1_headers_basic(t *testing.T) {
}

log2 := gofastly.Header{
Version: "1",
Version: 1,
Name: "remove s3 server",
Destination: "http.Server",
Type: "cache",
Expand All @@ -100,7 +100,7 @@ func TestAccFastlyServiceV1_headers_basic(t *testing.T) {
}

log3 := gofastly.Header{
Version: "1",
Version: 1,
Name: "DESTROY S3",
Destination: "http.Server",
Type: "cache",
Expand All @@ -109,7 +109,7 @@ func TestAccFastlyServiceV1_headers_basic(t *testing.T) {
}

log4 := gofastly.Header{
Version: "1",
Version: 1,
Name: "Add server name",
Destination: "http.server-name",
Type: "request",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccFastlyServiceV1_healthcheck_basic(t *testing.T) {
domainName := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.HealthCheck{
Version: "1",
Version: 1,
Name: "example-healthcheck1",
Host: "example1.com",
Path: "/test1.txt",
Expand All @@ -32,7 +32,7 @@ func TestAccFastlyServiceV1_healthcheck_basic(t *testing.T) {
}

log2 := gofastly.HealthCheck{
Version: "1",
Version: 1,
Name: "example-healthcheck2",
Host: "example2.com",
Path: "/test2.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccFastlyServiceV1_papertrail_basic(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.Papertrail{
Version: "1",
Version: 1,
Name: "papertrailtesting",
Address: "test1.papertrailapp.com",
Port: uint(3600),
Expand All @@ -26,7 +26,7 @@ func TestAccFastlyServiceV1_papertrail_basic(t *testing.T) {
}

log2 := gofastly.Papertrail{
Version: "1",
Version: 1,
Name: "papertrailtesting2",
Address: "test2.papertrailapp.com",
Port: uint(8080),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccFastlyServiceV1_response_object_basic(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.ResponseObject{
Version: "1",
Version: 1,
Name: "responseObjecttesting",
Status: 200,
Response: "OK",
Expand All @@ -28,7 +28,7 @@ func TestAccFastlyServiceV1_response_object_basic(t *testing.T) {
}

log2 := gofastly.ResponseObject{
Version: "1",
Version: 1,
Name: "responseObjecttesting2",
Status: 404,
Response: "Not Found",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccFastlyServiceV1_s3logging_basic(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.S3{
Version: "1",
Version: 1,
Name: "somebucketlog",
BucketName: "fastlytestlogging",
Domain: "s3-us-west-2.amazonaws.com",
Expand All @@ -33,7 +33,7 @@ func TestAccFastlyServiceV1_s3logging_basic(t *testing.T) {
}

log2 := gofastly.S3{
Version: "1",
Version: 1,
Name: "someotherbucketlog",
BucketName: "fastlytestlogging2",
Domain: "s3-us-west-2.amazonaws.com",
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestAccFastlyServiceV1_s3logging_s3_env(t *testing.T) {
defer resetEnv()

log3 := gofastly.S3{
Version: "1",
Version: 1,
Name: "somebucketlog",
BucketName: "fastlytestlogging",
Domain: "s3-us-west-2.amazonaws.com",
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestAccFastlyServiceV1_s3logging_formatVersion(t *testing.T) {
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

log1 := gofastly.S3{
Version: "1",
Version: 1,
Name: "somebucketlog",
BucketName: "fastlytestlogging",
Domain: "s3-us-west-2.amazonaws.com",
Expand Down
Loading