Skip to content

refactor: migrate to api-server library pattern#1

Merged
joshuasequeira19 merged 2 commits into
mainfrom
feat/refactor-use-api-server-library
Oct 10, 2025
Merged

refactor: migrate to api-server library pattern#1
joshuasequeira19 merged 2 commits into
mainfrom
feat/refactor-use-api-server-library

Conversation

@joshuasequeira19

Copy link
Copy Markdown
Member

Replace direct Kubernetes access with api-server service library for unified business logic across CLI and API server.

Changes

Architecture

  • Replace pkg/k8s with pkg/workspace wrapper service
  • Import api-server/pkg/services/forkspacer as library
  • All commands delegate to api-server for business logic
  • Add Get() and List() methods in wrapper (api-server missing these)

Commands Refactored

  • create: Uses service.Create() with proper waitForWorkspaceReady polling
  • list: Uses service.List() with namespace filtering support
  • get: Uses service.Get()
  • delete: Uses service.Delete()
  • hibernate: Uses service.SetHibernation(true)
  • wake: Uses service.SetHibernation(false)

Code Quality

  • Simplified codebase: -178 net lines of code
  • Fixed 3 go vet errors (non-constant format strings)
  • Updated to Go 1.25
  • Added Makefile for build automation
  • Improved waitForWorkspaceReady with proper polling and error detection

Documentation

  • Updated README architecture section
  • Documented api-server library pattern
  • Fixed project structure (removed pkg/k8s references)
  • Updated development prerequisites to Go 1.25

CI/CD

  • Updated workflow to Go 1.25
  • Removed -race flag (Go 1.25 compatibility)
  • Simplified test execution

Benefits

  • Single source of truth for workspace operations
  • Type-safe compile-time checking
  • No code duplication for business logic
  • Consistent validation and error handling
  • No network overhead (direct library calls)

Breaking Changes

  • Removed pkg/k8s (replaced by pkg/workspace)
  • Added dependency on api-server v1.0.0
  • Requires Go 1.25 (updated from 1.24)

Replace direct Kubernetes access with api-server service library for
unified business logic across CLI and API server.

## Changes

### Architecture
- Replace pkg/k8s with pkg/workspace wrapper service
- Import api-server/pkg/services/forkspacer as library
- All commands delegate to api-server for business logic
- Add Get() and List() methods in wrapper (api-server missing these)

### Commands Refactored
- create: Uses service.Create() with proper waitForWorkspaceReady polling
- list: Uses service.List() with namespace filtering support
- get: Uses service.Get()
- delete: Uses service.Delete()
- hibernate: Uses service.SetHibernation(true)
- wake: Uses service.SetHibernation(false)

### Code Quality
- Simplified codebase: -178 net lines of code
- Fixed 3 go vet errors (non-constant format strings)
- Updated to Go 1.25
- Added Makefile for build automation
- Improved waitForWorkspaceReady with proper polling and error detection

### Documentation
- Updated README architecture section
- Documented api-server library pattern
- Fixed project structure (removed pkg/k8s references)
- Updated development prerequisites to Go 1.25

### CI/CD
- Updated workflow to Go 1.25
- Removed -race flag (Go 1.25 compatibility)
- Simplified test execution

## Benefits

- Single source of truth for workspace operations
- Type-safe compile-time checking
- No code duplication for business logic
- Consistent validation and error handling
- No network overhead (direct library calls)

## Breaking Changes

- Removed pkg/k8s (replaced by pkg/workspace)
- Added dependency on api-server v1.0.0
- Requires Go 1.25 (updated from 1.24)
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

GitHub Actions runners are amd64/x86_64, so we can only verify the
linux-amd64 binary. Trying to execute linux-arm64 binary on amd64
runner causes 'Exec format error'.

This ensures we still verify the binary works, but only for the
architecture that matches the runner.
@joshuasequeira19 joshuasequeira19 merged commit 960ce6d into main Oct 10, 2025
7 of 8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2025
joshuasequeira19 added a commit that referenced this pull request Oct 10, 2025
The tarballs were containing platform-specific names like
'forkspacer-darwin-arm64' but the install instructions expect
just 'forkspacer'.

Now the workflow renames the binary to 'forkspacer' (or 'forkspacer.exe'
for Windows) before creating the archive. This matches industry standard
practice (kubectl, helm, etc.).

Fixes: #1 (install instructions not working)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant