Skip to content

Commit

Permalink
Operator configmap: use KAAP as prefix (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi authored Aug 16, 2023
1 parent 59b807c commit abc5774
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion helm/kaap/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ data:
{{ printf "QUARKUS_%s" ($key | replace "-" "." | replace "\"" "." | snakecase | upper | replace "." "_" ) }}: {{ $val | toString | replace "\"" "" | trim | quote }}
{{- end }}
{{- range $key, $val := $.Values.operator.config.operator }}
{{ printf "PULSAR_OPERATOR_%s" ($key | replace "-" "." | snakecase | upper | replace "." "_" | replace "\"" "_") }}: {{ $val | toString | replace "\"" "" | trim | quote }}
{{ printf "KAAP_%s" ($key | replace "-" "." | snakecase | upper | replace "." "_" | replace "\"" "_") }}: {{ $val | toString | replace "\"" "" | trim | quote }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
@Unremovable
public class LeaderElectionConfig extends LeaderElectionConfiguration {

public static final String PULSAR_OPERATOR_LEASE_NAME = "kaap-lease";
public static final String LEASE_NAME = "kaap-lease";

public LeaderElectionConfig() {
super(PULSAR_OPERATOR_LEASE_NAME);
super(LEASE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
@Slf4j
public abstract class BaseK8sEnvTest {

public static final Path PULSAR_OPERATOR_CHART_PATH = Paths.get("..", "helm", "kaap");
public static final Path OPERATOR_CHART_PATH = Paths.get("..", "helm", "kaap");

public static final String OPERATOR_IMAGE = System.getProperty("kaap.tests.operator.image",
"datastax/kaap:latest-dev");
Expand Down Expand Up @@ -116,7 +116,7 @@ public BaseK8sEnvTest() {
@SneakyThrows
private static List<Path> getCRDsManifests() {
return Files.list(
Paths.get(PULSAR_OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "crds")
Paths.get(OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "crds")
).filter(p -> p.toFile().getName().endsWith(".yml"))
.collect(Collectors.toList());
}
Expand Down Expand Up @@ -179,18 +179,18 @@ public void onClose(WatcherException cause) {
private String getRbacManifest() throws IOException {
List<String> allRbac = new ArrayList<>();
allRbac.addAll(Files.readAllLines(
Paths.get(PULSAR_OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "rbac.yaml")));
Paths.get(OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "rbac.yaml")));
allRbac.add("---");
allRbac.addAll(Files.readAllLines(
Paths.get(PULSAR_OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "serviceaccount.yaml")));
Paths.get(OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "serviceaccount.yaml")));

return simulateHelmRendering(allRbac);
}

private String getOperatorDeploymentManifest() throws IOException {
List<String> manifests = new ArrayList<>();
manifests.addAll(Files.readAllLines(
Paths.get(PULSAR_OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "operator.yaml")));
Paths.get(OPERATOR_CHART_PATH.toFile().getAbsolutePath(), "templates", "operator.yaml")));
manifests.add("---");
manifests.addAll(Arrays.stream("""
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class BaseHelmTest extends BasePulsarClusterTest {
"https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.crds.yaml";

private static final String HELM_RELEASE_PREFIX = "pothr-";
public static final String HELM_BIND_PULSAR_OPERATOR = "/helm-kaap";
public static final String HELM_BIND_PULSAR_STACK = "/helm-kaap-stack";
public static final String HELM_BIND_OPERATOR = "/helm-kaap";
public static final String HELM_BIND_STACK = "/helm-kaap-stack";

protected String helmReleaseName;

Expand All @@ -58,10 +58,10 @@ public void beforeBaseHelmTest() throws Exception {
+ namespace + "-r-" + RandomStringUtils.randomAlphabetic(8).toLowerCase();
cleanupNonNamespaceableResources();
env.withHelmContainer(helm -> {
final Path operatorPath = PULSAR_OPERATOR_CHART_PATH;
final Path operatorPath = OPERATOR_CHART_PATH;
final Path stackPath = Paths.get("..", "helm", "kaap-stack");
helm.withFileSystemBind(operatorPath.toFile().getAbsolutePath(), HELM_BIND_PULSAR_OPERATOR);
helm.withFileSystemBind(stackPath.toFile().getAbsolutePath(), HELM_BIND_PULSAR_STACK);
helm.withFileSystemBind(operatorPath.toFile().getAbsolutePath(), HELM_BIND_OPERATOR);
helm.withFileSystemBind(stackPath.toFile().getAbsolutePath(), HELM_BIND_STACK);
log.info("loaded helm charts from {} and {}", operatorPath, stackPath);
});
}
Expand Down Expand Up @@ -100,9 +100,9 @@ protected void helmInstall(Chart chart, String values) {

private static String getChartPath(Chart chart) {
if (chart == Chart.OPERATOR) {
return HELM_BIND_PULSAR_OPERATOR;
return HELM_BIND_OPERATOR;
} else {
return HELM_BIND_PULSAR_STACK;
return HELM_BIND_STACK;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public void testHelm() throws Exception {
"debug");
Assert.assertEquals(configMap.getData().get("QUARKUS_OPERATOR_SDK_CONTROLLERS__CONTROLLERS__RETRY_INTERVAL_INITIAL"),
"2500");
Assert.assertEquals(configMap.getData().get("PULSAR_OPERATOR_RECONCILIATION_RESCHEDULE_SECONDS"),
Assert.assertEquals(configMap.getData().get("KAAP_RECONCILIATION_RESCHEDULE_SECONDS"),
"3");

final List<Pod> pods = getOperatorPods();
Assert.assertEquals(pods.size(), 2);
Awaitility.await().untilAsserted(() -> {
Assert.assertNotNull(client.leases()
.inNamespace(namespace)
.withName(LeaderElectionConfig.PULSAR_OPERATOR_LEASE_NAME)
.withName(LeaderElectionConfig.LEASE_NAME)
.get());
});

Expand Down

0 comments on commit abc5774

Please sign in to comment.