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

io.quarkiverse.operatorsdk.runtime.devconsole.DependentInfo Maven / Gradle / Ivy

The newest version!
package io.quarkiverse.operatorsdk.runtime.devconsole;

import java.util.Set;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.api.config.dependent.DependentResourceSpec;
import io.javaoperatorsdk.operator.processing.dependent.workflow.Condition;
import io.quarkus.arc.Arc;

@SuppressWarnings({ "unused", "rawtypes" })
public class DependentInfo implements Comparable {
    private final DependentResourceSpec spec;

    public DependentInfo(DependentResourceSpec spec) {
        this.spec = spec;
    }

    public String getResourceClass() {
        try (final var dependent = Arc.container().instance(spec.getDependentResourceClass())) {
            return dependent.get().resourceType().getName();
        }
    }

    public String getName() {
        return spec.getName();
    }

    public Set getDependsOn() {
        return spec.getDependsOn();
    }

    public boolean getHasConditions() {
        return getReadyCondition() != null || getReconcileCondition() != null || getDeletePostCondition() != null;
    }

    public String getReadyCondition() {
        return getConditionClassName(spec.getReadyCondition());
    }

    public String getReconcileCondition() {
        return getConditionClassName(spec.getReconcileCondition());
    }

    public String getDeletePostCondition() {
        return getConditionClassName(spec.getDeletePostCondition());
    }

    private String getConditionClassName(Condition condition) {
        return condition != null ? condition.getClass().getName() : null;
    }

    public String getUseEventSourceWithName() {
        return spec.getUseEventSourceWithName().orElse(null);
    }

    public String getType() {
        return spec.getDependentResourceClass().getName();
    }

    @Override
    public int compareTo(DependentInfo other) {
        return getName().compareTo(other.getName());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy