package com.cameleer.server.core.runtime;

/**
 * Supported deployment strategies. Persisted as a kebab-case string on
 * ApplicationConfig / ResolvedContainerConfig; {@link #fromWire(String)} is
 * the only conversion entry point and falls back to {@link #BLUE_GREEN} for
 * unknown or null input so the executor never has to null-check.
 */
public enum DeploymentStrategy {
    BLUE_GREEN("blue-green"),
    ROLLING("rolling");

    private final String wire;

    DeploymentStrategy(String wire) {
        this.wire = wire;
    }

    public String toWire() {
        return wire;
    }

    public static DeploymentStrategy fromWire(String value) {
        if (value == null) return BLUE_GREEN;
        String normalized = value.trim().toLowerCase();
        for (DeploymentStrategy s : values()) {
            if (s.wire.equals(normalized)) return s;
        }
        return BLUE_GREEN;
    }
}
