UNPKG

@deploystack/docker-to-iac

Version:

Translate docker run and docker compose file to Infrastructure as Code

18 lines (17 loc) 722 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveEnvironmentValue = resolveEnvironmentValue; function resolveEnvironmentValue(value, environmentVariables) { // Check if value uses ${VAR:-default} syntax const defaultValueMatch = value.match(/\${([^:-]+):-([^}]+)}/); if (defaultValueMatch) { const [, varName, defaultValue] = defaultValueMatch; // Check if the variable exists in provided environment variables if (environmentVariables && varName in environmentVariables) { return environmentVariables[varName]; } // No environment variable found, use default return defaultValue; } return value; }