Skip to content

Conversation

@ryanseys
Copy link
Contributor

Do not merge! No tests yet!

This is the implementation to make a bucket public and private. In my preliminary manually testing, it works great!

Optionally a recursive option can be set to true to set all the files in the bucket to public as well. QUESTION: Should this be default true? Also, I'm returning either a single error after the first error occurs if a file cannot be made public for some reason, or if they set force to true then it will add those errors to an array and return that array of errors at the end.

Additionally, I'm returning a list of the file objects that were successfully publicized/privatized.

I'm looking for feedback on general approach and big issues you can see.

Issues: bucket#makePrivate with strict: true always throws an error forbidden before it finishes, because it somehow doesn't recognize my account using service account key json to authenticate as an owner. Any idea how I can become the root owner of the bucket?

TODO: Add options.auto to apply a predefinedObjectACL on the bucket to allow new files to be created with the same permissions.

Depends on #390.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 28, 2015
@ryanseys ryanseys added api: storage Issues related to the Cloud Storage API. don't merge labels Feb 28, 2015

This comment was marked as spam.

@ryanseys ryanseys changed the title Add bucket#makePublic Add bucket#makePublic and bucket#makePrivate Mar 1, 2015

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor

I know the worst thing someone reviewing your PR can do is be like "here's a whole other bunch of code that renders yours useless!" I didn't intend to let it get to that point- I just wanted to drop the PR in my editor, which makes it easier for me to make sense of. I found some things I thought I could improve by demonstrating as opposed to trying to explain. And, before you know it... https://gist.github.com/stephenplusplus/66bfc7ba04ba97a8a15a

I think either approach is perfectly fine, I just wanted to hold less state outside of each function, and make it more modular in general. As an example, I let bucket#makePrivate() and bucket#makePublic() handle each of their metadata calls, then changed the behavior of _makePublicPrivate to a more focused intent: _makeAllFilesPublicPrivate.

It's not tested (didn't even run it), but if it's something that doesn't look hideous to you, I can send a PR with it to evolve from this one, or you can send me a meme that explains what a jerk I am, and I'll delete the gist and pretend it never happened!

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 3, 2015

Hey this is great! I don't mind one bit because mine was more POC. One thing that is still TODO that needs to be thought of is the options.auto which sets the default object ACL for the bucket as well. I've got a midterm that requires my focus today so can't really care for this PR so I'm 100% ok with abandoning it and letting you run with your gist. We can close this PR, and you can reopen a new one if you want to keep running with this. That's the easiest way forward.

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 3, 2015

Upon closer inspection your async.eachLimit doesn't really make sense. You don't want to run with the nextQuery on each file, only after all files are processed.

@stephenplusplus
Copy link
Contributor

Ooh, good catch. I'll have to think my way out of that one!

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 3, 2015

Actually you're right, I was messing up the callback count.

@stephenplusplus
Copy link
Contributor

Wait:

async.eachLimit(files, MAX_PARALLEL_LIMIT, processFile, function(err) {

Won't that process files (max 10 at a time) until all files are processed, then call processFiles again for the nextQuery?

@stephenplusplus
Copy link
Contributor

We're a mess

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 3, 2015

Yeah my bad... :( I think you'll be good. Or you'll figure it out! 😄

@stephenplusplus
Copy link
Contributor

Going to close this to let #429 carry it on. If I missed anything in the transfer, please update the issue pr.

@ryanseys ryanseys deleted the make-public-buckets branch March 5, 2015 19:25
chingor13 pushed a commit that referenced this pull request Aug 22, 2022
sofisl pushed a commit that referenced this pull request Sep 15, 2022
…cloud-rad for nodejs (#418)

This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/b02a7220-ded6-43ea-abe6-c043d792fee2/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@21f1470
Source-Link: googleapis/synthtool@d82decc
sofisl pushed a commit that referenced this pull request Oct 12, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/c503f640-90ae-4547-bcc8-a154d32c609e/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@15013ef
sofisl pushed a commit that referenced this pull request Nov 17, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@google-cloud/projectify](https://togithub.com/googleapis/nodejs-projectify) | dependencies | major | [`^1.0.0` -> `^2.0.0`](https://renovatebot.com/diffs/npm/@google-cloud%2fprojectify/1.0.4/2.0.0) |

---

### Release Notes

<details>
<summary>googleapis/nodejs-projectify</summary>

### [`v2.0.0`](https://togithub.com/googleapis/nodejs-projectify/blob/master/CHANGELOG.md#&#8203;200-httpswwwgithubcomgoogleapisnodejs-projectifycomparev104v200-2020-03-24)

[Compare Source](https://togithub.com/googleapis/nodejs-projectify/compare/v1.0.4...v2.0.0)

##### ⚠ BREAKING CHANGES

-   [email protected] introduced some breaking changes
-   drop Node 8 from engines field ([#&#8203;172](https://togithub.com/googleapis/nodejs-projectify/issues/172))

##### Features

-   drop Node 8 from engines field ([#&#8203;172](https://www.github.com/googleapis/nodejs-projectify/issues/172)) ([3eac424](https://www.github.com/googleapis/nodejs-projectify/commit/3eac424bfb1ee47144a77888dc68db687988945e))

##### Build System

-   update to latest version of gts/typescript ([#&#8203;171](https://www.github.com/googleapis/nodejs-projectify/issues/171)) ([30f90cc](https://www.github.com/googleapis/nodejs-projectify/commit/30f90cc172da6ed9394da91869556bf5eef42434))

##### [1.0.4](https://www.github.com/googleapis/nodejs-projectify/compare/v1.0.3...v1.0.4) (2019-12-05)

##### Bug Fixes

-   **publish:** publication failed to reach npm ([#&#8203;141](https://www.github.com/googleapis/nodejs-projectify/issues/141)) ([5406ba5](https://www.github.com/googleapis/nodejs-projectify/commit/5406ba5e1d43a228a19072023c1baebce34190af))

##### [1.0.3](https://www.github.com/googleapis/nodejs-projectify/compare/v1.0.2...v1.0.3) (2019-12-05)

##### Bug Fixes

-   **deps:** pin TypeScript below 3.7.0 ([6c95307](https://www.github.com/googleapis/nodejs-projectify/commit/6c953070139a77d30c4ce5b7dee1443874046906))

##### [1.0.2](https://www.github.com/googleapis/nodejs-projectify/compare/v1.0.1...v1.0.2) (2019-11-14)

##### Bug Fixes

-   **docs:** add jsdoc-region-tag plugin ([#&#8203;135](https://www.github.com/googleapis/nodejs-projectify/issues/135)) ([59301e7](https://www.github.com/googleapis/nodejs-projectify/commit/59301e7cfa855add4894dd9c46870e61fffa7413))

##### [1.0.1](https://www.github.com/googleapis/nodejs-projectify/compare/v1.0.0...v1.0.1) (2019-06-26)

##### Bug Fixes

-   **docs:** link to reference docs section on googleapis.dev ([#&#8203;119](https://www.github.com/googleapis/nodejs-projectify/issues/119)) ([90a009f](https://www.github.com/googleapis/nodejs-projectify/commit/90a009f))

</details>

---

### Renovate configuration

:date: **Schedule**: "after 9am and before 3pm" (UTC).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/nodejs-compute).
sofisl pushed a commit that referenced this pull request Nov 17, 2022
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.0.0](https://www.github.com/googleapis/nodejs-compute/compare/v1.2.0...v2.0.0) (2020-05-08)


### ⚠ BREAKING CHANGES

* update to latest version of gts and typescript (#433)
* require node 10 in engines field (#431)

### Features

* require node 10 in engines field ([#431](https://www.github.com/googleapis/nodejs-compute/issues/431)) ([fe2897f](https://www.github.com/googleapis/nodejs-compute/commit/fe2897fd1d625df0ccf5b910ec850e761c2ed6d3))


### Bug Fixes

* apache license URL ([#468](https://www.github.com/googleapis/nodejs-compute/issues/468)) ([#427](https://www.github.com/googleapis/nodejs-compute/issues/427)) ([02d63ed](https://www.github.com/googleapis/nodejs-compute/commit/02d63ed5a5a3559be0b5e49ed4c771b3661518a1))
* **deps:** update dependency @google-cloud/common to v3 ([#421](https://www.github.com/googleapis/nodejs-compute/issues/421)) ([d4469b6](https://www.github.com/googleapis/nodejs-compute/commit/d4469b693745df5a8a36b6988b7dba98f7d55142))
* **deps:** update dependency @google-cloud/paginator to v3 ([#419](https://www.github.com/googleapis/nodejs-compute/issues/419)) ([e667aee](https://www.github.com/googleapis/nodejs-compute/commit/e667aeecf7b9f51875c06cb6a885040828dc1181))
* **deps:** update dependency @google-cloud/projectify to v2 ([#418](https://www.github.com/googleapis/nodejs-compute/issues/418)) ([b861540](https://www.github.com/googleapis/nodejs-compute/commit/b861540aa17118a7508c7c970d84864a9028f588))
* **deps:** update dependency @google-cloud/promisify to v2 ([#417](https://www.github.com/googleapis/nodejs-compute/issues/417)) ([eedce75](https://www.github.com/googleapis/nodejs-compute/commit/eedce75e0d3f10dfed8151f12150d38d032f6a27))
* **deps:** update dependency @sendgrid/mail to v7 ([#424](https://www.github.com/googleapis/nodejs-compute/issues/424)) ([17af0f4](https://www.github.com/googleapis/nodejs-compute/commit/17af0f425354b261f9afc8ab30e16e66b7193fec))


### Build System

* update to latest version of gts and typescript ([#433](https://www.github.com/googleapis/nodejs-compute/issues/433)) ([a4fa8cc](https://www.github.com/googleapis/nodejs-compute/commit/a4fa8cc21df7a894486832b05449fa7afc02b7ee))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
sofisl pushed a commit that referenced this pull request Nov 18, 2022
sofisl pushed a commit that referenced this pull request Jan 24, 2023
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
sofisl pushed a commit that referenced this pull request Jan 25, 2023
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
sofisl pushed a commit that referenced this pull request Sep 13, 2023
sofisl pushed a commit that referenced this pull request Sep 14, 2023
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/4de22315-84b1-493d-8da2-dfa7688128f5/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@94421c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants