fix: download command now requires only keyvault URL.

This commit is contained in:
2026-05-21 23:59:10 +02:00
parent 576a5f959b
commit e2800819ce
3 changed files with 9 additions and 14 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "azure-acme-provisioner", "name": "azure-acme-provisioner",
"version": "0.3.0", "version": "0.3.1",
"author": { "author": {
"name": "Sławomir Koszewski", "name": "Sławomir Koszewski",
"url": "https://github.com/skoszewski" "url": "https://github.com/skoszewski"
+6 -13
View File
@@ -2,7 +2,7 @@ export interface Config {
keyVaultUrl?: string; keyVaultUrl?: string;
acmeDirectoryUrl: string; acmeDirectoryUrl: string;
acmeContactEmail?: string; acmeContactEmail?: string;
subscriptionId: string; subscriptionId?: string;
resourceGroups: string[]; resourceGroups: string[];
dnsZones?: string[]; dnsZones?: string[];
renewalThresholdDays: number; renewalThresholdDays: number;
@@ -19,12 +19,6 @@ export class ConfigError extends Error {
} }
} }
function requireEnv(name: string): string {
const value = process.env[name];
if (!value) throw new ConfigError(`Missing required environment variable: ${name}`);
return value;
}
function optionalEnv(name: string, defaultValue: string): string { function optionalEnv(name: string, defaultValue: string): string {
return process.env[name] ?? defaultValue; return process.env[name] ?? defaultValue;
} }
@@ -38,11 +32,10 @@ function optionalEnvInt(name: string, defaultValue: number): number {
} }
export function loadConfig(): Config { export function loadConfig(): Config {
const resourceGroupsRaw = requireEnv('ACME_RESOURCE_GROUPS'); const resourceGroupsRaw = process.env['ACME_RESOURCE_GROUPS'];
const resourceGroups = resourceGroupsRaw.split(',').map(s => s.trim()).filter(Boolean); const resourceGroups = resourceGroupsRaw
if (resourceGroups.length === 0) { ? resourceGroupsRaw.split(',').map(s => s.trim()).filter(Boolean)
throw new ConfigError('ACME_RESOURCE_GROUPS must contain at least one resource group'); : [];
}
const dnsZonesRaw = process.env['ACME_DNS_ZONES']; const dnsZonesRaw = process.env['ACME_DNS_ZONES'];
const dnsZones = dnsZonesRaw const dnsZones = dnsZonesRaw
@@ -61,7 +54,7 @@ export function loadConfig(): Config {
'https://acme-v02.api.letsencrypt.org/directory' 'https://acme-v02.api.letsencrypt.org/directory'
), ),
acmeContactEmail: process.env['ACME_CONTACT_EMAIL'], acmeContactEmail: process.env['ACME_CONTACT_EMAIL'],
subscriptionId: requireEnv('ACME_SUBSCRIPTION_ID'), subscriptionId: process.env['ACME_SUBSCRIPTION_ID'],
resourceGroups, resourceGroups,
dnsZones, dnsZones,
renewalThresholdDays: optionalEnvInt('ACME_RENEWAL_THRESHOLD_DAYS', 30), renewalThresholdDays: optionalEnvInt('ACME_RENEWAL_THRESHOLD_DAYS', 30),
+2
View File
@@ -15,6 +15,7 @@ export async function scanDnsZones(
credential: TokenCredential, credential: TokenCredential,
config: Config config: Config
): Promise<DomainRecord[]> { ): Promise<DomainRecord[]> {
if (!config.subscriptionId) throw new Error('ACME_SUBSCRIPTION_ID is required for DNS zone scanning');
const client = new DnsManagementClient(credential, config.subscriptionId); const client = new DnsManagementClient(credential, config.subscriptionId);
const results: DomainRecord[] = []; const results: DomainRecord[] = [];
const seen = new Set<string>(); const seen = new Set<string>();
@@ -73,6 +74,7 @@ export class DnsChallengeManager implements ChallengeHandler {
private readonly config: Config, private readonly config: Config,
private readonly log: (msg: string) => void private readonly log: (msg: string) => void
) { ) {
if (!config.subscriptionId) throw new Error('ACME_SUBSCRIPTION_ID is required for DNS challenges');
this.client = new DnsManagementClient(credential, config.subscriptionId); this.client = new DnsManagementClient(credential, config.subscriptionId);
} }