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 #267

Closed
wants to merge 88 commits into from
Closed

OC Migrate Blocks to using AttributeHandlers #267

wants to merge 88 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 19, 2020

No description provided.

Guy Richardson added 30 commits June 19, 2020 14:46
…d). No Read function for ElasticSearch and FTP to align with master
@ghost ghost added the size/XXL label Jun 19, 2020
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.

LGTM! This is amazing! This pattern will certainly improve maintainability and adding new resources.

The only action items:

  1. Consider making MustProcess method more dynamic by having a more general param than initialVersion bool
  2. Use GetKey pattern ubiquitously in logging endpoints versus the hardcoded string.
  3. Move test fixtures to a test-fixtures sub-directory.
  4. Update test helper for reading test fixtures to include a *testing.T param and call t.Fatal instead of panic.

Comment on lines +46 to +52
func (h *DefaultServiceAttributeHandler) HasChange(d *schema.ResourceData) bool {
return d.HasChange(h.key)
}

func (h *DefaultServiceAttributeHandler) MustProcess(d *schema.ResourceData, initialVersion bool) bool {
return h.HasChange(d)
}
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.

Comments on these two functions would be really appreciated because they are very similar and it might not be clear when to use one or the other.

@@ -230,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.

If this isn't used anymore (I don't think it should be), we can delete it.

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Resolves:
2. Use GetKey pattern ubiquitously in logging endpoints versus the hardcoded string.

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Resolves:
3. Move test fixtures to a test-fixtures sub-directory.

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Resolves:
4. Update test helper for reading test fixtures to include a *testing.T param and call t.Fatal instead of panic.

}

func processGooglePubSub(d *schema.ResourceData, conn *gofastly.Client, latestVersion int) error {
func (h *GooglePubSubServiceAttributeHandler) Process(d *schema.ResourceData, latestVersion int, conn *gofastly.Client) error {
serviceID := d.Id()
oldLogCfg, newLogCfg := d.GetChange("logging_googlepubsub")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
oldLogCfg, newLogCfg := d.GetChange("logging_googlepubsub")
oldLogCfg, newLogCfg := d.GetChange(h.GetKey())

}

func processScalyr(d *schema.ResourceData, conn *gofastly.Client, latestVersion int) error {
func (h *ScalyrServiceAttributeHandler) Process(d *schema.ResourceData, latestVersion int, conn *gofastly.Client) error {
serviceID := d.Id()
oldLogCfg, newLogCfg := d.GetChange("logging_scalyr")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
oldLogCfg, newLogCfg := d.GetChange("logging_scalyr")
oldLogCfg, newLogCfg := d.GetChange(h.GetKey())

@@ -0,0 +1,53 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Copy link
Collaborator

Choose a reason for hiding this comment

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

You may have to update this file once you rebase master.

@mccurdyc
Copy link
Collaborator

mccurdyc commented Jun 23, 2020

  • 1. Consider making MustProcess method more dynamic by having a more general param than initialVersion bool
    • We discussed offline. We will make this change when it is necessary as changing the API should be safe.
  • 2. Use GetKey pattern ubiquitously in logging endpoints versus the hardcoded string.
  • 3. Move test fixtures to a test-fixtures sub-directory.
  • 4. Update test helper for reading test fixtures to include a *testing.T param and call t.Fatal instead of panic.

Everything looks good to me! I saw that googlepubsub and scalyr did still need to be updated in one place to use the GetKey pattern.

@ghost ghost closed this Jun 23, 2020
@ghost ghost deleted the oc/block_handlers branch June 23, 2020 15:13
This pull request was closed.
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.

2 participants