Skip to content

Conversation

@TylerGillson
Copy link
Collaborator

@TylerGillson TylerGillson commented Jul 21, 2025

The original goal of this PR was to make API defaulting consistent for all fields and clean up a bit of unnecessary code. However, a bunch of other changes snuck in along the way.

API Conventions

  • Use pointers only for fields that are entirely optional and have no nested defaults.
  • All fields defaulted to their zero value (via // +kubebuilder:default:={}, to enable nested defaults) are no longer pointers. Use this approach to properly default registrationAuth.
  • All fields are explicitly optional or explicitly required. This resolved a few issues with the OpenAPI spec for the FleetConfig CRD where fields were marked required that should not have been.
  • Use +optional in conjunction with every omitempty and +required otherwise.

Fixes

  • Force users to provide exactly one of clusterManager or singleton. Clarified webhook validation accordingly. Updated Helm chart values and FleetConfig template to specify either clusterManager or singleton mode.
  • Made Helm values optional in singleton mode (made the Helm field a pointer accordingly). This is because installing the multicluster-controlplane chart with default values should be supported.
  • Improved validation logic for ManagedClusterKubeconfig in hosted mode by ensuring a kubeconfig secret is provided.
  • Added RBAC required for singleton mode to the default manager role.

@openshift-ci
Copy link

openshift-ci bot commented Jul 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TylerGillson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TylerGillson TylerGillson force-pushed the chore/tidy-api-defaults branch 3 times, most recently from f64b3a2 to ecaf7a9 Compare July 21, 2025 22:10
@TylerGillson TylerGillson changed the title chore: use +optional in conjunction with every omitempty; tidy code accordingly refactor: remove pointers from API, use +optional in conjunction with every omitempty Jul 21, 2025
…junction with all omitemptys, tidy code

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
@TylerGillson TylerGillson force-pushed the chore/tidy-api-defaults branch from ecaf7a9 to 3a0efd4 Compare July 21, 2025 22:43
@TylerGillson TylerGillson changed the title refactor: remove pointers from API, use +optional in conjunction with every omitempty refactor: use pointers only for optional fields, use +optional in conjunction with every omitempty Jul 21, 2025
Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
@TylerGillson TylerGillson changed the title refactor: use pointers only for optional fields, use +optional in conjunction with every omitempty refactor: standardize API conventions Jul 22, 2025
@arturshadnik
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 22, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 6a38ee3 into open-cluster-management-io:main Jul 22, 2025
7 checks passed
arturshadnik pushed a commit to arturshadnik/ocm-labs that referenced this pull request Jul 22, 2025
* refactor: use pointers only for optional fields, use +optional in conjunction with all omitemptys, tidy code

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* chore: clarify webhook for hosted mode

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* fix: force specification of either clusterManager or singleton

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* chore: make reviewable

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

---------

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
@TylerGillson TylerGillson changed the title refactor: standardize API conventions 🌱 standardize API conventions Jul 22, 2025
openshift-merge-bot bot pushed a commit that referenced this pull request Jul 22, 2025
* refactor: standardize API conventions (#31)

* refactor: use pointers only for optional fields, use +optional in conjunction with all omitemptys, tidy code

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* chore: clarify webhook for hosted mode

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* fix: force specification of either clusterManager or singleton

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* chore: make reviewable

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

---------

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>

* feat: implement addon create and delete reconcile on the hub

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: address review comments

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* refactor: do all CMA purging at the end

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: clarify comment

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* fix: update manager rbac

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* feat: use separate CM for each addon's manifests

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: error wording

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: try to delete all addons before returning errors

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* fix: move err return to prevent orphaning addon CRs

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: parse URLs using lib; use different keys depending on manifest source

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: make reviewable

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: make reviewable

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: add annotations and labels to CMs

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* feat: add addon manifest validation to fcc webhook

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* chore: readibility

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* fix: dont generate deepcopy methods for custom validator

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

* fix: dont use pointer for addonconfig

Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>

---------

Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
Co-authored-by: Tyler Gillson <tyler.gillson@gmail.com>
@TylerGillson TylerGillson deleted the chore/tidy-api-defaults branch July 22, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants