-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Container Analysis Beta #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container Analysis Beta #1194
Conversation
4168a2f
to
11f11c1
Compare
throws Exception { | ||
public static Subscription createOccurrenceSubscription(String subId, String projectId) | ||
throws IOException, StatusRuntimeException { | ||
// This topic id will automatically receive messages when Occurrences are added or modified | ||
String topicId = "resource-notes-occurrences-v1alpha1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vtsao Is there a new topic Id for beta?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup:
container-analysis-occurrences-v1beta1
11f11c1
to
487449f
Compare
487449f
to
934cbe2
Compare
} | ||
public static Occurrence createOccurrence(GrafeasV1Beta1Client client, String imageUri, | ||
String parentNoteId,String projectId) { | ||
final String parentNoteName = client.formatNoteName(projectId, parentNoteId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable can just be called noteName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also just "noteId".
* Makes an update to an existing occurrence | ||
* | ||
* Pushes an update to an Occurrence that already exists on the server | ||
* @param client The Grafeas client used to perform the API requests. | ||
* @param occurrenceName the name of the occurrence to delete. | ||
* format: "projects/{projectId}/occurrences/{occurrence_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the forms should be stylized as:
"projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]"
throws Exception { | ||
public static Subscription createOccurrenceSubscription(String subId, String projectId) | ||
throws IOException, StatusRuntimeException { | ||
// This topic id will automatically receive messages when Occurrences are added or modified | ||
String topicId = "resource-notes-occurrences-v1alpha1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup:
container-analysis-occurrences-v1beta1
try (ContainerAnalysisClient client = ContainerAnalysisClient.create()) { | ||
final String noteName = client.formatNoteName(projectId, noteId); | ||
public static Note getNote(GrafeasV1Beta1Client client, String noteId, String projectId) { | ||
final String noteName = client.formatNoteName(projectId, noteId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI the Java lib has been updated to now have the methods with the resource name types:
https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-clients/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1beta1
E.g., instead of using the formatter to create a string, you can do:
NoteName name = NoteName.of("[PROJECT]", "[NOTE]");
to use the NoteName type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for all other resource types.
b9b441f
to
317b7e3
Compare
317b7e3
to
8f28455
Compare
LGTM |
|
||
@Test | ||
public void testCreateNote() throws Exception { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
Note n = Samples.getNote(client, noteId, PROJECT_ID); | ||
|
||
assertEquals(n.getName(), noteObj.getName()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
...ner-registry/container-analysis/src/test/java/com/example/containeranalysis/SamplesTest.java
Show resolved
Hide resolved
Samples.deleteNote(client, noteId, PROJECT_ID); | ||
try { | ||
Samples.getNote(client, noteId, PROJECT_ID); | ||
//above should throw, because note was deleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to have a bunch of check-style violations on it for some reason - can you try running checkstyle on it manually and addressing the issues? mvn checkstyle:check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm that's strange, I'm not seeing any on my end, and Kokoro isn't blocking anything either. Any ideas what might be going on? I'm not too familiar with maven
Samples.getNote(client, noteId, PROJECT_ID); | ||
//above should throw, because note was deleted | ||
fail("note not deleted"); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to catch every Exception - can we only catch the correct error instead?
@@ -0,0 +1,256 @@ | |||
/* | |||
* Copyright 2018 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Google LLC
for all new headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checkstyle plugin seems to enforce using Inc for me. Am I using an outdated version or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the following parent is in your pom:
<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
</parent>
Its should accept Inc.
or LLC
- no punctuation on the second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did have that in my pom, but it looks like LLC works if I update to 1.0.10, so I switched to that instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's weird. We must have some other out of dates in this repo.
|
||
@Test | ||
public void testCreateOccurrence() throws Exception { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove emtpy line
75827cc
to
46dfc79
Compare
46dfc79
to
9690fb7
Compare
Updated the Container Analysis samples for the upcoming beta release.