Skip to content

refactor(provider): extract shared helpers for Configure, 404, and ru…#13

Merged
combor merged 1 commit intomainfrom
claude/optimize-code-performance-QIa2D
Apr 17, 2026
Merged

refactor(provider): extract shared helpers for Configure, 404, and ru…#13
combor merged 1 commit intomainfrom
claude/optimize-code-performance-QIa2D

Conversation

@combor
Copy link
Copy Markdown
Owner

@combor combor commented Apr 17, 2026

…nner status

The internal/provider package was built resource-by-resource, which left ~100 lines of copied boilerplate across 12 files: the Configure client assertion, the errors.As(err, &apiErr) && StatusCode == 404 check, inline runner-status types.Object construction, and manual RunnerManagerID null checks. Each copy had to be kept in sync by hand.

Extract four tiny helpers in helpers.go and replace all call sites:

  • clientFromProviderData: one helper serves both resource and datasource Configure (both expose ProviderData and Diagnostics).
  • isAPINotFound: replaces 13 repeated 404 checks.
  • runnerStatusObjectValue + shared runnerStatusAttrTypes: replaces 3 copies of the same four-field status ObjectValue construction.
  • Reuse existing stringValueOrNull for three RunnerManagerID sites.

Also tighten stringListValue to use ListValueMust with []attr.Value, skipping the reflection pass ListValueFrom performs over the typed slice (and dropping a bogus context.Background()).

No behaviour changes, no schema changes. Existing tests pass unchanged.

…nner status

The internal/provider package was built resource-by-resource, which left
~100 lines of copied boilerplate across 12 files: the Configure client
assertion, the `errors.As(err, &apiErr) && StatusCode == 404` check, inline
runner-status types.Object construction, and manual RunnerManagerID null
checks. Each copy had to be kept in sync by hand.

Extract four tiny helpers in helpers.go and replace all call sites:
- clientFromProviderData: one helper serves both resource and datasource
  Configure (both expose ProviderData and Diagnostics).
- isAPINotFound: replaces 13 repeated 404 checks.
- runnerStatusObjectValue + shared runnerStatusAttrTypes: replaces 3 copies
  of the same four-field status ObjectValue construction.
- Reuse existing stringValueOrNull for three RunnerManagerID sites.

Also tighten stringListValue to use ListValueMust with []attr.Value,
skipping the reflection pass ListValueFrom performs over the typed slice
(and dropping a bogus context.Background()).

No behaviour changes, no schema changes. Existing tests pass unchanged.
@combor combor merged commit 5ee45aa into main Apr 17, 2026
13 checks passed
@combor combor deleted the claude/optimize-code-performance-QIa2D branch April 17, 2026 10:12
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