Skip to content

Commit fd06b8b

Browse files
authored
Merge pull request #361 from java-operator-sdk/rename-validate
refactor: validateCustomResources -> checkCRDAndValidateLocalModel
2 parents 564302f + 1a89a3e commit fd06b8b

File tree

9 files changed

+21
-20
lines changed

9 files changed

+21
-20
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public <R extends CustomResource> void register(
101101

102102
// check that the custom resource is known by the cluster if configured that way
103103
final CustomResourceDefinition crd;
104-
if (configurationService.validateCustomResources()) {
104+
if (configurationService.checkCRDAndValidateLocalModel()) {
105105
final var crdName = configuration.getCRDName();
106106
crd = k8sClient.apiextensions().v1().customResourceDefinitions().withName(crdName).get();
107107
if (crd == null) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ default Config getClientConfiguration() {
5252
*
5353
* @return {@code true} if CRDs should be checked (default), {@code false} otherwise
5454
*/
55-
default boolean validateCustomResources() {
55+
default boolean checkCRDAndValidateLocalModel() {
5656
return true;
5757
}
5858
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class Utils {
1313

1414
private static final Logger log = LoggerFactory.getLogger(Utils.class);
15-
public static final String VALIDATE_CR_ENV_KEY = "JAVA_OPERATOR_SDK_VALIDATE_CR";
15+
public static final String CHECK_CRD_ENV_KEY = "JAVA_OPERATOR_SDK_CHECK_CRD";
1616

1717
/**
1818
* Attempts to load version information from a properties file produced at build time, currently
@@ -51,11 +51,11 @@ public static Version loadFromProperties() {
5151
}
5252

5353
public static boolean isValidateCustomResourcesEnvVarSet() {
54-
return System.getProperty(VALIDATE_CR_ENV_KEY) != null;
54+
return System.getProperty(CHECK_CRD_ENV_KEY) != null;
5555
}
5656

57-
public static boolean shouldValidateCustomResources() {
58-
final var value = System.getProperty(VALIDATE_CR_ENV_KEY);
57+
public static boolean shouldCheckCRDAndValidateLocalModel() {
58+
final var value = System.getProperty(CHECK_CRD_ENV_KEY);
5959
return value == null || Boolean.getBoolean(value);
6060
}
6161
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void createConfigurationServiceAndOperator(
8383
final var version = Utils.loadFromProperties();
8484
final var validateCustomResources =
8585
Utils.isValidateCustomResourcesEnvVarSet()
86-
? Utils.shouldValidateCustomResources()
87-
: externalConfiguration.validateCustomResources.orElse(true);
86+
? Utils.shouldCheckCRDAndValidateLocalModel()
87+
: externalConfiguration.checkCRDAndValidateLocalModel.orElse(true);
8888

8989
final var supplier =
9090
recorder.configurationServiceSupplier(

operator-framework-quarkus-extension/runtime/src/main/java/io/javaoperatorsdk/quarkus/extension/ExternalConfiguration.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ public class ExternalConfiguration {
1414
@ConfigItem public Map<String, ExternalControllerConfiguration> controllers;
1515

1616
/**
17-
* Whether the operator should validate the {@link CustomResource} implementation before
18-
* registering the associated controller.
17+
* Whether the operator should check that the CRD is properly deployed and that the associated
18+
* {@link CustomResource} implementation matches its information before registering the associated
19+
* controller.
1920
*/
2021
@ConfigItem(defaultValue = "true")
21-
public Optional<Boolean> validateCustomResources;
22+
public Optional<Boolean> checkCRDAndValidateLocalModel;
2223
}

operator-framework-quarkus-extension/runtime/src/main/java/io/javaoperatorsdk/quarkus/extension/QuarkusConfigurationService.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
public class QuarkusConfigurationService extends AbstractConfigurationService {
1414
private static final ClientProxyUnwrapper unwrapper = new ClientProxyUnwrapper();
1515
private final KubernetesClient client;
16-
private final boolean validateCustomResources;
16+
private final boolean checkCRDAndValidateLocalModel;
1717

1818
public QuarkusConfigurationService(
1919
Version version,
2020
List<ControllerConfiguration> configurations,
2121
KubernetesClient client,
22-
boolean validateCustomResources) {
22+
boolean checkCRDAndValidateLocalModel) {
2323
super(version);
2424
this.client = client;
2525
if (configurations != null && !configurations.isEmpty()) {
2626
configurations.forEach(this::register);
2727
}
28-
this.validateCustomResources = validateCustomResources;
28+
this.checkCRDAndValidateLocalModel = checkCRDAndValidateLocalModel;
2929
}
3030

3131
@Override
@@ -41,8 +41,8 @@ public <R extends CustomResource> ControllerConfiguration<R> getConfigurationFor
4141
}
4242

4343
@Override
44-
public boolean validateCustomResources() {
45-
return validateCustomResources;
44+
public boolean checkCRDAndValidateLocalModel() {
45+
return checkCRDAndValidateLocalModel;
4646
}
4747

4848
private static <R extends CustomResource> ResourceController<R> unwrap(

operator-framework-quarkus-extension/tests/src/main/java/io/javaoperatorsdk/quarkus/it/TestOperatorApp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TestOperatorApp {
2121
@GET
2222
@Path("validateCR")
2323
public boolean validateCR() {
24-
return configurationService.validateCustomResources();
24+
return configurationService.checkCRDAndValidateLocalModel();
2525
}
2626

2727
@GET
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
quarkus.operator-sdk.controllers.annotation.finalizer=from-property/finalizer
22
quarkus.operator-sdk.controllers.annotation.namespaces=bar
3-
quarkus.operator-sdk.validate-custom-resources=false
3+
quarkus.operator-sdk.check-crd-and-validate-local-model=false

operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/DefaultConfigurationService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public <R extends CustomResource> ControllerConfiguration<R> getConfigurationFor
3838
}
3939

4040
@Override
41-
public boolean validateCustomResources() {
42-
return Utils.shouldValidateCustomResources();
41+
public boolean checkCRDAndValidateLocalModel() {
42+
return Utils.shouldCheckCRDAndValidateLocalModel();
4343
}
4444
}

0 commit comments

Comments
 (0)