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

OC Migrate Blocks to using AttributeHandlers #269

Merged
merged 94 commits into from
Jun 23, 2020
Merged

OC Migrate Blocks to using AttributeHandlers #269

merged 94 commits into from
Jun 23, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jun 23, 2020

This is a large change which refactors how attributes are processed for service resources. The change is motivated primarily to enable composition of different attribute sets for services of type Wasm and VCL; secondarily to tidy up the codebase and refactor large files.

AttributesHandlers provide contributions to the resource schema (Register), resource processing (Process) and resource state refresh (Read). These functions are delegated to AttributeHandlers by a new Base codebase shared between Wasm and VCL service resources.

Guy Richardson added 30 commits June 23, 2020 14:14
…d). No Read function for ElasticSearch and FTP to align with master
@ghost ghost added the size/XXL label Jun 23, 2020
@ghost ghost changed the title Oc/block to handlers OC Migrate Blocks to using AttributeHandlers Jun 23, 2020
Copy link
Member

@phamann phamann left a comment

Choose a reason for hiding this comment

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

This is looking great! Really happy with how it's turned out. My review comments are very minor relating to comment/documentation style. @mccurdyc has picked up most of the code issues so I'll leave those to his review.

  • Very pedantic but is Wasm not WASM. Per: https://webassembly.org/
  • Slightly pedantic, per the golang code review guidelines we prefer comments to be full sentences including ending with a period. I know a lot of this code base doesn't follow this, but I try to pick it up where-ever possible on function comments, inline ones can be left as-is.
  • Some places I've asked for comments to be added to help document the pattern more.
  • Lastly, It would be great if you can add a detailed description to this PR for future maintainers, if they stubble upon the large changeset and want to understand the reasoning why we went with this pattern.

Comment on lines 282 to 286
// New versions are not immediately found in the API, or are not
// immediately mutable, so we need to sleep a few and let Fastly ready
// itself. Typically, 7 seconds is enough
log.Print("[DEBUG] Sleeping 7 seconds to allow Fastly Version to be available")
time.Sleep(7 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

@thommahoney not blocking for this PR, but I'd like to understand why this is the case.

Copy link
Collaborator

@mccurdyc mccurdyc left a comment

Choose a reason for hiding this comment

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

Just those two places identified in #267 that need to use GetKey. Otherwise, LGTM!

Copy link
Collaborator

@mccurdyc mccurdyc left a comment

Choose a reason for hiding this comment

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

Did another pass. LGTM.

@@ -208,3 +94,7 @@ func TestEscapePercentSign(t *testing.T) {
})
}
}

func appendNewLine(s string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not blocking. I think this may be dead now.

// MustProcess returns whether we must process the resource (usually HasChange==true but allowing exceptions).
// For example: at present, the settings attributeHandler (block_fastly_service_v1_settings.go) must process when
// default_ttl==0 and it is the initialVersion - as well as when default_ttl or default_host have changed.
MustProcess(d *schema.ResourceData, initialVersion bool) bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just noting that we talked offline about how it is okay that we just use initialVersion here for now rather than solving the more general use of this method.

@mccurdyc mccurdyc merged commit ae73da7 into fastly:master Jun 23, 2020
@ghost ghost deleted the oc/block_to_handlers branch June 24, 2020 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants