-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
CRD generation from RealmRepresentation #9759
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1495dbf
Enabling CRD generation from RealmRepresentation
andreaTP 8487032
move the changes to the operator module
andreaTP 4e9d8c5
cleanup
andreaTP 14dd74e
kubernetes-client version in operator/pom.xml
andreaTP fceaa95
patching keycloak-core with sed
andreaTP 3dc12b9
Merge pull request #3 from andreaTP/sed-patching
andreaTP File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
sedCommand="sed" | ||
if [ "$(uname)" == "Darwin" ]; then | ||
if hash gsed 2>/dev/null; then | ||
sedCommand="gsed" | ||
fi | ||
fi | ||
|
||
function addAnnotation() { | ||
local match=$1 | ||
local annotation=$2 | ||
local file=$3 | ||
|
||
$sedCommand -i "/^.*${match}.*/i ${annotation}" ${file} | ||
} | ||
|
||
addAnnotation \ | ||
"protected List<GroupRepresentation> subGroups;" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.NoSubGroupsGroupRepresentationList.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/GroupRepresentation.java | ||
|
||
addAnnotation \ | ||
"private MultivaluedHashMap<String, ComponentExportRepresentation> components;" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.ComponentExportRepresentationMap.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/RealmRepresentation.java | ||
|
||
addAnnotation \ | ||
"private MultivaluedHashMap<String, String> config;" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/CredentialRepresentation.java | ||
|
||
addAnnotation \ | ||
"private MultivaluedHashMap<String, String> config;" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/ComponentRepresentation.java | ||
|
||
addAnnotation \ | ||
"private MultivaluedHashMap<String, ComponentExportRepresentation> subComponents = new MultivaluedHashMap<>();" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.NoSubcomponentsComponentExportRepresentationMap.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/ComponentExportRepresentation.java | ||
|
||
addAnnotation \ | ||
"private MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();" \ | ||
"@io.fabric8.crd.generator.annotation.SchemaFrom(type = org.keycloak.representations.overrides.MultivaluedStringStringHashMap.class)" \ | ||
target/keycloak-core/org/keycloak/representations/idm/ComponentExportRepresentation.java | ||
|
||
addAnnotation \ | ||
"private List<PolicyRepresentation> policies;" \ | ||
"@com.fasterxml.jackson.annotation.JsonIgnore" \ | ||
target/keycloak-core/org/keycloak/representations/idm/authorization/ScopeRepresentation.java | ||
|
||
addAnnotation \ | ||
"private List<ResourceRepresentation> resources;" \ | ||
"@com.fasterxml.jackson.annotation.JsonIgnore" \ | ||
target/keycloak-core/org/keycloak/representations/idm/authorization/ScopeRepresentation.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
31 changes: 31 additions & 0 deletions
31
operator/src/main/java/org/keycloak/operator/v2alpha1/crds/Realm.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,31 @@ | ||
/* | ||
* Copyright 2021 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.v2alpha1.crds; | ||
|
||
import io.fabric8.kubernetes.api.model.Namespaced; | ||
import io.fabric8.kubernetes.client.CustomResource; | ||
import io.fabric8.kubernetes.model.annotation.Group; | ||
import io.fabric8.kubernetes.model.annotation.Plural; | ||
import io.fabric8.kubernetes.model.annotation.ShortNames; | ||
import io.fabric8.kubernetes.model.annotation.Version; | ||
import org.keycloak.operator.Constants; | ||
|
||
@Group(Constants.CRDS_GROUP) | ||
@Version(Constants.CRDS_VERSION) | ||
public class Realm extends CustomResource<RealmSpec, Void> implements Namespaced { | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
operator/src/main/java/org/keycloak/operator/v2alpha1/crds/RealmSpec.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,46 @@ | ||
/* | ||
* Copyright 2021 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.v2alpha1.crds; | ||
|
||
import org.keycloak.representations.idm.RealmRepresentation; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public class RealmSpec { | ||
|
||
@NotNull | ||
private String keycloakCRName; | ||
@NotNull | ||
private RealmRepresentation realm; | ||
|
||
public String getKeycloakCRName() { | ||
return keycloakCRName; | ||
} | ||
|
||
public void setKeycloakCRName(String keycloakCRName) { | ||
this.keycloakCRName = keycloakCRName; | ||
} | ||
|
||
public RealmRepresentation getRealm() { | ||
return realm; | ||
} | ||
|
||
public void setRealm(RealmRepresentation realm) { | ||
this.realm = realm; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...rc/main/java/org/keycloak/representations/overrides/ComponentExportRepresentationMap.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,25 @@ | ||
/* | ||
* Copyright 2016 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.representations.overrides; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import org.keycloak.representations.idm.ComponentExportRepresentation; | ||
|
||
public class ComponentExportRepresentationMap extends HashMap<String, List<ComponentExportRepresentation>> { | ||
} |
24 changes: 24 additions & 0 deletions
24
.../src/main/java/org/keycloak/representations/overrides/MultivaluedStringStringHashMap.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,24 @@ | ||
/* | ||
* Copyright 2016 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.representations.overrides; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class MultivaluedStringStringHashMap extends HashMap<String, List<String>> { | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding this unused field I would be happy to remove the following accessors, unfortunately, the latter is a breaking change for the import/export functionality.
cc. @stianst @pedroigor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something, but why do you need to remove a simple boolean field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are adding back the field, that remains unused, since it's emitted by the Json serialization.
If we don't add it, you would need to remove all the relevant fields
autheticatorFlow
(WITH the typo) from the exportedRealmRepresentation
before importing it as a CR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stianst this is the only change in the core I'm leaving, as far as I can tell it should be ok, but let me know if I have to duplicate even this file.