Always ensure configuration values are managed consistently and sourced from stable locations. 1. Use defined constants instead of string literals for configuration values to improve maintainability and reduce errors when values change
Always ensure configuration values are managed consistently and sourced from stable locations.
Example:
// โ Poor configuration management
enum ConfigPath {
V05 = 'v0.5-branch/config/kfctl_config.yaml',
V06 = 'master/bootstrap/config/kfctl_gcp_iap.yaml' // Unstable source
}
const versionList = ['v0.7.0', 'v0.6.0']; // Hard-coded literals
// โ
Better configuration management
enum Version {
V05 = 'v0.5.0',
V06 = 'v0.6.0',
V07 = 'v0.7.0'
}
enum ConfigPath {
V05 = 'v0.5-branch/config/kfctl_config.yaml',
V06 = 'v0.6-branch/config/kfctl_gcp_iap.0.6.yaml' // Stable source
}
// Use constants and document environment-specific values
const versionList = [
Version.V07, // For local testing, will be overwritten by env vars
Version.V06
];
Enter the URL of a public GitHub repository