ืืคื ื ืฉื ืชืืื ืืขืืื ืขื ConfigMaps, ืื ืื ื ืืขืืื ืื ืืช ืืคืืืงืฆืืืช colorAPI ืื ืฉืชืืื ืืงืื ืืช ืืฆืืข:
ืืืืจื:
ืืืคืฉืจ ืื ื ืืืืฉื ืืืืจืื ืชืฆืืจื ืืืฆืื ืืช ืืจื Kubernetes.
ื ืืื ืก ืืงืืืฅ ืืจืืฉื ืฉื ืืืคืืืงืฆืื (ืืืฉื app.js).
ื ืืกืืฃ ืืืขืื:
const fs = require("fs");
const path = require("path");
โ fs โ ืืงืจืืืช ืงืืฆืื
โ path โ ืืืืคืื ืื ืชืืื ืืขืจืืช
ื ืืฆืืจ ืคืื ืงืฆืื ืืืฉื:
const getColor = () => {
let color = process.env.DEFAULT_COLOR;
const filePath = process.env.COLOR_CONFIG_PATH;
if (filePath) {
try {
const colorFromFile = fs.readFileSync(
path.resolve(filePath),
"utf8"
);
color = colorFromFile.trim();
} catch (error) {
console.error(`Failed to read contents of ${filePath}`);
console.error(error);
}
}
return color || "blue";
};