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

Bump go-fastly to new v7 major release #614

Merged
merged 14 commits into from
Nov 16, 2022
Merged

Conversation

Integralist
Copy link
Collaborator

@Integralist Integralist commented Nov 14, 2022

This is technically a breaking-change PR because we remove a long deprecated attribute. Also, the underlying go-fastly changes are so substantial that it's probably worth moving to a new major version.

@Integralist Integralist added enhancement New feature or request dependencies labels Nov 14, 2022
@Integralist Integralist force-pushed the integralist/go-fastly-bump branch from 6bf8514 to eba7530 Compare November 14, 2022 16:48
Copy link
Collaborator Author

@Integralist Integralist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTES for reviewer...

github.com/google/go-cmp v0.5.9
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I had to bump this dependency to fix a failing test caused by a bug in the Terraform SDK.

"ip": currentACLEntry.IP,
"negated": currentACLEntry.Negated,
"comment": currentACLEntry.Comment,
var result []map[string]any
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I made a bunch of consistency changes to variable naming.

Default: 0,
Type: schema.TypeInt,
Optional: true,
// NOTE: The default represents an unset value
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ The changes in go-fastly cause complications for the Terraform provider.

go-fastly v7+ now expects a pointer, but the Terraform provider originally set a 'default' value of zero for the gzip_level attribute (which is a valid API value). This meant the default value would be wrapped in a pointer and consequently was always sent to the API, but this caused the API to error as some combinations of attributes are considered conflicting.

For example, configuring compression_codec + gzip_level is an invalid API request and was being triggered by our test suite which explicitly defined compression_codec in Terraform configuration while gzip_level was now being added to the API request because of the default value.

We weren't able to determine if the user actually configured gzip_level in their Terraform configuration because zero might well be a value they would set (as it's a valid value for that attribute). This meant we needed to set a default value (i.e. -1) that we could use to determine if the user had set the attribute in their Terraform configuration (see the updated 'flatten' function).

Additionally, some fields shouldn't have an empty string passed as it would cause the Fastly API to return an error. Because of go-fastly's new behaviour it now will not 'omitempty' empty strings due to the pointer field type.

@@ -37,6 +37,12 @@ func (h *DynamicSnippetServiceAttributeHandler) GetSchema() *schema.Schema {
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"content": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ We never actually defined an attribute for a user to create/update VCL content for a dynamic snippet.

@@ -152,18 +152,11 @@ func (h *BackendServiceAttributeHandler) GetSchema() *schema.Schema {
Description: "Client key attached to origin. Used when connecting to the backend",
Sensitive: true,
},
"ssl_hostname": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been deprecated in go-fastly for nearly two years and was removed in v7, which means by removing this attribute here we'll need to cut a new major Terraform release.

@Integralist Integralist requested a review from shawnps November 14, 2022 17:37
@Integralist
Copy link
Collaborator Author

NOTE: I've run the full integration test suite and it's passing.

@Integralist Integralist merged commit 53403fc into main Nov 16, 2022
@Integralist Integralist deleted the integralist/go-fastly-bump branch November 16, 2022 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants