Skip to content

Commit 71f4fe1

Browse files
committed
feat: revert use of canonical class name as default controller name
1 parent d12bb06 commit 71f4fe1

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ static String getDefaultNameFor(ResourceController controller) {
6666
}
6767

6868
static String getDefaultNameFor(Class<? extends ResourceController> controllerClass) {
69-
return getDefaultResourceControllerName(controllerClass.getCanonicalName());
69+
return getDefaultResourceControllerName(controllerClass.getSimpleName());
7070
}
7171

7272
static String getDefaultResourceControllerName(String rcControllerClassName) {
73-
if (rcControllerClassName.indexOf('.') < 0) {
74-
throw new IllegalArgumentException(
75-
"Must provide a fully-qualified resource controller class name, was: "
76-
+ rcControllerClassName);
73+
// if the name is fully qualified, extract the simple class name
74+
final var lastDot = rcControllerClassName.lastIndexOf('.');
75+
if (lastDot > 0) {
76+
rcControllerClassName = rcControllerClassName.substring(lastDot);
7777
}
7878
return rcControllerClassName.toLowerCase(Locale.ROOT);
7979
}

operator-framework-quarkus-extension/deployment/src/main/java/io/javaoperatorsdk/quarkus/extension/deployment/QuarkusExtensionProcessor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ private ControllerConfiguration createControllerConfiguration(
143143
controllerAnnotation,
144144
"name",
145145
AnnotationValue::asString,
146-
() -> ResourceController
147-
.getDefaultResourceControllerName(resourceControllerClassName)),
146+
() ->
147+
ResourceController.getDefaultResourceControllerName(
148+
resourceControllerClassName)),
148149
crdName,
149150
valueOrDefault(
150151
controllerAnnotation,
@@ -163,11 +164,11 @@ private ControllerConfiguration createControllerConfiguration(
163164
controllerAnnotation,
164165
"namespaces",
165166
AnnotationValue::asStringArray,
166-
() -> new String[]{})),
167+
() -> new String[] {})),
167168
crType,
168169
doneableClassName,
169170
null // todo: fix-me
170-
);
171+
);
171172

172173
return configuration;
173174
}

operator-framework-spring-boot-starter/src/test/java/io/javaoperatorsdk/operator/springboot/starter/TestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.stereotype.Component;
1010

1111
@Component
12-
@Controller(crdName = "name", name = "name_must_be_changed")
12+
@Controller(crdName = "name")
1313
public class TestController implements ResourceController {
1414

1515
@Override

operator-framework-spring-boot-starter/src/test/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ javaoperatorsdk:
55
masterUrl: http://master.url
66

77
controllers:
8-
name_must_be_changed:
8+
testcontroller:
99
retry:
1010
maxAttempts: 3
1111
initialInterval: 1000

0 commit comments

Comments
 (0)