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

fix: adds an additional printer column annotation #6390

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

shawkins
Copy link
Contributor

Description

closes: #3069

I believe the is the most straight-foward appraoch to adding general additional printer columns.

Other thoughts:

  • we could reuse the existing PrinterColumn annotation. However I didn't like about that is that it mixes the usage models, so the javadocs / validations would need to be more extensive.
  • allow the annotation to appear in other places. I think we'd at least need to auto-prefix the paths with the current path within the structure - we do have that as we're navigating over the object model. This can be easily added later if needed.
  • it's not being extensively validated. For example we could check that the path provided is valid / actually exists.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@baloo42
Copy link
Contributor

baloo42 commented Sep 30, 2024

👍 worked on the same last weekend, but no tests yet: baloo42#10

Looks very similar, but I used enums for format and type. I think using enums is better here, because not all formats and types are allowed to be used here. What do you think on enums?

  • we could reuse the existing PrinterColumn annotation. However I didn't like about that is that it mixes the usage models, so the javadocs / validations would need to be more extensive.

I also wouldn't like it if we reuse the PrinterColumn. Too many differences to explain.

  • allow the annotation to appear in other places. I think we'd at least need to auto-prefix the paths with the current path within the structure - we do have that as we're navigating over the object model. This can be easily added later if needed.

I think there are pro's and con's about this. It is possible and might be explainable
but if we don't implement it, the difference would be better:

@PrinterColumn Uses magic to find the path
@AdditionalPrinterColumn No magic involved, you as user are fully responsible.

👍 to postpone this to next iteration at least.

  • it's not being extensively validated. For example we could check that the path provided is valid / actually exists.

👍 same, as a above. If we validate it, it must support all cases because CRDGenerator is now fully responsible instead of the user.

@shawkins
Copy link
Contributor Author

worked on the same last weekend, but no tests yet: baloo42#10

Whoops, sorry for the duplication of effort.

What do you think on enums?

My only thought is the mismatch with the PrinterColumn annotation. To evolve the other annotation we'd have to accept Object for a major release before restricting back to an enum.

I've added your enums to the this pr.

to postpone this to next iteration at least.

I'm guessing that it may never be needed - what are the chances that someone wants the same set of printer columns in two different CRDs based upon a common object?

@baloo42
Copy link
Contributor

baloo42 commented Sep 30, 2024

worked on the same last weekend, but no tests yet: baloo42#10

Whoops, sorry for the duplication of effort.

no worries, I havn't published or noted it somewhere. My fault ^^

What do you think on enums?

My only thought is the mismatch with the PrinterColumn annotation. To evolve the other annotation we'd have to accept Object for a major release before restricting back to an enum.

I've added your enums to the this pr.

👍
For @PrinterColumn we could also phase it out:

  1. Add additional enum param formatStrict, deprecate format
  2. Replace format with enum param, deprecate formatStrict
  3. Remove formatStrict

This would require the same amount of major releases but avoids Object or do I miss something?

to postpone this to next iteration at least.

I'm guessing that it may never be needed - what are the chances that someone wants the same set of printer columns in two different CRDs based upon a common object?

Full ack. There is no need for additional ways. If someone wants to configure a printer column deep in the hierarchy and maybe shared between CRDs, he should and can already use PrinterColumn.

FLOAT("float"),
DOUBLE("double"),
BYTE("byte"),
BINARY("binary"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Altenatively, I'm fine if you want to take over ownership of this feature from your branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want, you can assign it to me but it doesn't make a lot sense too me as yours is almost ready.
Your approach is able collect the path, my approach tries to distinguesh between top level annotations and annotations in the hierarchy a little bit more but without the ability to collect the path.
So it depends on which direction we want to go.

@shawkins
Copy link
Contributor Author

shawkins commented Oct 1, 2024

This would require the same amount of major releases but avoids Object or do I miss something?

Actually Object won't work at all for an annotation property. So it either needs to be a breaking change for 7.0 or done over 3 major releases with the additional field. I'd opt for just doing the breaking change instead.

Copy link
Contributor

@baloo42 baloo42 left a comment

Choose a reason for hiding this comment

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

FYI: I also tried to add an approval test (only for @PrinterColumns) to compare if something breaks with this change.

Your change in this PR looks good, but it seems there is a bug in api-v1 which blocks us to add an approval test at the moment:

@Data
public class PrinterColumnSpec {
  @PrinterColumn
  private String fromLevel0;

  private DeepLevel1 deepLevel1;

  @Data
  public static class DeepLevel1 {

    @PrinterColumn
    private Integer fromLevel1;
  }
}

Result with api-v2 (this MR):

    - jsonPath: ".spec.deepLevel1.fromLevel1"
      name: "FROMLEVEL1"
      priority: 0
      type: "integer"
    - jsonPath: ".spec.fromLevel0"
      name: "FROMLEVEL0"
      priority: 0
      type: "string"

Result with api-v1:

    - jsonPath: ".spec.deepLevel1.fromLevel1"
      name: "FROMLEVEL1"
      priority: 0
      type: "integer"
    - jsonPath: ".spec.fromLevel0"
      name: "FROMLEVEL0"
      priority: 0
      type: "string"
    - jsonPath: ".spec.fromLevel1"
      name: "FROMLEVEL1"
      priority: 0
      type: "integer"

Should we fix this within this PR or create another one and add an approval test later?

} else if ("string".equals(type) && "date".equals(property.schema.getFormat())) {
type = "date";
}
if (property.annotation instanceof AdditionalPrinterColumn) {
Copy link
Contributor

Choose a reason for hiding this comment

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

At the moment the @AdditionalPrinterColum is collected from everywhere in the spec or status type. Is this intended?

We should either clarify this in the description of the annotation or pick it only from the custom resource class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment the @AdditionalPrinterColum is collected from everywhere in the spec or status type.

It should not be: https://github.com/fabric8io/kubernetes-client/pull/6390/files#diff-e5491c474236ab12f8e6f5d9895464ecf77754b17ddb0e182682add6db8620ceR146

We should either clarify this in the description of the annotation or pick it only from the custom resource class.

It is documented as intended for the root: https://github.com/fabric8io/kubernetes-client/pull/6390/files#diff-669d381122146d717c360f17fcfe5eeaab88b5c84dd4bfcf81b6de71aa5a75c1R25

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, seems like it was a problem on my side. I have checked out your branch again and could not reproduce it. Looks fine now!

@shawkins
Copy link
Contributor Author

Should we fix this within this PR or create another one and add an approval test later?

Do you mean fix the v1 implementation? I don't think we need to bother doing that.

based upon Bernhard Strähle's review

Signed-off-by: Steve Hawkins <[email protected]>
Signed-off-by: Steve Hawkins <[email protected]>
@baloo42
Copy link
Contributor

baloo42 commented Oct 16, 2024

Should we fix this within this PR or create another one and add an approval test later?

Do you mean fix the v1 implementation? I don't think we need to bother doing that.

Yes I mean fixing v1 because of differences in the approval tests. If we don't want to fix v1, then we should start splitting the approval tests so that we can add tests for new or breaking features. (not in this PR)

See also #6447 (comment)

@shawkins
Copy link
Contributor Author

Yes I mean fixing v1 because of differences in the approval tests. If we don't want to fix v1, then we should start splitting the approval tests so that we can add tests for new or breaking features. (not in this PR)

I'm good with that.

@manusa manusa added this to the 7.0.0 milestone Oct 18, 2024 — with automated-tasks
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, thx!

Copy link

sonarcloud bot commented Oct 18, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
78.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@manusa manusa merged commit 66dbab1 into fabric8io:main Oct 18, 2024
19 of 20 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.

JSONPath selection in PrinterColumn
4 participants