Skip to content

Conversation

@bshaffer
Copy link
Contributor

No description provided.

@bshaffer
Copy link
Contributor Author

NOTE: These samples will need to be updated for googleapis/google-cloud-php#169 once a new tag is available.

$bucketName = $input->getArgument('bucket');
$entity = $input->getOption('entity');
$role = $input->getOption('role');
if ($objectName = $input->getArgument('object')) {
Copy link
Contributor

@tmatsuo tmatsuo Sep 29, 2016

Choose a reason for hiding this comment

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

The if-else clauses here make me nervous.
Can it be simpler? How about to split this command into 3 or 4 commands like object-acl, default-acl, show-acl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about bucket-acl and object-acl?

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL

'Supply your encryption key'
)
->addOption(
'generate',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: So it's encryption --generate. I would say --generate-key

/**
* For instructions on how to run the full sample:
*
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/storage/api/README.md
Copy link
Contributor

@tmatsuo tmatsuo Sep 29, 2016

Choose a reason for hiding this comment

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

Does the README really have the instruction? How about to point them to our docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docs don't show how to run the CLI

Copy link
Contributor

Choose a reason for hiding this comment

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

So how about the README? It's now almost empty.


use Exception;

# [START rotate_encryption_key]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to put this snippet on our docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might as well leave it in - it'll be supported by the veneers soon.

],
['interactive' => false]
);
$this->expectOutputRegex("/Deleted allAuthenticatedUsers from \S+ ACL/");
Copy link
Contributor

Choose a reason for hiding this comment

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

This test will pass when the API call silently fails. Ideally can we test the actual behavior? Maybe you can file a bug for it and tackle it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now fixed!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, it's not. I mean, for example, if the following call:

$acl->add($entity, $role, $options);

doesn't raise any exception, but it fails to actually add the acl for some reason, our test will pass, but it's not working.

I think the ideal test should check if the acl is actually created as expected.

I'm fine with the current test for the initial version though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the API call to $acl->add fails, it will throw an exception. These tests are not to test the underlying google-cloud library, but rather to test the samples. I believe the tests are sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it fails with an exception, yes you're right. But potentially it can fail without throwing any exceptions. For example, the code may put the argument in a wrong order, normally it will throw an exception, but potentially they are legal, etc.

Anyway, you can merge and discuss this outside of this PR

],
['interactive' => false]
);
$this->expectOutputRegex("/Deleted \S+$basename-copy/");
Copy link
Contributor

Choose a reason for hiding this comment

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

Be careful about calling expectOutputRegex multiple times. Only the last call will take effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks. These are now all tackled in a single assert.

@tmatsuo
Copy link
Contributor

tmatsuo commented Sep 30, 2016

LGTM if you want to merge this with following TODOs:

  • More appropriate test
  • README that actually instruct how to run the cli
  • nit, but generate -> generate-key

Copy link
Contributor

@tmatsuo tmatsuo left a comment

Choose a reason for hiding this comment

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

Looks great!

@bshaffer bshaffer merged commit 2474a58 into master Sep 30, 2016
@bshaffer bshaffer deleted the add-storage branch September 30, 2016 19:09
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.

2 participants