Skip to content

refactor: merge cluster service arrays into record#33

Draft
matejvasek wants to merge 1 commit into
functions-dev:masterfrom
matejvasek:cleanup-cluster-svc
Draft

refactor: merge cluster service arrays into record#33
matejvasek wants to merge 1 commit into
functions-dev:masterfrom
matejvasek:cleanup-cluster-svc

Conversation

@matejvasek

Copy link
Copy Markdown
Collaborator

Summary

  • Change useClusterService return type from { knativeServices[], deployments[] } to { functions: Record<string, ClusterFunctionInfo> } with pre-correlated ksvc/deployment pairs
  • Move revision-based correlation logic (latestReadyRevisionName matching) from FunctionsListPage into the hook
  • Rename misleading deployment field to knativeService on FunctionTableItem (the field held a Knative Service, not a Deployment)
  • Fix FunctionTable.test.tsx fixture to use an actual Knative Service object instead of a Deployment
  • Add 4 new hook tests: error propagation, co-presence pairing, ksvc without deployment, revision-based matching

Test plan

  • yarn lint passes (0 errors, 0 warnings)
  • yarn test passes (14 suites, 129 tests)
  • Manual: verify delete button on function list still launches undeploy modal for the Knative Service

🤖 Generated with Claude Code

useClusterService returned Knative Services and Deployments as
separate arrays. Consumers had to manually correlate them by
revision label, and a naming bug stored the ksvc in a field
called "deployment".

The hook now returns a Record<string, ClusterFunctionInfo> with
pre-correlated pairs. The revision-matching logic moves into the
hook, simplifying every consumer to a single record lookup.
Renamed the misleading field to "knativeService" on
FunctionTableItem and fixed the test fixture to use an actual
Knative Service object.

Co-Authored-By: Claude <noreply@anthropic.com>
@matejvasek matejvasek marked this pull request as draft June 8, 2026 20:47
@matejvasek matejvasek changed the title refactor: merge cluster service arrays into record% refactor: merge cluster service arrays into record Jun 8, 2026
@matejvasek matejvasek requested a review from Copilot June 8, 2026 23:50

Copilot AI 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.

Pull request overview

This PR refactors cluster resource consumption by changing useClusterService to return a correlated record of Knative Service + Deployment info per function name, moving revision-based matching logic out of FunctionsListPage into the hook, and updating consumers/tests accordingly.

Changes:

  • Refactor useClusterService to return functions: Record<string, ClusterFunctionInfo> with ksvc/deployment correlation by latestReadyRevisionName (fallback to function label).
  • Simplify FunctionsListPage to use the correlated record, and rename FunctionTableItem.deploymentknativeService (since it actually held a Knative Service).
  • Update/expand tests to match the new API and to cover correlation/error scenarios.

Reviewed changes

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

Show a summary per file
File Description
src/pages/function-list/FunctionsListPage.tsx Switches list enrichment from ad-hoc array matching to record lookup and renames stored Knative resource field.
src/pages/function-list/FunctionsListPage.test.tsx Updates cluster service mocks/fixtures to the new return shape; removes list-page revision matching test now covered at the hook level.
src/pages/function-list/components/FunctionTable.tsx Renames delete target prop to knativeService and updates FunctionTableItem accordingly.
src/pages/function-list/components/FunctionTable.test.tsx Fixes fixture to use a real Knative Service object and updates expectations for delete modal invocation.
src/pages/function-create/FunctionCreatePage.test.tsx Adjusts mocked useClusterService return shape.
src/common/services/cluster/useClusterService.ts Implements the new correlated functions record and centralizes revision-based pairing logic.
src/common/services/cluster/useClusterService.test.tsx Adds/updates tests for correlation behavior and error propagation with the new return type.
docs/features.json Documents the refactor work item in the feature checklist.
docs/claude-progress.txt Updates the progress log with the work completed in this refactor.

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

Comment thread src/pages/function-list/FunctionsListPage.tsx
Comment thread src/pages/function-list/FunctionsListPage.test.tsx
Comment thread docs/features.json
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