Skip to content
Open
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
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ subprojects {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")

// Source code: A category that an Error Prone check already owns is deliberately absent
options.compilerArgs.add("-Xlint:deprecation,removal,unchecked,cast,rawtypes,divzero,this-escape,identity,text-blocks,dangling-doc-comments,restricted")
// The build itself: command-line options, path entries, output file collisions
options.compilerArgs.add("-Xlint:options,path,output-file-clash")

options.errorprone {
// The checks live in errorprone.args, see https://github.com/tbroyer/gradle-errorprone-plugin#argument-files
argumentFiles.from(rootProject.layout.projectDirectory.file("errorprone.args"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ void setUp() {
resource.setSpec(spec);
resource.setMetadata(metadata);

//noinspection unchecked
context = mock(Context.class);
@SuppressWarnings("unchecked")
Context<ClusterConnection> mockedContext = mock(Context.class);
context = mockedContext;
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ private void createTableWithSerial(
) {
try (var dsl = postgreSQLContextFactory.getDSLContext(clusterConnection, databaseName)) {
dsl.createTable(quotedName(schemaName, tableName))
.column("id", SQLDataType.BIGINT.identity(true))
.column("id", SQLDataType.BIGINT.generatedByDefaultAsIdentity())
.execute();
}
}
Expand Down
27 changes: 15 additions & 12 deletions operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package it.aboutbits.postgresql.helm;

import com.fasterxml.jackson.databind.JsonNode;
import io.fabric8.kubernetes.api.model.ConfigBuilder;
import io.fabric8.kubernetes.api.model.LocalObjectReference;
import io.fabric8.kubernetes.api.model.Volume;
import io.fabric8.kubernetes.api.model.VolumeMount;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.utils.KubernetesSerialization;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.quarkus.test.junit.QuarkusTest;
import io.smallrye.common.process.ProcessBuilder;
Expand Down Expand Up @@ -35,6 +37,7 @@
@NullMarked
class HelmTest {
private static final String ENV_VAR_KUBECONFIG = "KUBECONFIG";
private static final KubernetesSerialization KUBERNETES_SERIALIZATION = new KubernetesSerialization();

/// The Pod and Container list fields that the chart exposes as free-form Helm values.
private static final List<String> LIST_VALUES = List.of(
Expand Down Expand Up @@ -84,21 +87,19 @@ void helmInstall_createsDeployment() throws IOException {
// 1. Verify files exist and contain expected data
// ./Chart.yaml
@SuppressWarnings("unchecked")
Map<String, Object> chartMetadata = Serialization.yamlMapper()
.readValue(
chartPath.resolve("Chart.yaml").toFile(),
Map.class
);
Map<String, Object> chartMetadata = KUBERNETES_SERIALIZATION.unmarshal(
Files.newInputStream(chartPath.resolve("Chart.yaml")),
Map.class
);

assertThat(chartMetadata.get("name")).isEqualTo(chartName);

// ./values.yaml
@SuppressWarnings("unchecked")
Map<String, Object> values = Serialization.yamlMapper()
.readValue(
chartPath.resolve("values.yaml").toFile(),
Map.class
);
Map<String, Object> values = KUBERNETES_SERIALIZATION.unmarshal(
Files.newInputStream(chartPath.resolve("values.yaml")),
Map.class
);

assertThat(values).containsKey(rootValuesAlias);

Expand All @@ -123,8 +124,10 @@ void helmInstall_createsDeployment() throws IOException {
// ./values.schema.json
// The type must be declared for every list value, otherwise the generated schema
// falls back to `string` and `helm install` rejects a list.
var valuesSchema = Serialization.jsonMapper()
.readTree(chartPath.resolve("values.schema.json").toFile());
var valuesSchema = KUBERNETES_SERIALIZATION.unmarshal(
Files.newInputStream(chartPath.resolve("values.schema.json")),
JsonNode.class
);

for (var listValue : LIST_VALUES) {
var schemaProperty = valuesSchema.at("/properties/%s/properties/%s".formatted(
Expand Down