Skip to content

Conversation

@timflannagan
Copy link
Member

Description

This removes the legacy getter functions defined in the api/ directory. These pattern is no longer relevant now that we've migrated away from proto-based APIs in favor of kubebuilder.

Fixes #12227.

Change Type

/kind cleanup

Changelog

NONE

Additional Notes

This removes the legacy getter functions defined in the api/
directory. These pattern is no longer relevant now that we've
migrated away from proto-based APIs in favor of kubebuilder.

Signed-off-by: timflannagan <[email protected]>
Copilot AI review requested due to automatic review settings October 28, 2025 20:30
@timflannagan timflannagan changed the title Remove getter usage for API fields api: Remove proto-style getter functions Oct 28, 2025
@github-actions github-actions bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none labels Oct 28, 2025
@timflannagan timflannagan force-pushed the chore/remove-getters-api branch from fa552f7 to 17fc7f1 Compare October 28, 2025 20:39
Copy link
Contributor

Copilot AI left a comment

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 the codebase to remove a large number of getter methods (e.g., GetRegistry(), GetEnabled(), etc.) from API types and replaces their usage with direct field access. This simplification removes over 600 lines of boilerplate code while adding nil checks where necessary to maintain safety.

  • Removed all Get*() methods from API types in api/v1alpha1 package
  • Updated all call sites to use direct field access with proper nil checks
  • Added early nil returns in helper functions to prevent nil pointer dereferences

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/v1alpha1/kube_types.go Removed getter methods for Image, Service, ServiceAccount, Pod, and GracefulShutdownSpec types
api/v1alpha1/gateway_parameters_types.go Removed getter methods for all GatewayParameters-related types including KubernetesProxyConfig, ProxyDeployment, containers, and AI extension types
pkg/deployer/values_helpers.go Updated to use direct field access with nil checks; added early returns in GetServiceValues, GetServiceAccountValues, and enhanced tracing conversion logic
pkg/deployer/merge.go Updated all merge functions to use direct field access instead of getter methods
pkg/deployer/gateway_parameters.go Added conditional nil checks when accessing nested fields, replaced slice creation pattern with conditional appends
internal/kgateway/deployer/gateway_parameters.go Added nil checks before accessing Kube field and wrapped field accesses in conditional blocks

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

istioContainerConfig := istioConfig.GetIstioProxyContainer()
aiExtensionConfig := kubeProxyConfig.GetAiExtension()
if aiExtensionConfig != nil && aiExtensionConfig.GetEnabled() != nil && *aiExtensionConfig.GetEnabled() {
deployConfig := kubeProxyConfig.Deployment
Copy link
Contributor

Choose a reason for hiding this comment

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

probably need a nil check for kubeProxyConfig first

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm getting dizzy reading through this implementation. Such an eye sore in it's current form. Going to take a stab at cleaning this up and address any potential NPEs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Part 1 of the cleanup: #12747.

@timflannagan timflannagan added the work in progress Indicates that a PR should not merge because it is a work in progress label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none work in progress Indicates that a PR should not merge because it is a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup: move away from proto style getters for kubebuilder type

2 participants