Skip to content

Add profile data source - #14

Merged
IlyaasK merged 1 commit into
project-data-sourcefrom
profile-data-source
Jul 2, 2026
Merged

Add profile data source#14
IlyaasK merged 1 commit into
project-data-sourcefrom
profile-data-source

Conversation

@IlyaasK

@IlyaasK IlyaasK commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Adds the kernel_profile data source with id or exact name lookup.
  • Uses project-scoped Kernel SDK profile calls through the durable internal/kernelclient wrapper.
  • Shares selector and response-field validation helpers between project/profile data sources.
  • Adds manual list-page support for profile/project exact lookup, including fail-closed pagination diagnostics when X-Has-More is inconsistent with X-Next-Offset.
  • Registers kernel_profile with the provider and adds focused unit tests.

Intentionally unsupported

  • No profile resource or profile mutation support.
  • No browser/session runtime operations.
  • No last_used_at or updated_at in Terraform state because profile runtime load/save paths can change them.
  • No fallback to provider project_id for profile selection; kernel_profile requires explicit id or name.
  • No fuzzy lookup selection; name lookup must resolve to exactly one exact match.

Tests run

  • GOCACHE=/private/tmp/terraform-provider-kernel-go-cache go test ./internal/datasources/... ./internal/kernelclient ./internal/provider
  • GOCACHE=/private/tmp/terraform-provider-kernel-go-cache go test ./...
  • GOCACHE=/private/tmp/terraform-provider-kernel-go-cache go vet ./...
  • git diff --check project-data-source
  • git diff --check project-data-source..HEAD
  • gofmt -l on changed Go files

Review gates

All five review gates passed after accepted fixes were applied and tests were rerun:

  • deslop: all good
  • autoreview: clean, no accepted/actionable findings
  • thermo-nuclear-code-quality-review: all good
  • dave cheney Go architecture review: all good
  • eblog review: all good

Note

Medium Risk
New data source and changed project name-lookup behavior affect how users resolve projects and profiles; pagination and API response validation are security-relevant for correct targeting but are well-tested.

Overview
Adds kernel_profile so Terraform can read durable profile metadata by id or exact name, with optional project_id scoping and only created_at in state (no runtime updated_at / last_used_at).

Introduces shared internal/datasources helpers for id/name selectors and validating API JSON fields; kernel_project now uses them and resolves name lookups with a single GetProject call instead of paginated list scans, with a guard when a configured name collides with another project’s id.

kernelclient gains ListProfilePage and generic pagination that honors X-Has-More over stale X-Next-Offset; ListProjectPage is removed. projectscope.ResolveDataSource errors on unknown project_id during data source reads.

Reviewed by Cursor Bugbot for commit 74bbda8. Bugbot is set up for automated code reviews on this repo. Configure here.

@firetiger-agent

Copy link
Copy Markdown

Created a monitoring plan for this PR.

What this PR does: Adds a kernel_profile data source to the Terraform provider, letting users look up Kernel profile metadata (id, name, created_at) by ID or exact name in infrastructure-as-code. Also refactors shared validation and pagination helpers from the project data source into a reusable package.

Intended effect:

  • CI check runs on this repo: baseline all passing (8+ consecutive successes today, Jun 5); confirmed if HEAD SHA 1b537923 completes conclusion=success
  • Provider data source count: baseline 1 (kernel_project); confirmed if provider_test assertion passes with 2 data sources registered (kernel_project, kernel_profile)
  • Absent runtime fields: baseline no updated_at/last_used_at in project state; confirmed if schema test asserts those attributes are absent from kernel_profile

No production API telemetry applies — this is a Terraform provider change that is dormant until users upgrade their provider version and adopt the new data source.

Risks:

  • Profile API pagination mismatch — if the Kernel /profiles list endpoint returns X-Has-More: true without X-Next-Offset, users see "Kernel profile pagination reported more results without a next offset"; alert if any user reports this error
  • Project data source regressionkernel_project read logic was refactored to shared helpers; alert on any CI failure in the project package or user-reported project plan breakage post-upgrade
  • Provider init panic — second data source registration could surface plugin framework edge cases; alert if any terraform init/plan crash is reported after provider release

Status updates will be posted automatically on this PR as monitoring progresses.

View monitor

@IlyaasK
IlyaasK force-pushed the project-data-source branch from 7f11cd1 to 87e666f Compare June 10, 2026 20:13
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 1b53792 to 3c197fe Compare June 10, 2026 20:13
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 87e666f to 2b6927d Compare June 11, 2026 14:26
@IlyaasK
IlyaasK force-pushed the profile-data-source branch 2 times, most recently from fb46981 to e074c1b Compare June 11, 2026 14:58
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 2b6927d to 999e100 Compare June 12, 2026 14:55
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from e074c1b to 720e1a2 Compare June 12, 2026 14:55
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 999e100 to 026d2cf Compare June 15, 2026 19:22
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 720e1a2 to 7f03669 Compare June 15, 2026 19:22
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 026d2cf to 855072b Compare June 22, 2026 14:16
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 7f03669 to e800b1a Compare June 22, 2026 14:16
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 855072b to 2324adc Compare June 22, 2026 15:03
@IlyaasK
IlyaasK force-pushed the profile-data-source branch 3 times, most recently from e434b60 to a987861 Compare June 26, 2026 14:46
@linear-code

linear-code Bot commented Jun 26, 2026

Copy link
Copy Markdown
KERNEL-1458 Ship v0 Terraform provider for browser pools

tldr

Ship a v0 Kernel Terraform provider for Framer that manages browser pools only. Keep broader durable Kernel resources, including profiles, projects, and API keys, deferred until after the browser-pool MVP is working and reviewed.

Problem

Framer asked for Terraform-managed Kernel infrastructure, and the immediate useful surface is browser pools. The provider should model durable desired state, not runtime browser/session operations. Recent API/SDK contract work has already been done to make this viable.

Customer

Framer.

v0 scope

  • Provider config: api_key, optional base_url, optional project_id.
  • Resource: kernel_browser_pool with create/read/update/delete and import support.
  • Read-only data sources needed for browser-pool references except profiles if they would expand scope beyond the browser-pool MVP.
  • Docs/examples for a Framer-style production pool and project-scoped usage.
  • CI, release checklist, generated Terraform docs, and security checklist for the v0 provider.
  • Keep the provider narrow for v0: no kernel_profile, no kernel_project, no kernel_api_key, and no browser session/acquire/release/runtime resources.

Deferred / follow-up scope

  • Terraform support for Kernel profiles should be added after v0, not in the browser-pool MVP.
  • The existing profile-related provider PR/context can be used later as follow-up planning, but should not gate v0.

Plan and repo

Terraform provider PR context

Merged foundation:

Open v0 stack should stay browser-pool focused:

Potential follow-up data-source work after v0:

API changes made for Terraform/provider correctness

  • kernel/kernel#2386 corrected project-scoping descriptions in the OpenAPI spec.
  • kernel/kernel#2387 made default-project context resolution consistent for Terraform-style explicit project scoping.
  • kernel/kernel#2392 added a typed SDK project_id option mapped to X-Kernel-Project-Id.
  • kernel/kernel#2447 aligned browser-pool timeout/viewport/fill-rate contract with implementation and fixed the update-side save_changes rejection.
  • kernel/kernel#2484 removes save_changes from browser-pool profile params by introducing a pool-specific BrowserPoolProfile schema, so generated SDKs do not expose a field pool create/update reject.

SDK release context

Acceptance criteria

  • kernel_browser_pool CRUD is idempotent and drift-safe.
  • Import sets the canonical browser-pool ID/state correctly.
  • Project scoping is explicit and does not accidentally send a project header for unscoped calls.
  • Sensitive values stay sensitive in Terraform state/logs.
  • Unit tests cover schema/model/helpers and SDK/client wiring.
  • Acceptance tests cover browser-pool create/read/update/delete/import against live Kernel when credentials are present.
  • Docs clearly state that profiles, projects, API keys, and runtime browser/session operations are intentionally unsupported in v0.

Comment thread internal/datasources/profile/datasource.go
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 1732b67 to ef1bca7 Compare June 26, 2026 14:59
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from a987861 to 9d3991d Compare June 26, 2026 14:59
Comment thread internal/datasources/project/datasource.go Outdated
@IlyaasK
IlyaasK force-pushed the project-data-source branch from ef1bca7 to c05ef4a Compare June 26, 2026 17:19
@IlyaasK
IlyaasK force-pushed the profile-data-source branch 2 times, most recently from eed77b3 to f68f78e Compare June 29, 2026 13:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f68f78e. Configure here.

Comment thread internal/kernelclient/client.go
@IlyaasK
IlyaasK force-pushed the project-data-source branch from aa9269d to 6dda104 Compare June 29, 2026 13:49
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from f68f78e to 58ecf85 Compare June 29, 2026 13:49
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 6dda104 to 8e8be50 Compare June 29, 2026 14:03
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 58ecf85 to 26b807a Compare June 29, 2026 14:03
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 8e8be50 to 905f042 Compare June 29, 2026 14:29
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 26b807a to 6a48f02 Compare June 29, 2026 14:29
@IlyaasK
IlyaasK force-pushed the project-data-source branch from 905f042 to f78a750 Compare June 29, 2026 19:14
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 6a48f02 to 80cc052 Compare June 29, 2026 19:14
@IlyaasK
IlyaasK requested review from Sayan- and tnsardesai June 29, 2026 20:54
@IlyaasK
IlyaasK force-pushed the project-data-source branch from f78a750 to b05c00b Compare July 2, 2026 02:34
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 80cc052 to 7bb01f5 Compare July 2, 2026 02:34
@IlyaasK
IlyaasK force-pushed the project-data-source branch from b05c00b to 7c0b29f Compare July 2, 2026 02:48
@IlyaasK
IlyaasK force-pushed the profile-data-source branch 2 times, most recently from 405847e to 9bac0d1 Compare July 2, 2026 19:38
@IlyaasK IlyaasK mentioned this pull request Jul 2, 2026

@tnsardesai tnsardesai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

reviewed — clean PR. generic Page[T], the shared datasources helpers, and the profile/project name-lookup split all read well, and the profile test suite covers the tricky paths (nullable name, id-mismatch guard, ambiguous name). build + tests pass locally.

Nits

  • internal/datasources/helpers.go — the new datasources package has no direct test file (go test reports [no test files]); ResolveIDNameSelector / ValidResponseString / ValidResponseTime are only covered transitively through project/profile. consider a small table test now that they're shared surface area.

@IlyaasK
IlyaasK force-pushed the profile-data-source branch from 9bac0d1 to b97c471 Compare July 2, 2026 19:51
Adds the profile data source plus the shared internal/datasources helpers and
generic Page[T]/lookupNextOffset pagination. Also switches the project data
source name lookup to ProjectService.Get (the API resolves id-or-name,
kernel/kernel#2455) instead of a list-and-scan, and drops the now-unused
ListProjectPage client method + ProjectPage page type. Pagination error-branch
coverage moves to ListProfilePage.
@IlyaasK
IlyaasK force-pushed the profile-data-source branch from b97c471 to 74bbda8 Compare July 2, 2026 20:03
@IlyaasK

IlyaasK commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @tnsardesai — nit addressed, plus the three Bugbot findings on this PR are now resolved (replies on each thread).

Nit — no direct tests for the shared datasources package: added internal/datasources/helpers_test.go with table tests over the shared surface: ResolveIDNameSelector (id/name/neither/conflict/unknown/empty — 8 cases with summary assertions), ValidResponseString and ValidResponseTime (present/absent/null raw, invalid field flag, wrong JSON type, raw-vs-decoded disagreement), and FieldPresent. go test ./internal/datasources/ no longer reports [no test files].

Also folded in on this head: profile scan hardening (filter-first + match-only validation + dedupe-by-id), a name-collision guard on the project Get path, and authoritative X-Has-More: false handling in pagination — details on the Bugbot threads. Head 74bbda8; full internal test suite green on every branch in the stack.

@IlyaasK
IlyaasK merged commit cad56cc into project-data-source Jul 2, 2026
1 check passed
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