feat(provider): implement opt-in Enumerator interface (workflow#536 follow-up)#69
Merged
feat(provider): implement opt-in Enumerator interface (workflow#536 follow-up)#69
Conversation
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>
There was a problem hiding this comment.
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.Enumeratorimplementation onDOProviderwith tag probing and resource listing logic. - Adds unit tests for direct
EnumerateByTagbehavior, including happy path and error/edge cases. - Updates the workflow dependency to
v0.21.2and 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
interfaces.Enumerator(opt-in, added in workflow PR #557 / v0.21.2) onDOProvider, enablingwfctl infra cleanup --tag <name>to drive tag-scoped teardown of DO resources.EnumerateByTag(ctx, tag)probesTags.Getto distinguish unknown-tag (404 → empty slice) from genuine API failure, then queries droplets via nativeListByTag, volumes viaList + client-side Tags filter, databases viaList + client-side Tags filter.Enumeratorinterface.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/...cleango build ./...cleanTestDOProvider_ImplementsEnumerator— compile-time interface assertionTestDOProvider_EnumerateByTag_ReturnsTaggedResources— happy path, droplets+volumes+databases, exercises filterTestDOProvider_EnumerateByTag_TagNotFound— 404 → empty result (not an error)TestDOProvider_EnumerateByTag_EmptyTag— early-reject empty tag argTestDOProvider_EnumerateByTag_NilClient— defensive guard for uninitialised provider🤖 Generated with Claude Code