All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.automatiko.engine.quarkus.operator.ops.ConfigMapOperations Maven / Gradle / Ivy

The newest version!
package io.automatiko.engine.quarkus.operator.ops;

import java.util.Map;
import java.util.Map.Entry;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.KubernetesClient;

@ApplicationScoped
public class ConfigMapOperations {

    @Inject
    KubernetesClient kube;

    public void createConfigMap(CustomResource resource, String name, Map values) {

        ConfigMapBuilder builder = new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata();

        for (Entry entry : values.entrySet()) {
            builder.addToData(entry.getKey(), entry.getValue());
        }

        this.kube.configMaps().inNamespace(resource.getMetadata().getNamespace()).create(builder.build());
    }

    public void createConfigMap(CustomResource resource, String name, String key, String value) {

        ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata().addToData(name, value)
                .build();

        this.kube.configMaps().inNamespace(resource.getMetadata().getNamespace()).create(configMap);
    }

    public void deleteConfigMap(CustomResource resource, String name) {

        ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata()
                .build();

        this.kube.configMaps().inNamespace(resource.getMetadata().getNamespace()).delete(configMap);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy