import { ConfigError } from "@distilled.cloud/core/errors";
import * as EffectConfig from "effect/Config";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Redacted from "effect/Redacted";
export class Credentials extends Context.Service()("KubernetesCredentials") {
}
const envConfig = EffectConfig.all({
    token: EffectConfig.string("KUBERNETES_TOKEN"),
    apiBaseUrl: EffectConfig.string("KUBERNETES_API_URL"),
});
/**
 * Build a credentials layer from environment variables.
 *
 * | Variable | Required | Description |
 * |---|---|---|
 * | `KUBERNETES_TOKEN` | yes | Bearer token for authentication |
 * | `KUBERNETES_API_URL` | yes | API server URL (e.g. from `kubectl cluster-info`) |
 */
export const CredentialsFromEnv = Layer.succeed(Credentials, envConfig.pipe(Effect.mapError(() => new ConfigError({
    message: "KUBERNETES_TOKEN and KUBERNETES_API_URL environment variables are required. " +
        "Set KUBERNETES_TOKEN to a bearer token for your Kubernetes cluster, " +
        "and KUBERNETES_API_URL to the API server URL (e.g. from `kubectl cluster-info` " +
        "or the EKS cluster endpoint).",
})), Effect.map(({ token, apiBaseUrl }) => ({
    token: Redacted.make(token),
    apiBaseUrl,
})), Effect.orDie));
//# sourceMappingURL=credentials.js.map