Skip to content

Conversation

@pengzhouml
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 17, 2025 06:51
Copy link

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 ensures that existing Kubernetes Service resources are updated when new ports are added by introducing patch-based diffing and refactoring service generation.

  • Use k8s-objectmatcher to calculate and apply patches in ReconcileServices, updating Services when specs differ.
  • Add StsName to serviceParameters and switch selector logic to getSelectorLabels(params.StsName).
  • Remove deprecated helper methods (getService, CreateOrUpdateService) and refine import and label merging logic.
Comments suppressed due to low confidence (4)

pkg/k8sutil/service.go:18

  • [nitpick] The field name 'StsName' is an unclear abbreviation; consider renaming it to 'StatefulSetName' for clarity.
StsName     string

pkg/k8sutil/service.go:106

  • [nitpick] The declaration of svcParams could be simplified by directly using a short variable declaration (e.g., svcParams := generateServiceParams(cr)), removing the redundant zero-value initialization.
var svcParams serviceParameters = serviceParameters{}

pkg/k8sutil/service.go:125

  • Consider adding unit or integration tests for the service reconciliation logic, especially covering the update path when new ports are added to verify the patch and update behavior.
svcDef := generateService(service, cr)

pkg/k8sutil/service.go:17

  • Add a doc comment for the StsName field in serviceParameters to explain its purpose and usage.
type serviceParameters struct {

import (
"strings"

"github.com/cisco-open/k8s-objectmatcher/patch"
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider reorganizing imports to follow the project's style guide (e.g., grouping standard library, third-party, and local imports separately) for consistency.

Copilot uses AI. Check for mistakes.
@pengzhouml pengzhouml merged commit b62461b into develop Jun 17, 2025
3 checks 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.

3 participants