-
Notifications
You must be signed in to change notification settings - Fork 127
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
v2 #230
v2 #230
Conversation
@phamann as you're aware, the WAF aspect of this PR has been reviewed and approved already, it's the last three commits authored by myself that require a solid review. I appreciate that most of the code is boilerplate in appearance (and will be tedious to sift through) but it's these types of changes that make me especially nervous, so I'm going to be going back over it myself with a fine tooth-comb and would appreciate you do the same if you have capacity. The section I'm most concerned about is the move to pointer values for optional basic types. As an example, there were some situations where a basic type was optional and yet I didn't switch it to be a pointer simply because the basic type was wrapped in a custom type that was defined with constant values (i.e. in theory there should always be a value provided by the user as they would have to assign one of the custom type's constant values to the field). Similarly there were types such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, thank you SO MUCH for taking the time to do this, I know how monotonous it may feel. ❤️
I've taken a scan through the changes and no major issues stood out or typos etc. However, I have are some general observations/questions/discussions to start:
Use of pointers:
I noticed that you've also implemented the pointer pattern on the CreateFooInput
create structs. However, as I understand, they're not needed for resource creation as the underlying omit empty issue only relates to updating fields on existing resources and not creating new ones. Did you do this for consistency or another reason I’m not thinking of? What is your opinion on using them?
ServiceID and ServiceVersion consistency:
I noticed that you've made these consistent on all of the input structs but not on the response models themselves (i.e. Backend
vs CreateBackendInput
). Is there a reason for this? I assume to be consistent with the API schema returned in the JSON responses? However it does raise the question of whether we should be consistent in all structs. Which I'd personally say we should.
Go module v2:
Something we haven't discussed internally yet is how we are going to release this properly as v2 and place nicely with go modules.
Sadly, like most things with Go dependency management, the official recommendation and how other repos approach this are a bit conflicting. Golang recommends creating a v2
folder in the master/main branch and continue the v2 development in there, see: https://blog.golang.org/v2-go-modules and https://github.com/googleapis/gax-go. Mostly, this recommendation is based on keeping the repo working for tools that do not support go modules yet.
Hashicorp has used a different approach with branches. They have a long-lived v2 branch (i.e hcl2
) and the go.mod in that branch has a package called module xxxx/v2 (ie. module github.com/hashicorp/hcl/v2). See https://github.com/hashicorp/hcl/tree/hcl2. We took this approach in the interim for WAF and TF while we were still developing v2. Hence the current dev-v2
branch in this PR. As it allowed us to start consuming it via go modules in TF but not advertise to external users there is an official v2 release yet.
So we have a decision to make:
- Move all of this code to a
v2
directory - Keep a v2 branch as mainline
- Merge this as-is and become v2 in master
Upgrading docs:
Related to the above discussion, once we decide upon how we are going to version and releases as a v2 go module, we need to document how users can upgrade from v1 to v2 and enumerate the main changes to watch out for.
fastly/content.go
Outdated
@@ -26,15 +26,15 @@ type EdgeCheckResponse struct { | |||
|
|||
// EdgeCheckInput is used as input to the EdgeCheck function. | |||
type EdgeCheckInput struct { | |||
URL string `form:"url,omitempty"` | |||
URL *string `form:"url,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a pointer?
Thanks @phamann 1. re: pointers - I'm going to do as you've suggested and only implement the pointer references for input structs that are used for write/update operations. 2. re: response object consistency - good point. I'll make those consistent as well. 3. re: versioning - I'm not a fan of having to deal with two code bases separated by just a folder (makes things confusing when editing files as I could imagine finding myself accidentally updating the wrong file, e.g. a v1 vs v2 file of the same name when fuzzing searching). I'm also not sure what the repercussions are with regards to the simpler v2 suffix on the go.mod namespace? e.g. we rename the module namespace and merge this branch into master. I know that the consumer of Go-Fastly would need to opt in by updating their imports to reference the v2 but then if they decide they're not ready to implement that change, then what happens? e.g. consumers can't continue to import the old go.mod value of So this might suggest that keeping the Alternatively could we do it in reverse? Could we create a |
9f30083
to
b7ba895
Compare
* service waf component new API implemented
* waf version (configuration) API implemented
* WAF active rules implementation
* WAF rules related endpoints implementation
* create empty waf version endpoint implemented
* making WAF enable and disable functions consistent with rest
* Introducing waf version struct method to check for custom emptiness * Using pointers on the WAf version update endpoint
Co-authored-by: Zsolt Balvanyos <[email protected]>
NOTE: this does not include 'create' structs that already had pointer references on them as I'm unaware of the context related to why they are pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem: v1 was lacking critical support for WAF APIs.
Solution: implement missing APIs + fix some minor issues (see notes below) and bump to v2.
Notes: We now...
ServiceID
,ServiceVersion
,DictionaryID
,PoolID
)./stats/field/...
API endpoint (as per Fails to Parse Historic Stats when no Service Provided #214).