Skip to content

feat(functions/v2): add GCE labeling sample - #6432

Merged
averikitsch merged 4 commits into
mainfrom
gcf-compute
Nov 24, 2021
Merged

averikitsch merged 4 commits into
mainfrom
gcf-compute

Conversation

@averikitsch

Copy link
Copy Markdown
Contributor

Fixes #issue

It's a good idea to open an issue first for discussion.

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • API's need to be enabled to test (tell us)
  • Environment Variables need to be set (ask us to set them)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • Please merge this PR for me once it is approved.

@averikitsch
averikitsch requested a review from ace-n November 24, 2021 18:58
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 24, 2021
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 24, 2021

@ace-n ace-n left a comment

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.

LGTM other than the file-paths issue.

@@ -16,9 +16,7 @@
limitations under the License.
-->

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.

Did you mean to change this file?

I think we should put this sample in its own directory, e.g. functions/v2/cloudevent/label-compute-instance

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 probably want to restructure this directory without so much nesting. Currently it would be:

- helloworld/
  - hello-gcs/
- pubsub/
  - subscribe-to-topic/
- cloudevents/
  - log-cloudevent/
  - autolabelinstance/ (if moved into another project)

But we may just want to use the top level folder with individual files for functions

- helloworld/
  - hello-gcs.java
- pubsub/
  - subscribe-to-topic.java
- cloudevents/
  - log-cloudevent.java
  - autolabelinstance.java

Thoughts?

@ace-n ace-n Nov 24, 2021 •

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 believe we previously decided to give each sample its own project (and thus, its own directory).

That being said, I'd be happy with functions/v2/label-compute-instance, if you want to remove the cloudevent part.

@suztomo

suztomo commented Nov 24, 2021

Copy link
Copy Markdown
Contributor

https://source.cloud.google.com/results/invocations/c5eb66d3-6251-4dde-832e-66657f397842/targets/cloud-devrel%2Fjava%2Fjava-docs-samples%2Flint%2Fpresubmit/log

#
# functions/v2/cloudevent/log-cloudevent
#

[ERROR] src/main/java/functions/AutoLabelInstance.java:[57,7] (blocks) NeedBraces: 'if' construct must use '{}'s.
[ERROR] src/main/java/functions/AutoLabelInstance.java:[65,7] (blocks) NeedBraces: 'if' construct must use '{}'s.
[ERROR] src/main/java/functions/AutoLabelInstance.java:[70,7] (blocks) NeedBraces: 'if' construct must use '{}'s.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (default-cli) on project functions-log-cloudevent: You have 3 Checkstyle violations. -> [Help 1]
[ERROR]


private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String ZONE = "us-central1-a";
private static final String INSTANCE = "lite1";

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.

Should this be a UUID?

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.

This sample only labels the GCE VM. I looked at the create a VM code and I am not sure I want to have create and delete an instance every test run; therefore I am using an already created VM. Thoughts?

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.

Your probably ok, but anything that creates using a fixed name will have problems in our testing environment.

@lesv lesv left a comment

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'd rather you were using released artifacts rather than an alpha or RC.

Take a look at your instance name, perhaps it should be a UUID if it were created multiple times for different versions of the language during testing. Also, you might wish to then look for stuff >24h old and delete them.

@averikitsch averikitsch added the automerge Merge the pull request once unit tests and other checks pass. label Nov 24, 2021
@averikitsch
averikitsch merged commit af962b4 into main Nov 24, 2021
@averikitsch
averikitsch deleted the gcf-compute branch November 24, 2021 23:32
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Nov 24, 2021
@ace-n ace-n changed the title Add GCF Compute sample feat(functions/v2): add GCE labeling sample Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants