Merge 6c0f81864f into 8193b689ed
This commit is contained in:
commit
6d49ee06ee
22
README.md
22
README.md
|
|
@ -589,6 +589,28 @@ helm upgrade \
|
|||
zfs-nfs democratic-csi/democratic-csi
|
||||
```
|
||||
|
||||
### Injecting environment variables
|
||||
|
||||
It is possible to use environment variables to configure the `democratic-csi`
|
||||
driver, by setting a given field to `{env:<environment variable name>}`.
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
driver:
|
||||
config:
|
||||
driver: freenas-api-nfs
|
||||
instance_id:
|
||||
httpConnection:
|
||||
protocol: http
|
||||
host: 10.0.0.1
|
||||
port: 80
|
||||
apiKey: '{env:TRUENAS_API_KEY}'
|
||||
allowInsecure: false
|
||||
```
|
||||
|
||||
This will set the value of the `apiKey` field to the `TRUENAS_API_KEY` environment
|
||||
variable.
|
||||
|
||||
### A note on non standard kubelet paths
|
||||
|
||||
Some distrobutions, such as `minikube` and `microk8s` use a non-standard
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
require("../src/utils/polyfills");
|
||||
const yaml = require("js-yaml");
|
||||
const fs = require("fs");
|
||||
const { substituteEnvVars } = require("../src/utils/config_env");
|
||||
const { grpc } = require("../src/utils/grpc");
|
||||
const { stringify, stripWindowsDriveLetter } = require("../src/utils/general");
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ const args = require("yargs")
|
|||
}
|
||||
|
||||
try {
|
||||
options = yaml.load(fs.readFileSync(path, "utf8"));
|
||||
options = yaml.load(substituteEnvVars(fs.readFileSync(path, "utf8")));
|
||||
try {
|
||||
driverConfigFile = fs.realpathSync(path);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
function substituteEnvVars(config) {
|
||||
return config.replace(/{env:(.*)}/gm, (match, varName) => {
|
||||
if (!(varName in process.env)) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return process.env[varName];
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.substituteEnvVars = substituteEnvVars;
|
||||
Loading…
Reference in New Issue