-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): New "features" section of the app spec to allow enabl…
…ing deletes (#5898) * New "features" section of the app spec to allow enabling delete functionality * Class rename and regenerated the install.yaml * Removed examle file (accidentally added).
- Loading branch information
1 parent
f2bab39
commit 58606dd
Showing
7 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
controller/src/main/deploy/crd/apicurioregistries3.registry.apicur.io-v1.yml | ||
install/apicurio-registry-operator-*-SNAPSHOT.yaml | ||
.*.sh | ||
.*.yaml | ||
.*.yml |
13 changes: 13 additions & 0 deletions
13
operator/controller/src/main/java/io/apicurio/registry/operator/EnvironmentVariables.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.apicurio.registry.operator; | ||
|
||
public class EnvironmentVariables { | ||
|
||
public static final String QUARKUS_PROFILE = "QUARKUS_PROFILE"; | ||
public static final String QUARKUS_HTTP_ACCESS_LOG_ENABLED = "QUARKUS_HTTP_ACCESS_LOG_ENABLED"; | ||
public static final String QUARKUS_HTTP_CORS_ORIGINS = "QUARKUS_HTTP_CORS_ORIGINS"; | ||
|
||
public static final String APICURIO_REST_DELETION_ARTIFACT_VERSION_ENABLED = "APICURIO_REST_DELETION_ARTIFACT-VERSION_ENABLED"; | ||
public static final String APICURIO_REST_DELETION_ARTIFACT_ENABLED = "APICURIO_REST_DELETION_ARTIFACT_ENABLED"; | ||
public static final String APICURIO_REST_DELETION_GROUP_ENABLED = "APICURIO_REST_DELETION_GROUP_ENABLED"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
operator/controller/src/test/java/io/apicurio/registry/operator/it/AppFeaturesITTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.apicurio.registry.operator.it; | ||
|
||
import io.apicurio.registry.operator.EnvironmentVariables; | ||
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3; | ||
import io.apicurio.registry.operator.api.v1.spec.AppFeaturesSpec; | ||
import io.apicurio.registry.operator.resource.ResourceFactory; | ||
import io.fabric8.kubernetes.api.model.EnvVar; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static io.apicurio.registry.operator.api.v1.ContainerNames.REGISTRY_APP_CONTAINER_NAME; | ||
import static io.apicurio.registry.operator.resource.app.AppDeploymentResource.getContainerFromDeployment; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@QuarkusTest | ||
public class AppFeaturesITTest extends ITBase { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(AppFeaturesITTest.class); | ||
|
||
@Test | ||
void testAllowDeletesTrue() { | ||
ApicurioRegistry3 registry = ResourceFactory | ||
.deserialize("/k8s/examples/simple.apicurioregistry3.yaml", ApicurioRegistry3.class); | ||
// Set Allow deletes = true | ||
registry.getSpec().getApp().setFeatures(AppFeaturesSpec.builder().allowDeletes(true).build()); | ||
client.resource(registry).create(); | ||
|
||
// Wait for the deployment to exist | ||
checkDeploymentExists(registry, ResourceFactory.COMPONENT_APP, 1); | ||
|
||
// Check that the three deletion ENV vars are set | ||
var appEnv = getContainerFromDeployment( | ||
client.apps().deployments().inNamespace(namespace) | ||
.withName(registry.getMetadata().getName() + "-app-deployment").get(), | ||
REGISTRY_APP_CONTAINER_NAME).getEnv(); | ||
assertThat(appEnv).map(EnvVar::getName).contains( | ||
EnvironmentVariables.APICURIO_REST_DELETION_ARTIFACT_ENABLED, | ||
EnvironmentVariables.APICURIO_REST_DELETION_ARTIFACT_VERSION_ENABLED, | ||
EnvironmentVariables.APICURIO_REST_DELETION_GROUP_ENABLED); | ||
} | ||
|
||
@Test | ||
void testAllowDeletesDefault() { | ||
ApicurioRegistry3 registry = ResourceFactory | ||
.deserialize("/k8s/examples/simple.apicurioregistry3.yaml", ApicurioRegistry3.class); | ||
client.resource(registry).create(); | ||
|
||
// Wait for the deployment to exist | ||
checkDeploymentExists(registry, ResourceFactory.COMPONENT_APP, 1); | ||
|
||
// Check that the three deletion ENV vars are NOT set | ||
var appEnv = getContainerFromDeployment( | ||
client.apps().deployments().inNamespace(namespace) | ||
.withName(registry.getMetadata().getName() + "-app-deployment").get(), | ||
REGISTRY_APP_CONTAINER_NAME).getEnv(); | ||
assertThat(appEnv).map(EnvVar::getName).doesNotContain( | ||
EnvironmentVariables.APICURIO_REST_DELETION_ARTIFACT_ENABLED, | ||
EnvironmentVariables.APICURIO_REST_DELETION_ARTIFACT_VERSION_ENABLED, | ||
EnvironmentVariables.APICURIO_REST_DELETION_GROUP_ENABLED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/AppFeaturesSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.apicurio.registry.operator.api.v1.spec; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.annotation.JsonSetter; | ||
import com.fasterxml.jackson.annotation.Nulls; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@JsonDeserialize(using = JsonDeserializer.None.class) | ||
@JsonInclude(NON_NULL) | ||
@JsonPropertyOrder({ "allowDeletes" }) | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = PRIVATE) | ||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@Setter | ||
@EqualsAndHashCode | ||
@ToString | ||
public class AppFeaturesSpec { | ||
|
||
@JsonProperty("allowDeletes") | ||
@JsonPropertyDescription(""" | ||
Apicurio Registry backend 'allow deletes' feature. | ||
If the value is true, the application will be configured to allow Groups, Artifacts, and | ||
Artifact Versions to be deleted. By default, resources in Registry are immutable and so | ||
cannot be deleted. Registry can be configured to allow deleting of these resources at a | ||
granular level (e.g. only allow deleting artifact versions) using ENV variables. This | ||
option enables deletes for all three resource types.""") | ||
@JsonSetter(nulls = Nulls.SKIP) | ||
private Boolean allowDeletes; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters