Skip to content

feat(provider): implement opt-in Enumerator interface (workflow#536 follow-up)#69

Merged
intel352 merged 2 commits intomainfrom
feat/do-enumerator-impl
May 5, 2026
Merged

feat(provider): implement opt-in Enumerator interface (workflow#536 follow-up)#69
intel352 merged 2 commits intomainfrom
feat/do-enumerator-impl

Conversation

@intel352
Copy link
Copy Markdown
Contributor

@intel352 intel352 commented May 5, 2026

Summary

  • Implements interfaces.Enumerator (opt-in, added in workflow PR #557 / v0.21.2) on DOProvider, enabling wfctl infra cleanup --tag <name> to drive tag-scoped teardown of DO resources.
  • EnumerateByTag(ctx, tag) probes Tags.Get to distinguish unknown-tag (404 → empty slice) from genuine API failure, then queries droplets via native ListByTag, volumes via List + client-side Tags filter, databases via List + client-side Tags filter.
  • Bumps workflow dep to v0.21.2 to pull in the Enumerator interface.
  • Other DO resource types (load balancers, k8s clusters, app platform, etc.) either do not support tags or are deferred; per-provider coverage is documented in workflow/docs/WFCTL.md #### infra cleanup.

This is the follow-up to workflow#557 (design rev3, §PR 6b) per the IaC deferred-cleanup plan. Closes workflow#536 from the DO-plugin side.

Test plan

  • GOWORK=off go test -race -count=1 ./internal/... (all packages pass)
  • go vet ./internal/... clean
  • go build ./... clean
  • New tests:
    • TestDOProvider_ImplementsEnumerator — compile-time interface assertion
    • TestDOProvider_EnumerateByTag_ReturnsTaggedResources — happy path, droplets+volumes+databases, exercises filter
    • TestDOProvider_EnumerateByTag_TagNotFound — 404 → empty result (not an error)
    • TestDOProvider_EnumerateByTag_EmptyTag — early-reject empty tag arg
    • TestDOProvider_EnumerateByTag_NilClient — defensive guard for uninitialised provider

🤖 Generated with Claude Code

Implements interfaces.Enumerator (added in workflow PR #557 / v0.21.2) on
DOProvider, enabling `wfctl infra cleanup --tag <name>` to drive tag-scoped
teardown of DO resources.

EnumerateByTag probes Tags.Get to distinguish unknown-tag (404 → empty
result) from API failure, then queries:
- Droplets via native ListByTag
- Volumes via List + client-side Tags filter (no native tag-filter param)
- Databases via List + client-side Tags filter

Other DO resource types either do not support tags or are deferred; per-
provider coverage is documented in workflow/docs/WFCTL.md.

Tests cover the compile-time interface assertion, the happy path across
all three resource types (with off-tag entries to exercise the filter),
the 404-tag-not-found case, the empty-tag rejection, and the nil-client
defensive guard.

Bumps workflow dep to v0.21.2 to pull in interfaces.Enumerator.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 5, 2026 11:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds opt-in tag enumeration support to the DigitalOcean IaC provider so workflow cleanup can discover tagged resources for teardown, alongside the workflow dependency bump needed for the new interface.

Changes:

  • Adds interfaces.Enumerator implementation on DOProvider with tag probing and resource listing logic.
  • Adds unit tests for direct EnumerateByTag behavior, including happy path and error/edge cases.
  • Updates the workflow dependency to v0.21.2 and refreshes resolved module versions.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
internal/provider.go Adds Enumerator conformance and the new EnumerateByTag implementation for tagged DO resources.
internal/provider_enumerator_test.go Adds direct unit tests for enumeration success, missing-tag, empty-tag, and nil-client cases.
go.mod Bumps github.com/GoCodeAlone/workflow and refreshes selected direct/indirect dependency versions.
go.sum Updates checksums to match the new dependency resolution set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/provider.go
Comment thread internal/provider.go Outdated
Comment thread internal/provider_enumerator_test.go
Addresses three findings from the PR 6b Copilot review:

1. doModuleInstance.InvokeMethod now routes "IaCProvider.EnumerateByTag"
   through to the underlying provider when it implements
   interfaces.Enumerator. Without this case, the host's remoteIaCProvider
   would type-assert ok=false and `wfctl infra cleanup` would silently
   skip every DO provider — even though DOProvider itself implements
   Enumerator. Returns codes.Unimplemented when the provider does NOT
   implement Enumerator so the host can interpret it as the same skip
   semantic the in-process type-assertion would yield.

2. EnumerateByTag now splits the godo.Databases.List response by
   EngineSlug. DO models SQL clusters and managed Redis under the same
   /v2/databases endpoint; the DO plugin's CacheDriver vs DatabaseDriver
   split mirrors that. Emitting every entry as `infra.database` would
   silently misclassify caches and route their Delete to the wrong
   driver in the cleanup dispatcher.

3. New tests: TestDOModuleInstance_InvokeMethod_EnumerateByTag pins the
   dispatch contract end-to-end (stubbed provider implements Enumerator
   → InvokeMethod returns serialized refs); the non-Enumerator case
   pins the codes.Unimplemented branch. The existing happy-path
   provider test now includes a redis-engine cluster and asserts it
   surfaces as infra.cache.

Also tightens droplet ID conversion to strconv.Itoa.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@intel352 intel352 merged commit 5445329 into main May 5, 2026
4 of 5 checks passed
@intel352 intel352 deleted the feat/do-enumerator-impl branch May 5, 2026 12:44
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.

2 participants