Skip to content

Commit

Permalink
fix: provide more context when group/plural are missing
Browse files Browse the repository at this point in the history
Fixes #4396
  • Loading branch information
metacosm authored and manusa committed Sep 8, 2022
1 parent 951a7f5 commit 5d66189
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
#### Improvements
* Fix #4348: Introduce specific annotations for the generators
* Fix #4365: The Watch retry logic will handle more cases, as well as perform an exceptional close for events that are not properly handled. Informers can directly provide those exceptional outcomes via the SharedIndexInformer.stopped CompletableFuture.
* Fix #4396: Provide more error context when @Group/@Version annotations are missing

#### Dependency Upgrade
* Fix #4243: Update Tekton pipeline model to v0.39.0
Expand Down Expand Up @@ -37,7 +38,6 @@ fix #4373: NO_PROXY should allow URIs with hyphens ("circleci-internal-outer-bui
* Fix #4320: corrected leader transitions field on leader election leases
* Fix #4360: JUnit dependencies aren't leaked in child modules


#### Improvements
* Fix #887: added KubernetesClient.visitResources to search and perform other operations across all resources.
* Fix #3960: adding a KubernetesMockServer.expectCustomResource helper method and additional mock crd support
Expand Down
Expand Up @@ -30,6 +30,6 @@
@Target({TYPE})
@Retention(RUNTIME)
public @interface Group {

String NAME = Group.class.getSimpleName();
String value();
}
Expand Up @@ -29,6 +29,7 @@
@Target({TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Version {
String NAME = Version.class.getSimpleName();

/**
* The name of this version.
Expand Down
Expand Up @@ -84,8 +84,7 @@ static String getApiVersion(Class<?> clazz) {
}
if (group != null || version != null) {
throw new IllegalArgumentException(
"You need to specify both @" + Group.class.getSimpleName() + " and @"
+ Version.class.getSimpleName() + " annotations if you specify either");
"You need to specify both @" + Group.NAME + " and @" + Version.NAME + " annotations if you specify either");
}
return null;
}
Expand Down Expand Up @@ -158,7 +157,13 @@ default String getSingular() {
}

static String getFullResourceName(Class<?> clazz) {
return getFullResourceName(getPlural(clazz), getGroup(clazz));
final String plural = getPlural(clazz);
final String group = getGroup(clazz);
if (plural == null || group == null) {
throw new IllegalArgumentException(
"Should provide non-null plural and/or group. Is " + clazz.getName() + " properly annotated with @" + Group.NAME + " and/or @" + Version.NAME + "?");
}
return getFullResourceName(plural, group);
}

static String getFullResourceName(String plural, String group) {
Expand All @@ -168,6 +173,7 @@ static String getFullResourceName(String plural, String group) {
}

@JsonIgnore
@SuppressWarnings("unused")
default String getFullResourceName() {
return getFullResourceName(getClass());
}
Expand Down

0 comments on commit 5d66189

Please sign in to comment.