Skip to content

Conversation

@allixsenos
Copy link
Contributor

Introduced 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)

Fixes #1862

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)
@allixsenos
Copy link
Contributor Author

@tlimoncelli should tags and CNAME flattening tests have a single gate (-cfpaid) or be kept separate like this?

@tlimoncelli
Copy link
Collaborator

@tlimoncelli should tags and CNAME flattening tests have a single gate (-cfpaid) or be kept separate like this?

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.

@allixsenos
Copy link
Contributor Author

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.

Comment on lines +1253 to +1269
testgroup("CF_COMMENT create",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), tcEmptyZone(),
),

testgroup("CF_COMMENT change",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), CfCommentChange(),
),

testgroup("CF_COMMENT remove",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), CfCommentRemove(),
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

These can be combined. No need to clear the zone between tests. (for example, testgroup("MX" does it all in one group)

Suggested change
testgroup("CF_COMMENT create",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), tcEmptyZone(),
),
testgroup("CF_COMMENT change",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), CfCommentChange(),
),
testgroup("CF_COMMENT remove",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(), CfCommentRemove(),
),
testgroup("CF_COMMENT create",
only("CLOUDFLAREAPI"),
domainMeta(map[string]string{"cloudflare_manage_comments": "true"}),
CfCommentCreate(),
CfCommentChange(),
CfCommentRemove(),
),

Comment on lines +1273 to +1293
testgroup("CF_TAGS create",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), tcEmptyZone(),
),

testgroup("CF_TAGS change",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), CfTagsChange(),
),

testgroup("CF_TAGS remove",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), CfTagsRemove(),
),

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consolidate these:

Suggested change
testgroup("CF_TAGS create",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), tcEmptyZone(),
),
testgroup("CF_TAGS change",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), CfTagsChange(),
),
testgroup("CF_TAGS remove",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(), CfTagsRemove(),
),
testgroup("CF_TAGS create",
only("CLOUDFLAREAPI"),
alltrue(*enableCFTags),
domainMeta(map[string]string{"cloudflare_manage_tags": "true"}),
CfTagsCreate(),
CfTagsChange(),
CfTagsRemove(),
),

// Helper constants/funcs for the CLOUDFLARE comments testing:

// A-record with comment
func CfCommentCreate() *TestCase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that CfCommentCreate() and friends are only used once, please inline them. That has the benefit of making the test data more visible.

if comment, ok := rec.Metadata["cloudflare_comment"]; ok && comment != "" {
hasComments = true
}
if tags, ok := rec.Metadata["cloudflare_tags"]; ok && tags != "" {
Copy link
Collaborator

@tlimoncelli tlimoncelli Jan 28, 2026

Choose a reason for hiding this comment

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

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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEATURE: Maintain CLOUDFLARE comments and tags via DNSControl

2 participants