Skip to content

Commit

Permalink
fix: Wrong variables when creating new BigQuery backed project
Browse files Browse the repository at this point in the history
Fixes #97
  • Loading branch information
paveltiunov committed Apr 30, 2019
1 parent bde5ea1 commit bae6348
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/cubejs-bigquery-driver/driver/BigQueryDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class BigQueryDriver extends BaseDriver {
this.toObjectFromId = this.toObjectFromId.bind(this);
}

static driverEnvVariables() {
return ['CUBEJS_DB_BQ_PROJECT_ID', 'CUBEJS_DB_BQ_KEY_FILE'];
}

testConnection() {
return this.bigquery.query({
query: 'SELECT ? AS number', params: ['1']
Expand Down
5 changes: 4 additions & 1 deletion packages/cubejs-cli/cubejsCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ const createApp = async (projectName, options) => {

logStage('Writing files from template');

const driverClass = requireFromPackage(driverDependencies[0]);

const templateConfig = templates[template];
const env = {
dbType: options.dbType,
apiSecret: crypto.randomBytes(64).toString('hex'),
projectName
projectName,
driverEnvVariables: driverClass.driverEnvVariables && driverClass.driverEnvVariables()
};
await Promise.all(Object.keys(templateConfig.files).map(async fileName => {
await fs.ensureDir(path.dirname(fileName));
Expand Down
14 changes: 10 additions & 4 deletions packages/cubejs-cli/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ const mongobiDotEnvVars = env => `${defaultDotEnvVars(env)}
#CUBEJS_DB_SSL_PASSPHRASE=<SSL_PASSPHRASE>
#CUBEJS_DB_SSL_REJECT_UNAUTHORIZED=<SSL_REJECT_UNAUTHORIZED>`;

const dotEnv = env => ({
athena: athenaDotEnvVars(env),
mongobi: mongobiDotEnvVars(env)
}[env.dbType] || defaultDotEnvVars(env));
const dotEnv = env => {
if (env.driverEnvVariables) {
const envVars = env.driverEnvVariables.map(v => `${v}=<${v.replace('CUBEJS', 'YOUR')}>`).join('\n');
return `${envVars}\n${sharedDotEnvVars(env)}`;
}
return {
athena: athenaDotEnvVars(env),
mongobi: mongobiDotEnvVars(env)
}[env.dbType] || defaultDotEnvVars(env);
};

const serverlessYml = env => `service: ${env.projectName}
Expand Down

0 comments on commit bae6348

Please sign in to comment.