Skip to content

Brings storage rules deploy into the CLI - #461

Merged
mbleigh merged 2 commits into
masterfrom
mb-rules
Sep 20, 2017
Merged

mbleigh merged 2 commits into
masterfrom
mb-rules

Conversation

@mbleigh

@mbleigh mbleigh commented Sep 19, 2017

Copy link
Copy Markdown
Contributor

This takes responsibility for deploying storage rules out of the previous backend server and puts it directly in the CLI. Primarily this is a lift-and-translate of backend code (ping me if you want to see where it came from).

This is groundwork for other ongoing refactorings (specifically resource targets) but should be reviewed independently and can be merged separately.

I wanted to do this first so that the multi-resource config abstraction could be built on a stable foundation.

/cc @samtstern who is working with similar code right now and should be aware of this PR.

Comment thread lib/gcp/rules.js Outdated
function createRuleset(projectId, files) {
var payload = {source: {files: files}};

return api.request('POST', '/v1/projects/' + projectId + '/rulesets', {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to put the version # at the top of the file, so if we need to update API version in the future, it's a simpler change. (See https://github.com/firebase/firebase-tools/blob/master/lib/gcp/cloudfunctions.js#L10)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

module.exports = function(context, options, payload) {
module.exports = function(context, options) {
var rulesPath = options.config.get('storage.rules');
if (rulesPath) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If rulesPath is not defined, is there a message to the user?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, and I don't think we want one (see above comment).

module.exports = function(context, options) {
var files = _.get(context, 'storage.rules');
if (!files) {
return RSVP.resolve();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a message saying "No rules to deploy"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to do this, since someone running firebase deploy without having initialized their project for storage wouldn't have expected storage to deploy and the message would just be confusing.

Comment thread lib/deploy/storage/deploy.js Outdated

return gcp.storage.buckets.getDefault(options.project).then(function(defaultBucket) {
if (!defaultBucket) {
return utils.reject('Unable to locate your default bucket. Please visit the storage panel in the Firebase console to ensure provisioning.');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"provisioning" is a confusing and overly technical, rephrase?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@laurenzlong laurenzlong assigned mbleigh and unassigned laurenzlong Sep 20, 2017
@mbleigh mbleigh assigned laurenzlong and unassigned mbleigh Sep 20, 2017
@laurenzlong laurenzlong assigned mbleigh and unassigned laurenzlong Sep 20, 2017
@coveralls

coveralls commented Sep 20, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 57.27% when pulling 5232976 on mb-rules into a968600 on master.

@mbleigh
mbleigh merged commit f981c19 into master Sep 20, 2017
@mbleigh
mbleigh deleted the mb-rules branch September 20, 2017 22:39
yuchenshi pushed a commit that referenced this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants