Skip to content

chore: update dependencies and refactor API types for resource manage… - #34

Merged
iasthc merged 1 commit into
mainfrom
add-k8s-api-deps
Mar 4, 2026
Merged

chore: update dependencies and refactor API types for resource manage…#34
iasthc merged 1 commit into
mainfrom
add-k8s-api-deps

Conversation

@iasthc

@iasthc iasthc commented Mar 4, 2026

Copy link
Copy Markdown
Member

…ment

  • Added k8s.io/api as a dependency to support new API types.
  • Refactored ModuleSpec and SimpleAppSpec to replace runtime.RawExtension with specific Kubernetes API types for better clarity and type safety.
  • Updated CRD definitions for LimitRange and ResourceQuota to reflect changes in the underlying types.
  • Enhanced deepcopy functions to accommodate the new type structures.
  • Removed outdated comments and improved descriptions in the CRDs for better understanding.

…ment

- Added k8s.io/api as a dependency to support new API types.
- Refactored ModuleSpec and SimpleAppSpec to replace runtime.RawExtension with specific Kubernetes API types for better clarity and type safety.
- Updated CRD definitions for LimitRange and ResourceQuota to reflect changes in the underlying types.
- Enhanced deepcopy functions to accommodate the new type structures.
- Removed outdated comments and improved descriptions in the CRDs for better understanding.
Copilot AI review requested due to automatic review settings March 4, 2026 05:54
@iasthc
iasthc merged commit d6d26f2 into main Mar 4, 2026
5 checks passed
@iasthc
iasthc deleted the add-k8s-api-deps branch March 4, 2026 05:54
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the type safety and clarity of the project's Kubernetes Custom Resources by replacing generic runtime.RawExtension fields with concrete Kubernetes API types. This change not only improves the developer experience by providing better compile-time checks and IDE support but also makes the CRD definitions more explicit and robust. The update involves adding a new Kubernetes API dependency, refactoring core spec definitions, and updating associated deepcopy logic and CRD schemas to align with these more specific types.

Highlights

  • Dependency Update: The k8s.io/api dependency has been added to the project, enabling direct use of Kubernetes API types.
  • API Type Refactoring: The ModuleSpec and SimpleAppSpec structs have been refactored to replace runtime.RawExtension with specific Kubernetes API types (appsv1.DeploymentSpec, corev1.ServiceSpec, corev1.PersistentVolumeClaimSpec, corev1.ResourceQuotaSpec, corev1.LimitRangeSpec), significantly improving type safety and clarity.
  • CRD Definition Enhancement: Custom Resource Definition (CRD) schemas for LimitRange and ResourceQuota within WorkspaceSpec have been expanded to reflect the detailed structure of their respective Kubernetes API types, moving away from x-kubernetes-preserve-unknown-fields.
  • Deepcopy Function Updates: Generated deepcopy functions have been updated to correctly handle the new specific Kubernetes API types, ensuring proper object cloning.
Changelog
  • addons/v1alpha1/module_types.go
    • Removed comments related to runtime.RawExtension usage for Values field.
  • apps/v1alpha1/simpleapp_types.go
    • Imported appsv1 and corev1 packages.
    • Replaced runtime.RawExtension with appsv1.DeploymentSpec for Deployment field.
    • Replaced runtime.RawExtension with corev1.ServiceSpec for Service field.
    • Replaced runtime.RawExtension with corev1.PersistentVolumeClaimSpec for PersistentVolumeClaim field.
    • Updated comments for Deployment, Service, and PersistentVolumeClaim fields to reflect specific types.
  • apps/v1alpha1/zz_generated.deepcopy.go
    • Imported corev1 and metav1 packages.
    • Updated DeepCopyInto method for SimpleAppSpec to use corev1.ServiceSpec and corev1.PersistentVolumeClaimSpec.
    • Updated DeepCopyInto method for SimpleAppStatus to use metav1.Condition.
  • config/crd/bases/addons.otterscale.io_modules.yaml
    • Removed descriptive comments for the Values field in ModuleSpec related to RawExtension.
  • config/crd/bases/tenant.otterscale.io_workspaces.yaml
    • Expanded the schema definition for limitRange to include detailed properties of corev1.LimitRangeSpec.
    • Expanded the schema definition for resourceQuota to include detailed properties of corev1.ResourceQuotaSpec.
  • go.mod
    • Added k8s.io/api v0.35.1 as a direct dependency.
  • go.sum
    • Updated checksums for k8s.io/api and other related indirect dependencies.
  • tenant/v1alpha1/workspace_types.go
    • Imported corev1 package and removed runtime package import.
    • Replaced runtime.RawExtension with corev1.ResourceQuotaSpec for ResourceQuota field.
    • Replaced runtime.RawExtension with corev1.LimitRangeSpec for LimitRange field.
    • Removed kubebuilder:pruning:PreserveUnknownFields annotations and related comments for ResourceQuota and LimitRange.
  • tenant/v1alpha1/zz_generated.deepcopy.go
    • Imported corev1 and metav1 packages.
    • Updated DeepCopyInto method for WorkspaceSpec to use corev1.ResourceQuotaSpec and corev1.LimitRangeSpec.
    • Updated DeepCopyInto method for WorkspaceStatus to use metav1.Condition.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request is a valuable refactoring that significantly improves type safety and clarity by replacing runtime.RawExtension with specific, strongly-typed Kubernetes API objects for various resources. This change enhances CRD validation and overall maintainability. The dependency updates and modifications to the deepcopy functions are consistent with this goal. I've identified one issue in the go.sum file that could affect build stability, which should be straightforward to resolve.

Comment thread go.sum
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The go.sum file appears to have been left in an inconsistent state. While this line (the content hash for gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405) was removed, the corresponding /go.mod entry on the next line was not. A go.sum file should have both the module content hash and the go.mod hash for each version, or neither. This inconsistency can cause build or verification failures.

Please run go mod tidy to automatically clean up the go.sum file and ensure its consistency.

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 updates the API surface of several CRDs to use strongly-typed Kubernetes API specs (instead of runtime.RawExtension), adds the required Kubernetes dependency, and regenerates CRD/deepcopy artifacts accordingly.

Changes:

  • Add k8s.io/api dependency to support embedding core/apps Kubernetes spec types in CRDs.
  • Refactor WorkspaceSpec and SimpleAppSpec to use corev1/appsv1 spec structs (and update generated deepcopy code).
  • Update the Workspace CRD schema to reflect the new structural schemas for limitRange and resourceQuota (and remove outdated CRD descriptions/comments elsewhere).

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tenant/v1alpha1/workspace_types.go Switch Workspace quota/limit fields to typed corev1 specs.
tenant/v1alpha1/zz_generated.deepcopy.go Regenerate deepcopy to match new typed fields and metav1 conditions.
config/crd/bases/tenant.otterscale.io_workspaces.yaml Update Workspace CRD OpenAPI schema for LimitRangeSpec / ResourceQuotaSpec.
apps/v1alpha1/simpleapp_types.go Switch SimpleApp embedded specs to typed appsv1/corev1 types.
apps/v1alpha1/zz_generated.deepcopy.go Regenerate deepcopy to match new typed fields and metav1 conditions.
addons/v1alpha1/module_types.go Remove outdated comment text around Helm values field behavior.
config/crd/bases/addons.otterscale.io_modules.yaml Remove outdated CRD description text for Module values.
go.mod Add k8s.io/api (plus indirect dependency adjustments).
go.sum Record new module sums from the dependency update.

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

Comment on lines 44 to 49
// Values overrides the default Helm chart values for Helm-based modules.
// Only applicable when the referenced ModuleTemplate uses a HelmChart template.
// Ignored for Kustomization-based modules.
// Accepts arbitrary JSON; RawExtension is used instead of apiextensionsv1.JSON
// to avoid pulling in the k8s.io/apiextensions-apiserver dependency.
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
Values *runtime.RawExtension `json:"values,omitempty"`

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description says ModuleSpec was refactored to replace runtime.RawExtension with typed Kubernetes API types, but ModuleSpec.Values is still a *runtime.RawExtension. Either update the PR description to reflect the actual change, or complete the refactor for ModuleSpec (and regenerate CRDs/deepcopy as needed).

Copilot uses AI. Check for mistakes.
Comment on lines 100 to +106
// ResourceQuota defines the compute resource constraints (CPU, Memory, etc.) applied to the underlying namespace.
// The actual schema is composed at runtime by the Schema RPC from the core/v1 ResourceQuota.
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
ResourceQuota *runtime.RawExtension `json:"resourceQuota,omitempty"`
ResourceQuota *corev1.ResourceQuotaSpec `json:"resourceQuota,omitempty"`

// LimitRange defines the default resource limits and requests for pods in the workspace.
// The actual schema is composed at runtime by the Schema RPC from the core/v1 LimitRange.
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
LimitRange *runtime.RawExtension `json:"limitRange,omitempty"`
LimitRange *corev1.LimitRangeSpec `json:"limitRange,omitempty"`

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

Changing WorkspaceSpec.resourceQuota and .limitRange from RawExtension to corev1 specs is a wire-format/schema tightening (unknown fields previously accepted will now be rejected/pruned). If existing clusters may already have Workspace objects, please add/describe a migration strategy (e.g., version bump + conversion webhook or documented upgrade/migration steps) to avoid breaking upgrades.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +42
// Deployment defines the pod template, replicas, and update strategy
// for the application workload.
// +required
Deployment runtime.RawExtension `json:"deployment"`
Deployment appsv1.DeploymentSpec `json:"deployment"`

// Service defines the Service configuration.
// If specified, a Service will be created.
// The actual schema is composed at runtime by the Schema RPC from the core/v1 Service.
// +kubebuilder:pruning:PreserveUnknownFields
// If specified, a Service will be created to expose the application.
// +optional
Service *runtime.RawExtension `json:"service,omitempty"`
Service *corev1.ServiceSpec `json:"service,omitempty"`

// PersistentVolumeClaim defines the PersistentVolumeClaim configuration.
// If specified, a PersistentVolumeClaim will be created.
// The actual schema is composed at runtime by the Schema RPC from the core/v1 PersistentVolumeClaim.
// +kubebuilder:pruning:PreserveUnknownFields
// If specified, a PersistentVolumeClaim will be created for persistent storage.
// +optional
PersistentVolumeClaim *runtime.RawExtension `json:"persistentVolumeClaim,omitempty"`
PersistentVolumeClaim *corev1.PersistentVolumeClaimSpec `json:"persistentVolumeClaim,omitempty"`

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

Changing SimpleAppSpec.deployment/service/persistentVolumeClaim from RawExtension to typed Kubernetes specs is a backward-incompatible schema tightening for existing CRs/clients. If this API is already in use, consider a versioned migration path (new version + conversion) or document upgrade steps to ensure existing SimpleApps remain valid.

Copilot uses AI. Check for mistakes.
Comment on lines 54 to +60
limitRange:
description: |-
LimitRange defines the default resource limits and requests for pods in the workspace.
The actual schema is composed at runtime by the Schema RPC from the core/v1 LimitRange.
description: LimitRange defines the default resource limits and requests
for pods in the workspace.
properties:
limits:
description: Limits is the list of LimitRangeItem objects that
are enforced.

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

This CRD change removes preserve-unknown-fields and introduces structural schemas for limitRange/resourceQuota. That can make previously-stored Workspace objects invalid if they contained extra/unrecognized fields under these blocks. Ensure the release/upgrade notes include a migration or validation plan for existing clusters before applying the updated CRD.

Copilot uses AI. Check for mistakes.
Comment on lines 210 to +216
resourceQuota:
description: |-
ResourceQuota defines the compute resource constraints (CPU, Memory, etc.) applied to the underlying namespace.
The actual schema is composed at runtime by the Schema RPC from the core/v1 ResourceQuota.
description: ResourceQuota defines the compute resource constraints
(CPU, Memory, etc.) applied to the underlying namespace.
properties:
hard:
additionalProperties:
anyOf:

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

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

This CRD change removes preserve-unknown-fields and introduces a strict schema for resourceQuota. If any existing Workspace objects relied on arbitrary keys under resourceQuota, they will fail validation after the CRD update. Please ensure upgrade guidance/migration is in place (or keep unknown-field preservation if backward compatibility is required).

Copilot uses AI. Check for mistakes.
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