Skip to content

Commit 85475e3

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

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
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-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)