Skip to content

Commit

Permalink
Deprecate PrinterColumn annotation to move it to the crd-generator mo…
Browse files Browse the repository at this point in the history
…dule
  • Loading branch information
andreaTP committed Jul 20, 2023
1 parent a20da9a commit 8efaf0a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 6 deletions.
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")
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

0 comments on commit 8efaf0a

Please sign in to comment.