forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eclipse-jkube#515: Properties now get resolved in CustomResource…
… fragments CustomResource fragments are now deserialized/serialized into GenericCustomResource so that they are processed with standard kubernetes types
- Loading branch information
1 parent
ff0bbc8
commit 3d20220
Showing
16 changed files
with
910 additions
and
190 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
84 changes: 84 additions & 0 deletions
84
jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/GenericCustomResource.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,84 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.common; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.ObjectMeta; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
// Required if using any of the ObjectMappers provided by KubernetesDeserializer (yamlMapper, jsonMapper) | ||
@JsonDeserialize( | ||
using = JsonDeserializer.None.class | ||
) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class GenericCustomResource implements HasMetadata { | ||
|
||
@JsonProperty("apiVersion") | ||
private String apiVersion; | ||
@JsonProperty("kind") | ||
private String kind; | ||
@JsonProperty("metadata") | ||
private ObjectMeta metadata; | ||
@JsonIgnore | ||
private Map<String, Object> additionalProperties = new HashMap<>(); | ||
|
||
public String getApiVersion() { | ||
return apiVersion; | ||
} | ||
|
||
public void setApiVersion(String apiVersion) { | ||
this.apiVersion = apiVersion; | ||
} | ||
|
||
@Override | ||
public String getKind() { | ||
return kind; | ||
} | ||
|
||
public void setKind(String kind) { | ||
this.kind = kind; | ||
} | ||
|
||
public ObjectMeta getMetadata() { | ||
return metadata; | ||
} | ||
|
||
public void setMetadata(ObjectMeta metadata) { | ||
this.metadata = metadata; | ||
} | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getAdditionalProperties() { | ||
return this.additionalProperties; | ||
} | ||
|
||
public void setAdditionalProperties(Map<String, Object> additionalProperties) { | ||
this.additionalProperties = additionalProperties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setAdditionalProperty(String name, Object value) { | ||
this.additionalProperties.put(name, value); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...e-kit/common/src/main/java/org/eclipse/jkube/kit/common/GenericCustomResourceBuilder.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,43 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.common; | ||
|
||
import io.fabric8.kubernetes.api.builder.BaseFluent; | ||
import io.fabric8.kubernetes.api.builder.VisitableBuilder; | ||
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; | ||
|
||
import java.util.HashMap; | ||
|
||
public class GenericCustomResourceBuilder extends BaseFluent<GenericCustomResourceBuilder> | ||
implements VisitableBuilder<GenericCustomResource, GenericCustomResourceBuilder> { | ||
|
||
private final GenericCustomResource genericCustomResource; | ||
private final ObjectMetaBuilder metadata; | ||
|
||
public GenericCustomResourceBuilder(GenericCustomResource item) { | ||
this.genericCustomResource = new GenericCustomResource(); | ||
this.genericCustomResource.setApiVersion(item.getApiVersion()); | ||
this.genericCustomResource.setKind(item.getKind()); | ||
this.genericCustomResource.setAdditionalProperties(new HashMap<>(item.getAdditionalProperties())); | ||
metadata = item.getMetadata() == null ? new ObjectMetaBuilder() : new ObjectMetaBuilder(item.getMetadata()); | ||
_visitables.get("metadata").add(this.metadata); | ||
} | ||
|
||
@Override | ||
public GenericCustomResource build() { | ||
genericCustomResource.setMetadata(metadata.build()); | ||
return genericCustomResource; | ||
} | ||
|
||
} |
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
Oops, something went wrong.