Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove deprecated code and clean-ups #1020

Merged
merged 14 commits into from
Jan 10, 2025
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 @@ -19,7 +19,7 @@
enum RoleKind {

ClusterRole,
Role;
Role

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static HashSet<String> addCRDManifestBuilder(Map<String, CRDInfo> crds,

private static SortedMap<String, String> generateBundleLabels(CSVMetadataHolder csvMetadata,
BundleGenerationConfiguration bundleConfiguration, Version version) {
var packageName = bundleConfiguration.packageName().orElse(csvMetadata.bundleName);
var packageName = csvMetadata.bundleName;

SortedMap<String, String> values = new TreeMap<>();
values.put(join(BUNDLE_PREFIX, CHANNEL, DEFAULT, ANNOTATIONS_VERSION),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ CSVMetadataBuildItem gatherCSVMetadata(KubernetesConfig kubernetesConfig,
CombinedIndexBuildItem combinedIndexBuildItem,
JarBuildItem jarBuildItem) {
final var index = combinedIndexBuildItem.getIndex();
final var defaultName = bundleConfiguration.packageName()
.orElse(ResourceNameUtil.getResourceName(kubernetesConfig, appConfiguration));
final var defaultName = ResourceNameUtil.getResourceName(kubernetesConfig, appConfiguration);

// note that version, replaces, etc. should probably be settable at the reconciler level
// use version specified in bundle configuration, if not use the one extracted from the project, if available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,6 @@ private void appendRulesInPermission(StrategyDeploymentPermissionsFluent permiss
}

private static String defaultIfEmpty(String possiblyNullOrEmpty, String defaultValue) {
return Optional.ofNullable(possiblyNullOrEmpty).filter(s -> !s.isBlank() && !s.isEmpty()).orElse(defaultValue);
return Optional.ofNullable(possiblyNullOrEmpty).filter(s -> !s.isBlank()).orElse(defaultValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.file.Path;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
Expand All @@ -26,8 +27,9 @@ public abstract class ManifestsBuilder {
.enable(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS)
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
YAML_MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
YAML_MAPPER.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
YAML_MAPPER.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
YAML_MAPPER.setDefaultPropertyInclusion(
JsonInclude.Value.construct(JsonInclude.Include.ALWAYS, JsonInclude.Include.NON_NULL));
YAML_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
}

protected final CSVMetadataHolder metadata;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkiverse.operatorsdk.bundle;

import static io.quarkiverse.operatorsdk.bundle.Utils.*;
import static io.quarkiverse.operatorsdk.bundle.Utils.getCRDNameFor;
import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
public class MultipleOperatorsBundleTest {

private static final String VERSION = "test-version";
private static final String BUNDLE_PACKAGE = "olm-package";
private static final String OVERRIDEN_REPO_ANNOTATION = "overridden-repo-annotation";
private static final String DEFAULT_ANNOTATION_NAME = "default-annotation-name";
private static final String DEFAULT_ANNOTATION_VALUE = "default-annotation-value";
Expand All @@ -41,7 +40,6 @@ public class MultipleOperatorsBundleTest {
ExternalDependentResource.class, PodDependentResource.class))
.overrideConfigKey("quarkus.operator-sdk.crd.generate-all", "true")
.overrideConfigKey("quarkus.operator-sdk.bundle.replaces", FirstReconciler.REPLACES)
.overrideConfigKey("quarkus.operator-sdk.bundle.package-name", BUNDLE_PACKAGE)
.overrideConfigKey("quarkus.operator-sdk.bundle.bundles." + ThirdReconciler.BUNDLE_NAME + ".annotations."
+ BundleConfiguration.REPOSITORY_ANNOTATION, OVERRIDEN_REPO_ANNOTATION)
.overrideConfigKey(
Expand Down Expand Up @@ -71,7 +69,7 @@ public void shouldWriteBundleForTheOperators() throws IOException {
assertEquals(FirstReconciler.VERSION, csv.getSpec().getVersion());
assertEquals(FirstReconciler.REPLACES, csv.getSpec().getReplaces());
var bundleMeta = getAnnotationsFor(bundle, "first-operator");
assertEquals(BUNDLE_PACKAGE, bundleMeta.getAnnotations().get("operators.operatorframework.io.bundle.package.v1"));
assertEquals("first-operator", bundleMeta.getAnnotations().get("operators.operatorframework.io.bundle.package.v1"));

checkBundleFor(bundle, "second-operator", Second.class);
csv = getCSVFor(bundle, "second-operator");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Map;
import java.util.Optional;

import io.quarkiverse.operatorsdk.annotations.CSVMetadata;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
Expand All @@ -31,14 +30,6 @@ public interface BundleGenerationConfiguration {
*/
Optional<String> defaultChannel();

/**
* The name of the package that bundle belongs to.
*
* @deprecated Use {@link CSVMetadata#bundleName()} instead
*/
@Deprecated(forRemoval = true)
Optional<String> packageName();

/**
* The replaces value that should be used in the generated CSV.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkiverse.operatorsdk.bundle.runtime;

import static io.quarkiverse.operatorsdk.bundle.runtime.BundleConfiguration.*;
import static io.quarkiverse.operatorsdk.bundle.runtime.BundleConfiguration.CONTAINER_IMAGE_ANNOTATION;

import java.util.Collections;
import java.util.HashMap;
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

<properties>
<maven.compiler.parameters>true</maven.compiler.parameters>
<quarkus.package.type>uber-jar</quarkus.package.type>
<quarkus.package.jar.enabled>true</quarkus.package.jar.enabled>
<quarkus.package.jar.type>uber-jar</quarkus.package.jar.type>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private Files() {
public interface MessageWriter {
default void write(String message) {
write(message, null, false);
};
}

default void error(String message) {
error(message, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration;
import io.quarkiverse.operatorsdk.runtime.ConfigurationServiceRecorder;
import io.quarkiverse.operatorsdk.runtime.KubernetesClientObjectMapperCustomizer;
import io.quarkiverse.operatorsdk.runtime.KubernetesClientSerializationCustomizer;
import io.quarkiverse.operatorsdk.runtime.NoOpMetricsProvider;
import io.quarkiverse.operatorsdk.runtime.OperatorHealthCheck;
import io.quarkiverse.operatorsdk.runtime.OperatorProducer;
Expand Down Expand Up @@ -90,9 +89,6 @@ void setup(BuildProducer<IndexDependencyBuildItem> indexDependency,
// register our Kubernetes client mapper customizer
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(KubernetesClientObjectMapperCustomizer.class));

// register CDI qualifier for customization of the fabric8 ObjectMapper
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(KubernetesClientSerializationCustomizer.class));

// register CDI Operator producer
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(OperatorProducer.class));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void checkVersionCompatibility(BuildTimeOperatorConfiguration buildTimeC

private static Optional<Semver> getSemverFrom(String version) {
try {
return Optional.of(Semver.coerce(version));
return Optional.ofNullable(Semver.coerce(version));
} catch (Exception e) {
log.warn("Couldn't convert version " + version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.quarkiverse.operatorsdk.runtime.KubernetesClientSerializationCustomizer;
import io.quarkiverse.operatorsdk.runtime.QuarkusConfigurationService;
import io.quarkiverse.operatorsdk.test.sources.SimpleCR;
import io.quarkiverse.operatorsdk.test.sources.SimpleSpec;
import io.quarkiverse.operatorsdk.test.sources.SimpleStatus;
import io.quarkus.jackson.ObjectMapperCustomizer;
import io.quarkus.kubernetes.client.KubernetesClientObjectMapperCustomizer;
import io.quarkus.test.QuarkusUnitTest;

Expand All @@ -33,38 +31,27 @@ public void kubernetesClientUsesCustomizedObjectMapper() {
assertEquals(service.getKubernetesClient(), kubernetesClient);
var serialization = kubernetesClient.getKubernetesSerialization();
var result = serialization
.unmarshal("{\"spec\": {\"mixin\": \"fromMixin\"},\"status\":{\"mixin\": \"fromMixin\"}}", SimpleCR.class);
assertEquals("fromMixin", result.getSpec().value);
.unmarshal("{\"status\":{\"mixin\": \"fromMixin\"}}", SimpleCR.class);
assertEquals("fromMixin", result.getStatus().value);

serialization = service.getKubernetesClient().getKubernetesSerialization();
result = serialization
.unmarshal("{\"spec\": {\"mixin\": \"fromMixin\"},\"status\":{\"mixin\": \"fromMixin\"}}", SimpleCR.class);
assertEquals("fromMixin", result.getSpec().value);
.unmarshal("{\"status\":{\"mixin\": \"fromMixin\"}}", SimpleCR.class);
assertEquals("fromMixin", result.getStatus().value);
}

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot(jar -> jar.addClasses(Customizer.class, Customizer2.class, ValueMixIn.class, SimpleCR.class,
.withApplicationRoot(jar -> jar.addClasses(Customizer.class, ValueMixIn.class, SimpleCR.class,
SimpleSpec.class, SimpleStatus.class));

@Singleton
@KubernetesClientSerializationCustomizer
public static class Customizer implements ObjectMapperCustomizer {
@Override
public void customize(ObjectMapper objectMapper) {
objectMapper.addMixIn(SimpleSpec.class, ValueMixIn.class);
}
}

private static final class ValueMixIn {
@JsonProperty("mixin")
String value;
}

@Singleton
public static class Customizer2 implements KubernetesClientObjectMapperCustomizer {
public static class Customizer implements KubernetesClientObjectMapperCustomizer {
public void customize(ObjectMapper objectMapper) {
objectMapper.addMixIn(SimpleStatus.class, ValueMixIn.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.rbac.ClusterRole;
import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.client.utils.KubernetesSerialization;
import io.quarkiverse.operatorsdk.deployment.AddClusterRolesDecorator;
import io.quarkiverse.operatorsdk.deployment.AddRoleBindingsDecorator;
import io.quarkiverse.operatorsdk.test.sources.WatchAllReconciler;
Expand All @@ -36,6 +36,7 @@ public class WatchAllNamespacesTest {

@ProdBuildResults
private ProdModeTestResults prodModeTestResults;
private static final KubernetesSerialization serialization = new KubernetesSerialization();

@Test
public void shouldCreateRolesAndRoleBindings() throws IOException {
Expand All @@ -45,7 +46,7 @@ public void shouldCreateRolesAndRoleBindings() throws IOException {
final var kubeIS = new FileInputStream(kubeManifest.toFile());
// use unmarshall version with parameters map to ensure code goes through the proper processing wrt multiple documents
@SuppressWarnings("unchecked")
final var kubeResources = (List<HasMetadata>) Serialization.unmarshal(kubeIS);
final var kubeResources = (List<HasMetadata>) serialization.unmarshal(kubeIS);

// check cluster role
final var clusterRoleName = AddClusterRolesDecorator.getClusterRoleName(WatchAllReconciler.NAME);
Expand Down
Loading
Loading