Skip to content

Commit

Permalink
feat(cubejs-cli): Resolve content from CUBEJS_DB_SSL_CA/CUBEJS_DB_SSL…
Browse files Browse the repository at this point in the history
…_CERT/CUBEJS_DB_SSL_KEY (if it's path)
  • Loading branch information
ovr committed Dec 3, 2020
1 parent 322f662 commit ab42471
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 71 deletions.
1 change: 1 addition & 0 deletions packages/cubejs-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"LICENSE"
],
"dependencies": {
"@cubejs-backend/shared": "^0.24.3",
"chalk": "^2.4.2",
"cli-progress": "^3.8.2",
"commander": "^2.19.0",
Expand Down
23 changes: 22 additions & 1 deletion packages/cubejs-cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import jwt from 'jsonwebtoken';
import path from 'path';
import os from 'os';
import dotenv from 'dotenv';
import { isFilePath } from '@cubejs-backend/shared';

type ConfigurationFull = {
auth: {
Expand Down Expand Up @@ -42,7 +43,27 @@ export class Config {

public async envFile(envFile: string) {
if (await fs.pathExists(envFile)) {
return dotenv.config({ path: envFile }).parsed;
const env = dotenv.config({ path: envFile }).parsed;
if (env) {
const resolvePossibleFiles = [
'CUBEJS_DB_SSL_CA',
'CUBEJS_DB_SSL_CERT',
'CUBEJS_DB_SSL_KEY',
];

// eslint-disable-next-line no-restricted-syntax
for (const [key, value] of Object.entries(env)) {
if (resolvePossibleFiles.includes(key) && isFilePath(value)) {
if (fs.existsSync(value)) {
env[key] = fs.readFileSync(value, 'ascii');
} else {
env[key] = '';
}
}
}

return env;
}
}

return {};
Expand Down
169 changes: 99 additions & 70 deletions packages/cubejs-cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,24 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@cubejs-backend/linter@^0.24.2":
version "0.24.2"
resolved "https://registry.yarnpkg.com/@cubejs-backend/linter/-/linter-0.24.2.tgz#841f30b7357beca98a440788136b1f479400d072"
integrity sha512-FbM8SKEzAMXyfcmAbNZsYMKQiiyoYu4jR2281rZOa9e/XD9023Wy8dOsoEMVI7wjFMIeqkH9VV3es0n95Ricwg==
dependencies:
"@typescript-eslint/eslint-plugin" "^4.1.1"
"@typescript-eslint/parser" "^4.1.1"
eslint "^7.9.0"
eslint-config-airbnb-base "^14.2.0"
eslint-plugin-import "^2.22.0"
eslint-plugin-node "^6.0.1"
"@cubejs-backend/linter@^0.24.3":
version "0.24.3"
resolved "https://registry.yarnpkg.com/@cubejs-backend/linter/-/linter-0.24.3.tgz#9f943a69f755707118fb1b67f447378072b0dbea"
integrity sha512-/cSlFiTErloy6Uvgyzu1lEms5jfYj6oQXVp8ILNeJzo4r++gFvbox22CjNc7SlUN5tHC3x8sDzcJG4xqi9+7+Q==
dependencies:
"@typescript-eslint/eslint-plugin" "^4.8.2"
"@typescript-eslint/parser" "^4.8.2"
eslint "^7.14.0"
eslint-config-airbnb-base "^14.2.1"
eslint-plugin-import "^2.22.1"
eslint-plugin-node "^9.2.0"

"@cubejs-backend/shared@^0.24.3":
version "0.24.3"
resolved "https://registry.yarnpkg.com/@cubejs-backend/shared/-/shared-0.24.3.tgz#f2e3d9ba99cab906e7b4953c1c475fd81fd120eb"
integrity sha512-r5/E5cX6cleTM9HWP/i2o0iZbbotlD10JiLT4FFcvCVcj+XPc5064w6yP84YjiwpKyBvbO+OW9JyFguZ7Lf6vw==
dependencies:
env-var "^6.3.0"

"@eslint/eslintrc@^0.2.1":
version "0.2.1"
Expand Down Expand Up @@ -630,74 +637,74 @@
dependencies:
"@types/yargs-parser" "*"

"@typescript-eslint/eslint-plugin@^4.1.1":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.8.2.tgz#cf9102ec800391caa574f589ffe0623cca1d9308"
integrity sha512-gQ06QLV5l1DtvYtqOyFLXD9PdcILYqlrJj2l+CGDlPtmgLUzc1GpqciJFIRvyfvgLALpnxYINFuw+n9AZhPBKQ==
"@typescript-eslint/eslint-plugin@^4.8.2":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.0.tgz#8fde15743413661fdc086c9f1f5d74a80b856113"
integrity sha512-WrVzGMzzCrgrpnQMQm4Tnf+dk+wdl/YbgIgd5hKGa2P+lnJ2MON+nQnbwgbxtN9QDLi8HO+JAq0/krMnjQK6Cw==
dependencies:
"@typescript-eslint/experimental-utils" "4.8.2"
"@typescript-eslint/scope-manager" "4.8.2"
"@typescript-eslint/experimental-utils" "4.9.0"
"@typescript-eslint/scope-manager" "4.9.0"
debug "^4.1.1"
functional-red-black-tree "^1.0.1"
regexpp "^3.0.0"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@4.8.2":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.8.2.tgz#8909a5732f19329cf5ef0c39766170476bff5e50"
integrity sha512-hpTw6o6IhBZEsQsjuw/4RWmceRyESfAiEzAEnXHKG1X7S5DXFaZ4IO1JO7CW1aQ604leQBzjZmuMI9QBCAJX8Q==
"@typescript-eslint/experimental-utils@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.0.tgz#23a296b85d243afba24e75a43fd55aceda5141f0"
integrity sha512-0p8GnDWB3R2oGhmRXlEnCvYOtaBCijtA5uBfH5GxQKsukdSQyI4opC4NGTUb88CagsoNQ4rb/hId2JuMbzWKFQ==
dependencies:
"@types/json-schema" "^7.0.3"
"@typescript-eslint/scope-manager" "4.8.2"
"@typescript-eslint/types" "4.8.2"
"@typescript-eslint/typescript-estree" "4.8.2"
"@typescript-eslint/scope-manager" "4.9.0"
"@typescript-eslint/types" "4.9.0"
"@typescript-eslint/typescript-estree" "4.9.0"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/parser@^4.1.1":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.8.2.tgz#78dccbe5124de2b8dea2d4c363dee9f769151ca8"
integrity sha512-u0leyJqmclYr3KcXOqd2fmx6SDGBO0MUNHHAjr0JS4Crbb3C3d8dwAdlazy133PLCcPn+aOUFiHn72wcuc5wYw==
"@typescript-eslint/parser@^4.8.2":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.9.0.tgz#bb65f1214b5e221604996db53ef77c9d62b09249"
integrity sha512-QRSDAV8tGZoQye/ogp28ypb8qpsZPV6FOLD+tbN4ohKUWHD2n/u0Q2tIBnCsGwQCiD94RdtLkcqpdK4vKcLCCw==
dependencies:
"@typescript-eslint/scope-manager" "4.8.2"
"@typescript-eslint/types" "4.8.2"
"@typescript-eslint/typescript-estree" "4.8.2"
"@typescript-eslint/scope-manager" "4.9.0"
"@typescript-eslint/types" "4.9.0"
"@typescript-eslint/typescript-estree" "4.9.0"
debug "^4.1.1"

"@typescript-eslint/scope-manager@4.8.2":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.8.2.tgz#a18388c63ae9c17adde519384f539392f2c4f0d9"
integrity sha512-qHQ8ODi7mMin4Sq2eh/6eu03uVzsf5TX+J43xRmiq8ujng7ViQSHNPLOHGw/Wr5dFEoxq/ubKhzClIIdQy5q3g==
"@typescript-eslint/scope-manager@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.9.0.tgz#5eefe305d6b71d1c85af6587b048426bfd4d3708"
integrity sha512-q/81jtmcDtMRE+nfFt5pWqO0R41k46gpVLnuefqVOXl4QV1GdQoBWfk5REcipoJNQH9+F5l+dwa9Li5fbALjzg==
dependencies:
"@typescript-eslint/types" "4.8.2"
"@typescript-eslint/visitor-keys" "4.8.2"
"@typescript-eslint/types" "4.9.0"
"@typescript-eslint/visitor-keys" "4.9.0"

"@typescript-eslint/types@4.8.2":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.8.2.tgz#c862dd0e569d9478eb82d6aee662ea53f5661a36"
integrity sha512-z1/AVcVF8ju5ObaHe2fOpZYEQrwHyZ7PTOlmjd3EoFeX9sv7UekQhfrCmgUO7PruLNfSHrJGQvrW3Q7xQ8EoAw==
"@typescript-eslint/types@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.9.0.tgz#3fe8c3632abd07095c7458f7451bd14c85d0033c"
integrity sha512-luzLKmowfiM/IoJL/rus1K9iZpSJK6GlOS/1ezKplb7MkORt2dDcfi8g9B0bsF6JoRGhqn0D3Va55b+vredFHA==

"@typescript-eslint/typescript-estree@4.8.2":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.8.2.tgz#eeec34707d8577600fb21661b5287226cc8b3bed"
integrity sha512-HToGNwI6fekH0dOw3XEVESUm71Onfam0AKin6f26S2FtUmO7o3cLlWgrIaT1q3vjB3wCTdww3Dx2iGq5wtUOCg==
"@typescript-eslint/typescript-estree@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.9.0.tgz#38a98df6ee281cfd6164d6f9d91795b37d9e508c"
integrity sha512-rmDR++PGrIyQzAtt3pPcmKWLr7MA+u/Cmq9b/rON3//t5WofNR4m/Ybft2vOLj0WtUzjn018ekHjTsnIyBsQug==
dependencies:
"@typescript-eslint/types" "4.8.2"
"@typescript-eslint/visitor-keys" "4.8.2"
"@typescript-eslint/types" "4.9.0"
"@typescript-eslint/visitor-keys" "4.9.0"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/visitor-keys@4.8.2":
version "4.8.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.8.2.tgz#62cd3fbbbf65f8eccfbe6f159eb1b84a243a3f77"
integrity sha512-Vg+/SJTMZJEKKGHW7YC21QxgKJrSbxoYYd3MEUGtW7zuytHuEcksewq0DUmo4eh/CTNrVJGSdIY9AtRb6riWFw==
"@typescript-eslint/visitor-keys@4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.9.0.tgz#f284e9fac43f2d6d35094ce137473ee321f266c8"
integrity sha512-sV45zfdRqQo1A97pOSx3fsjR+3blmwtdCt8LDrXgCX36v4Vmz4KHrhpV6Fo2cRdXmyumxx11AHw0pNJqCNpDyg==
dependencies:
"@typescript-eslint/types" "4.8.2"
"@typescript-eslint/types" "4.9.0"
eslint-visitor-keys "^2.0.0"

"@ungap/promise-all-settled@1.1.2":
Expand Down Expand Up @@ -1520,6 +1527,11 @@ enquirer@^2.3.5:
dependencies:
ansi-colors "^4.1.1"

env-var@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/env-var/-/env-var-6.3.0.tgz#b4ace5bcd1d293629a2c509ae7b46f8add2f8892"
integrity sha512-gaNzDZuVaJQJlP2SigAZLu/FieZN5MzdN7lgHNehESwlRanHwGQ/WUtJ7q//dhrj3aGBZM45yEaKOuvSJaf4mA==

error-ex@^1.2.0, error-ex@^1.3.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
Expand Down Expand Up @@ -1598,7 +1610,7 @@ escodegen@^1.9.1:
optionalDependencies:
source-map "~0.6.1"

eslint-config-airbnb-base@^14.2.0:
eslint-config-airbnb-base@^14.2.1:
version "14.2.1"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz#8a2eb38455dc5a312550193b319cdaeef042cd1e"
integrity sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==
Expand All @@ -1623,7 +1635,15 @@ eslint-module-utils@^2.6.0:
debug "^2.6.9"
pkg-dir "^2.0.0"

eslint-plugin-import@^2.22.0:
eslint-plugin-es@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-1.4.1.tgz#12acae0f4953e76ba444bfd1b2271081ac620998"
integrity sha512-5fa/gR2yR3NxQf+UXkeLeP8FBBl6tSgdrAz1+cF84v1FMM4twGwQoqTnn+QxFLcPOrF4pdKEJKDB/q9GoyJrCA==
dependencies:
eslint-utils "^1.4.2"
regexpp "^2.0.1"

eslint-plugin-import@^2.22.1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz#0896c7e6a0cf44109a2d97b95903c2bb689d7702"
integrity sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==
Expand All @@ -1642,15 +1662,17 @@ eslint-plugin-import@^2.22.0:
resolve "^1.17.0"
tsconfig-paths "^3.9.0"

eslint-plugin-node@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4"
integrity sha512-Q/Cc2sW1OAISDS+Ji6lZS2KV4b7ueA/WydVWd1BECTQwVvfQy5JAi3glhINoKzoMnfnuRgNP+ZWKrGAbp3QDxw==
eslint-plugin-node@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-9.2.0.tgz#b1911f111002d366c5954a6d96d3cd5bf2a3036a"
integrity sha512-2abNmzAH/JpxI4gEOwd6K8wZIodK3BmHbTxz4s79OIYwwIt2gkpEXlAouJXu4H1c9ySTnRso0tsuthSOZbUMlA==
dependencies:
ignore "^3.3.6"
eslint-plugin-es "^1.4.1"
eslint-utils "^1.4.2"
ignore "^5.1.1"
minimatch "^3.0.4"
resolve "^1.3.3"
semver "^5.4.1"
resolve "^1.10.1"
semver "^6.1.0"

eslint-scope@^5.0.0, eslint-scope@^5.1.1:
version "5.1.1"
Expand All @@ -1660,6 +1682,13 @@ eslint-scope@^5.0.0, eslint-scope@^5.1.1:
esrecurse "^4.3.0"
estraverse "^4.1.1"

eslint-utils@^1.4.2:
version "1.4.3"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f"
integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==
dependencies:
eslint-visitor-keys "^1.1.0"

eslint-utils@^2.0.0, eslint-utils@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
Expand All @@ -1677,7 +1706,7 @@ eslint-visitor-keys@^2.0.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==

eslint@^7.9.0:
eslint@^7.14.0:
version "7.14.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.14.0.tgz#2d2cac1d28174c510a97b377f122a5507958e344"
integrity sha512-5YubdnPXrlrYAFCKybPuHIAH++PINe1pmKNc5wQRB9HSbqIK1ywAnntE3Wwua4giKu0bjligf1gLF6qxMGOYRA==
Expand Down Expand Up @@ -2285,17 +2314,12 @@ iconv-lite@0.4.24, iconv-lite@^0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

ignore@^3.3.6:
version "3.3.10"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==

ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

ignore@^5.1.4:
ignore@^5.1.1, ignore@^5.1.4:
version "5.1.8"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==
Expand Down Expand Up @@ -4077,6 +4101,11 @@ regex-not@^1.0.0, regex-not@^1.0.2:
extend-shallow "^3.0.2"
safe-regex "^1.1.0"

regexpp@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==

regexpp@^3.0.0, regexpp@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
Expand Down Expand Up @@ -4186,7 +4215,7 @@ resolve@1.1.7:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

resolve@^1.10.0, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.3.2, resolve@^1.3.3:
resolve@^1.10.0, resolve@^1.10.1, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.3.2:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
Expand Down Expand Up @@ -4305,7 +4334,7 @@ semver-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@^6.0.0, semver@^6.2.0:
semver@^6.0.0, semver@^6.1.0, semver@^6.2.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
Expand Down

0 comments on commit ab42471

Please sign in to comment.