Repository navigation
Added field to the RealmImport spec to replace environment variables within the realm import #31232
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
762dd33
Added field to the RealmImport spec to replace environment variables …
stustison 4b4e484
Added field to the RealmImport spec to replace environment variables …
stustison f6e4e72
testing refinement for placeholder handling
shawkins 4f6de79
changing from placeholdersecret to placeholder
shawkins 6af6cab
Update docs/guides/operator/realm-import.adoc
shawkins 578e0b4
Update docs/documentation/release_notes/topics/26_0_0.adoc
shawkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
8000
|
@@ -94,4 +94,28 @@ CONDITION: HasErrors | |
| MESSAGE: | ||
| ---- | ||
|
|
||
| === Placeholders | ||
|
|
||
| Imports support placeholders referencing environment variables, see <@links.server id="importExport"/> for more. | ||
| The `KeycloakRealmImport` CR allows you to leverage this functionality via the `spec.placeholders` stanza, for example: | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
| apiVersion: k8s.keycloak.org/v2alpha1 | ||
| kind: KeycloakRealmImport | ||
| metadata: | ||
| name: my-realm-kc | ||
| spec: | ||
| keycloakCRName: <name of the keycloak CR> | ||
| placeholders: | ||
| ENV_KEY: | ||
| secret: | ||
| name: SECRET_NAME | ||
| key: SECRET_KEY | ||
| ... | ||
| ---- | ||
|
|
||
| In the above example placeholder replacement will be enabled and an environment variable with key `ENV_KEY` will be created from the Secret `SECRET_NAME`'s value for key `SECRET_KEY`. | ||
| Currently only Secrets are supported and they must be in the same namespace as the Keycloak CR. | ||
|
|
||
| </@tmpl.guide> | ||
This file contains hidden or 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
8000
18 changes: 18 additions & 0 deletions
18
...rc/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/KeycloakRealmImportSpec.java
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
operator/src/main/java/org/keycloak/operator/crds/v2alpha1/realmimport/Placeholder.java
This file contains hidden or 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,61 @@ | ||
| /* | ||
| * Copyright 2022 Red Hat, Inc. and/or its affiliates | ||
| * and other contributors as indicated by the @author tags. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.keycloak.operator.crds.v2alpha1.realmimport; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import io.fabric8.kubernetes.api.model.SecretKeySelector; | ||
| import io.sundr.builder.annotations.Buildable; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * @author Scott Tustison | ||
| */ | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| @Buildable(editableEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder") | ||
| public class Placeholder { | ||
| private SecretKeySelector secret; | ||
|
|
||
| public Placeholder() { | ||
| } | ||
|
|
||
| public Placeholder(SecretKeySelector secret) { | ||
| this.secret = secret; | ||
| } | ||
|
|
||
| public SecretKeySelector getSecret() { | ||
| return secret; | ||
| } | ||
|
|
||
| public void setSecret(SecretKeySelector secret) { | ||
| this.secret = secret; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| Placeholder that = (Placeholder) o; | ||
| return getSecret().equals(that.getSecret()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(getSecret()); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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,14 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: keycloak-smtp-secret | ||
| stringData: | ||
| SMTP_PORT: "1234" | ||
| SMTP_SERVER: "example.com" | ||
| SMTP_FROM: "example@example.com" | ||
| SMTP_REPLY: "example@example.com" | ||
| SMTP_USE_TLS: "true" | ||
| SMTP_USERNAME: "example" | ||
| SMTP_PASSWORD: "example" | ||
| SMTP_AUTH: "true" | ||
| type: Opaque |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.