Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public <R extends CustomResource> void register(

// check that the custom resource is known by the cluster if configured that way
final CustomResourceDefinition crd;
if (configurationService.validateCustomResources()) {
if (configurationService.checkCRDAndValidateLocalModel()) {
final var crdName = configuration.getCRDName();
crd = k8sClient.apiextensions().v1().customResourceDefinitions().withName(crdName).get();
if (crd == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ default Config getClientConfiguration() {
*
* @return {@code true} if CRDs should be checked (default), {@code false} otherwise
*/
default boolean validateCustomResources() {
default boolean checkCRDAndValidateLocalModel() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class Utils {

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

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

public static boolean isValidateCustomResourcesEnvVarSet() {
return System.getProperty(VALIDATE_CR_ENV_KEY) != null;
return System.getProperty(CHECK_CRD_ENV_KEY) != null;
}

public static boolean shouldValidateCustomResources() {
final var value = System.getProperty(VALIDATE_CR_ENV_KEY);
public static boolean shouldCheckCRDAndValidateLocalModel() {
final var value = System.getProperty(CHECK_CRD_ENV_KEY);
return value == null || Boolean.getBoolean(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void createConfigurationServiceAndOperator(
final var version = Utils.loadFromProperties();
final var validateCustomResources =
Utils.isValidateCustomResourcesEnvVarSet()
? Utils.shouldValidateCustomResources()
: externalConfiguration.validateCustomResources.orElse(true);
? Utils.shouldCheckCRDAndValidateLocalModel()
: externalConfiguration.checkCRDAndValidateLocalModel.orElse(true);

final var supplier =
recorder.configurationServiceSupplier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ public class ExternalConfiguration {
@ConfigItem public Map<String, ExternalControllerConfiguration> controllers;

/**
* Whether the operator should validate the {@link CustomResource} implementation before
* registering the associated controller.
* Whether the operator should check that the CRD is properly deployed and that the associated
* {@link CustomResource} implementation matches its information before registering the associated
* controller.
*/
@ConfigItem(defaultValue = "true")
public Optional<Boolean> validateCustomResources;
public Optional<Boolean> checkCRDAndValidateLocalModel;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
public class QuarkusConfigurationService extends AbstractConfigurationService {
private static final ClientProxyUnwrapper unwrapper = new ClientProxyUnwrapper();
private final KubernetesClient client;
private final boolean validateCustomResources;
private final boolean checkCRDAndValidateLocalModel;

public QuarkusConfigurationService(
Version version,
List<ControllerConfiguration> configurations,
KubernetesClient client,
boolean validateCustomResources) {
boolean checkCRDAndValidateLocalModel) {
super(version);
this.client = client;
if (configurations != null && !configurations.isEmpty()) {
configurations.forEach(this::register);
}
this.validateCustomResources = validateCustomResources;
this.checkCRDAndValidateLocalModel = checkCRDAndValidateLocalModel;
}

@Override
Expand All @@ -41,8 +41,8 @@ public <R extends CustomResource> ControllerConfiguration<R> getConfigurationFor
}

@Override
public boolean validateCustomResources() {
return validateCustomResources;
public boolean checkCRDAndValidateLocalModel() {
return checkCRDAndValidateLocalModel;
}

private static <R extends CustomResource> ResourceController<R> unwrap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TestOperatorApp {
@GET
@Path("validateCR")
public boolean validateCR() {
return configurationService.validateCustomResources();
return configurationService.checkCRDAndValidateLocalModel();
}

@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
quarkus.operator-sdk.controllers.annotation.finalizer=from-property/finalizer
quarkus.operator-sdk.controllers.annotation.namespaces=bar
quarkus.operator-sdk.validate-custom-resources=false
quarkus.operator-sdk.check-crd-and-validate-local-model=false
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public <R extends CustomResource> ControllerConfiguration<R> getConfigurationFor
}

@Override
public boolean validateCustomResources() {
return Utils.shouldValidateCustomResources();
public boolean checkCRDAndValidateLocalModel() {
return Utils.shouldCheckCRDAndValidateLocalModel();
}
}