templates.ConfigMapDependentResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bootstrapper Show documentation
Show all versions of bootstrapper Show documentation
Operator SDK - Bootstrapper Maven Plugin
The newest version!
package {{groupId}};
import java.util.HashMap;
import java.util.Map;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;
import {{groupId}}.{{artifactClassId}}CustomResource;
@KubernetesDependent
public class ConfigMapDependentResource
extends CRUDKubernetesDependentResource {
public static final String KEY = "key";
public ConfigMapDependentResource() {
super(ConfigMap.class);
}
@Override
protected ConfigMap desired({{artifactClassId}}CustomResource primary,
Context<{{artifactClassId}}CustomResource> context) {
return new ConfigMapBuilder()
.withMetadata(
new ObjectMetaBuilder()
.withName(primary.getMetadata().getName())
.withNamespace(primary.getMetadata().getNamespace())
.build())
.withData(Map.of(KEY, primary.getSpec().getValue()))
.build();
}
}