Skip to content

Commit

Permalink
remove dependency on api.getSecret
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Long committed Jul 7, 2016
1 parent 1438d31 commit e3872c5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 40 deletions.
16 changes: 3 additions & 13 deletions lib/acquireRefs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

var FirebaseError = require('./error');
var api = require('./api');
var Firebase = require('firebase');
var RSVP = require('rsvp');
Expand All @@ -9,17 +8,8 @@ var requireAccess = require('./requireAccess');

module.exports = function(options, authScopes) {
return requireAccess(options, authScopes).then(function() {
return new RSVP.Promise(function(resolve, reject) {
var firebaseRef = new Firebase(utils.addSubdomain(api.realtimeOrigin, 'firebase'));
firebaseRef.authWithCustomToken(options.metadataToken, function(err) {
if (err) {
return reject(new FirebaseError('Failed to authenticate to Firebase', {
original: err
}));
}
options.firebaseRef = firebaseRef;
resolve();
});
});
var firebaseRef = new Firebase(utils.addSubdomain(api.realtimeOrigin, 'firebase'));
options.firebaseRef = firebaseRef;
return RSVP.resolve();
});
};
8 changes: 0 additions & 8 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ var api = {
exit: 2
}));
});
},
getSecret: function(instance, adminToken) {
return api.request('GET', '/.settings/secrets.json', {
origin: utils.addSubdomain(api.realtimeOrigin, instance),
query: {auth: adminToken}
}).then(function(response) {
return response.body[0];
});
}
};

Expand Down
1 change: 0 additions & 1 deletion lib/deploy/functions/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports = function(context, options, payload) {
origin: api.deployOrigin
});
};

if (options.config.get('functions')) {
utils.logBullet(chalk.cyan.bold('functions:') + ' preparing ' + chalk.bold(options.config.get('functions.source')) + ' directory for uploading...');

Expand Down
3 changes: 3 additions & 0 deletions lib/deploy/hosting/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ module.exports = function(context, options, payload) {
}
},
origin: api.deployOrigin
}).then(function() {
utils.logSuccess(chalk.green.bold('hosting:') + ' ' + chalk.bold(payload.hosting.public) + ' folder uploaded successfully');
resolve();
}).catch(reject);
});
});
Expand Down
30 changes: 12 additions & 18 deletions lib/prepareFunctionsUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ var _prepareSource = function(options) {
}
}

return api.getSecret(options.instance, options.databaseAdminToken).then(function(secret) { // maybe not needed?
_.assign(env, {
firebase: {
database: {
url: utils.addSubdomain(api.realtimeOrigin, options.instance),
secret: secret
}
_.assign(env, {
firebase: {
database: {
url: utils.addSubdomain(api.realtimeOrigin, options.instance)
}
});

fs.ensureFileSync(envDestPath);
fs.writeFileSync(envDestPath, JSON.stringify(env, null, 2));
return tmpdir;
}
});

fs.ensureFileSync(envDestPath);
fs.writeFileSync(envDestPath, JSON.stringify(env, null, 2));
return tmpdir;
};

var TRIGGER_PARSER = path.resolve(__dirname, './triggerParser.js');
Expand Down Expand Up @@ -140,12 +137,9 @@ var _packageSource = function(options, tmpdir) {
};

module.exports = function(options) {
var tmpdir;
return _prepareSource(options).then(function(result) {
tmpdir = result;
return _parseTriggers(options, tmpdir);
}).then(function(triggers) {
// respect any manually defined triggers in firebase.json
var tmpdir = _prepareSource(options);
return _parseTriggers(options, tmpdir).then(function(triggers) {
// respect any manually defined triggers in firebase.json
options.config.set('functions.triggers',
options.config.get('functions.triggers', []).concat(triggers)
);
Expand Down

0 comments on commit e3872c5

Please sign in to comment.