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

Deprecate PrinterColumn annotation to move it to the crd-generator module #5342

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#### New Features
* Fix #5133: Support for using TokenRequest for existing ServiceAccount

#### Deprecations
* Deprecating `io.fabric8.kubernetes.model.annotation.PrinterColumn` in favor of: `io.fabric8.crd.generator.annotation.PrinterColumn`

#### _**Note**_: Breaking changes
* Fix #2718: KubernetesResourceUtil.isResourceReady was deprecated. Use `client.resource(item).isReady()` or `Readiness.getInstance().isReady(item)` instead.
* Fix #5171: Removed Camel-K extension, use [`org.apache.camel.k:camel-k-crds`](https://central.sonatype.com/artifact/org.apache.camel.k/camel-k-crds) instead.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface PrinterColumn {

/**
* The name of the column.
* An empty column name implies the use of the property name
*
* @return the column name, or empty string if the annotated property name should be used.
*/
String name() default "";

/**
* The printer column format.
*
* @return the format or empty string if no format is specified.
*/
String format() default "";

/**
* The printer column priority.
*
* @return the priority or 0 if no priority is specified.
*/
int priority() default 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.fabric8.crd.generator.visitor;

import io.fabric8.kubernetes.model.annotation.PrinterColumn;
import io.fabric8.crd.generator.annotation.PrinterColumn;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package io.fabric8.crd.example.joke;

import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import io.fabric8.kubernetes.model.annotation.PrinterColumn;
import io.fabric8.crd.generator.annotation.PrinterColumn;

public class JokeRequestSpec {

Expand All @@ -42,7 +42,7 @@ public enum ExcludedTopic {
@PrinterColumn(name = "jokeCategory", priority = 1)
@JsonPropertyDescription("category-description")
private Category category = Category.Any;
@PrinterColumn(name = "excludedTopics")
@io.fabric8.kubernetes.model.annotation.PrinterColumn(name = "excludedTopics")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're still using deprecated PrinterColumn here.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. I think imports in the io.fabric8.crd.generator.zookeeper.v1.ZookeeperStatus also must be updated because it still uses deprecated version of PrinterColumn.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's intentional, we want to test that both annotations will work.

Copy link
Contributor

Choose a reason for hiding this comment

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

then when do you plan to replace old annotations?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the release of the next Minor, theoretically 6.9 at this point.

private ExcludedTopic[] excluded = new ExcludedTopic[] { ExcludedTopic.nsfw, ExcludedTopic.racist,
ExcludedTopic.sexist };
private boolean safe;
Expand Down
6 changes: 3 additions & 3 deletions doc/CRD-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ The field will be marked as `required` in the generated CRD, such as:
type: object
```

### io.fabric8.kubernetes.model.annotation.PrinterColumn
### io.fabric8.crd.generator.annotation.PrinterColumn

If a field or one of its accessors is annotated with `io.fabric8.kubernetes.model.annotation.PrinterColumn`
If a field or one of its accessors is annotated with `io.fabric8.crd.generator.annotation.PrinterColumn`

```java
public class ExampleSpec {
Expand Down Expand Up @@ -465,7 +465,7 @@ The CRD generator will add the additional `labels`:
| `io.fabric8.crd.generator.annotation.SchemaSwap` | Similar to SchemaFrom, but can be applied at any point in the class hierarchy |
| `io.fabric8.crd.generator.annotation.Annotations` | Additional `annotations` in `metadata` |
| `io.fabric8.crd.generator.annotation.Labels` | Additional `labels` in `metadata` |
| `io.fabric8.kubernetes.model.annotation.PrinterColumn` | Customize columns shown by the `kubectl get` command |
| `io.fabric8.crd.generator.annotation.PrinterColumn` | Customize columns shown by the `kubectl get` command |

A field of type `com.fasterxml.jackson.databind.JsonNode` is encoded as an empty object with `x-kubernetes-preserve-unknown-fields: true` defined.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @deprecated: use io.fabric8.crd.generator.annotation.PrinterColumn instead
*/
@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface PrinterColumn {

/**
Expand Down