Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PlacementAPISpecCore struct #169

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

dprince
Copy link
Contributor

@dprince dprince commented Mar 1, 2024

This version of the struct (called "core") is meant to be used via the OpenStackControlplane. It is the same as PlacementAPISpec only it is missing the containerImages.

The Default() function for webhooks has been split accordingly.

Jira: OSPRH-4835

@openshift-ci openshift-ci bot requested review from kk7ds and mrkisaolamb March 1, 2024 20:19
@openshift-ci openshift-ci bot added the approved label Mar 1, 2024
@dprince dprince marked this pull request as draft March 4, 2024 11:15
dprince added 2 commits March 7, 2024 10:23
This version of the struct (called "core") is meant to
be used via the OpenStackControlplane. It is the same
as PlacementAPISpec only it is missing the containerImages.

The Default() function for webhooks has been split accordingly.

Jira: OSPRH-4835
@dprince dprince marked this pull request as ready for review March 7, 2024 18:15
@openshift-ci openshift-ci bot requested review from gibizer and olliewalsh March 7, 2024 18:15
Copy link
Contributor

@mrkisaolamb mrkisaolamb left a comment

Choose a reason for hiding this comment

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

I'm ok with this patch, but I will wait for @gibizer review

@@ -121,18 +126,27 @@ func (r *PlacementAPI) ValidateDelete() (admission.Warnings, error) {
}

func (r PlacementAPISpec) ValidateCreate(basePath *field.Path) field.ErrorList {
Copy link
Collaborator

Choose a reason for hiding this comment

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

note to myself: This is called by the webhook within the placement-operator via func (r *PlacementAPI) ValidateCreate()

return ValidateDefaultConfigOverwrite(basePath, r.DefaultConfigOverwrite)
}

func (r PlacementAPISpecCore) ValidateCreate(basePath *field.Path) field.ErrorList {
Copy link
Collaborator

Choose a reason for hiding this comment

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

note to myself: this will be called by the webhook in openstack-operator when validating the service core struct within the openstackcontrolplane struct.

Comment on lines -131 to +144
func (r PlacementAPISpec) ValidateDefaultConfigOverwrite(
func ValidateDefaultConfigOverwrite(
Copy link
Collaborator

Choose a reason for hiding this comment

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

An alternative would be to change this to use the PlacementAPISpecCore as a receiver. Then

  • func (r PlacementAPISpecCore) ValidateCreate can call it directly as the type matches
  • func (r PlacementAPISpec) ValidateCreate can call it on its internal core struct within its receiver. Golang actually expose the functions on the embedded struct on the embedding struct automatically.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This would reduce the change to gibizer@91e9a07

While this is not a big deal here in placement, I think if we apply this pattern to the nova PR that would reduce the change there significantly

Copy link
Collaborator

Choose a reason for hiding this comment

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

Applying it to nova is not a clear cut due to deeper nesting of structs without a common embedded base struct.

Copy link
Collaborator

@gibizer gibizer left a comment

Choose a reason for hiding this comment

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

Looks OK. I will consider refactoring this to the mentioned pattern later.

Copy link
Contributor

openshift-ci bot commented Mar 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprince, gibizer

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

@openshift-merge-bot openshift-merge-bot bot merged commit 0bd583d into openstack-k8s-operators:main Mar 8, 2024
6 checks passed
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.

3 participants