CLOUDFLAREAPI: Add support for record comments and tags#4025
Conversation
Introducing the following Cloudflare-specific modifiers: - CF_MANAGE_COMMENTS - Domain modifier to opt into comment syncing - CF_MANAGE_TAGS - Domain modifier to opt into tag syncing - CF_COMMENT(comment) - Set a comment on a record (works on all plans) - CF_TAGS(tag1, tag2, ...) - Set tags on a record (requires paid plan) Features: - Comments and tags are read from API and displayed in get-zones output - Validation ensures CF_COMMENT/CF_TAGS require management flags enabled - Tags with reserved 'cf-' prefix are rejected - get-zones --format=js/djs auto-adds management flags when needed - Integration tests for comments (always run) and tags (-cftags flag)
|
@tlimoncelli should tags and CNAME flattening tests have a single gate ( |
Excellent question! Keep them separate, please. Even with a fully paid enterprise account, you can create API keys that are restricted to only support particular features. |
|
OK, ready for review then. I tested it manually quite a bit on a paid zone. I haven't tested comments alone on a free zone, I just realized. I'll do that now. |
| // Helper constants/funcs for the CLOUDFLARE comments testing: | ||
|
|
||
| // A-record with comment | ||
| func CfCommentCreate() *TestCase { |
There was a problem hiding this comment.
Now that CfCommentCreate() and friends are only used once, please inline them. That has the benefit of making the test data more visible.
commands/getZones.go
Outdated
| if comment, ok := rec.Metadata["cloudflare_comment"]; ok && comment != "" { | ||
| hasComments = true | ||
| } | ||
| if tags, ok := rec.Metadata["cloudflare_tags"]; ok && tags != "" { |
There was a problem hiding this comment.
rec.Metadata["cloudflare_tags"] returns "" if there is no "cloudflare_tags" key. It seems like the "ok" checking is overkill.
This would make CF_TAGS("") and not having any tags be equivalent. (which is a good thing. I think?)
- Consolidate CF_COMMENT and CF_TAGS integration tests into single testgroups (no need to clear zone between create/change/remove) - Inline helper functions CfCommentCreate/Change/Remove and CfTagsCreate/Change/Remove since they're only used once - Simplify metadata map lookups by removing unnecessary ok-pattern checks (missing key returns "" which is equivalent to no tags/comments)
There was a problem hiding this comment.
I have reviewed the documentation changes and they look very good and complete. Thank you @allixsenos for the clear improvements and detailed explanation around using comments/tags.
|
I can't wait to use this feature!!! |
Introduced the following Cloudflare-specific modifiers:
Features:
Fixes #1862