Skip to content

Conversation

@bshaffer
Copy link
Contributor

No description provided.

@bshaffer bshaffer requested a review from alixhami January 2, 2019 18:25
@bshaffer
Copy link
Contributor Author

bshaffer commented Jan 2, 2019

Done using the "new" way of writing samples (no "command" class, and no functions surrounding the sample code).

Would love some review :)

@bshaffer bshaffer requested review from a team, dwsupplee and tmatsuo and removed request for alixhami, dwsupplee and tmatsuo January 2, 2019 18:27
// The resource name of the location associated with the KeyRings
$parent = sprintf('projects/%s/locations/%s', $projectId, $location);
// Lists keys in the "global" location. Could also be "us-west1", etc.
$locationId = 'global';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you would ever choose a specific region when global is available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe you want to lock down permissions, or maybe it's for organization? I don't know TBH.

Copy link

Choose a reason for hiding this comment

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

You might choose a region like 'us-east1' if you have specific latency and/or data residency requirements:
https://cloud.google.com/kms/docs/locations#location_types

Copy link
Contributor

@grayside grayside left a comment

Choose a reason for hiding this comment

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

Things are looking consistent and aligned with "New New Practices". I raised a couple points that seem worth further discussion, so leaving this at comment for now.

"files": [
"src/functions.php"
]
"google/cloud-kms": "^0.4.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay for specific client libraries!

$policy->setBindings($bindings);

// Set the new IAM Policy.
$kms->setIamPolicy($cryptoKeyName, $policy);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check for success?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the API will throw an error if this is not successful

@@ -0,0 +1,64 @@
<?php
/**
* Copyright 2018 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Slowly shifting to Google LLC, unless it's pending on some test automation updates?

foreach ($policy->getBindings() as $binding) {
if ($binding->getRole() == $role) {
$members = $binding->getMembers();
foreach ($members as $i => $existingMember) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could shrink this a couple lines with array_search(). It's looking like one of the more complicated operations. Maybe the client library should have some helper functions on a couple of these operations that require fairly boilerplate modifications?

In practice, I would wrap this in a helper library rather than inline the code anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

array_search doesn't work because $members is a protobuf object :-/

I agree about the helper functions, and I thought we might have something written in the client libraries but I couldn't find anything. Adding @dwsupplee for advice here.

@bshaffer bshaffer merged commit 53fcce5 into master Jan 9, 2019
@bshaffer bshaffer deleted the update-kms branch January 9, 2019 01:25
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