Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion container_registry/container_analysis/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
google-cloud-pubsub==1.7.0
google-cloud-containeranalysis==0.3.1
google-cloud-containeranalysis==1.0.1
grafeas==0.4.1
pytest==5.3.0; python_version > "3.0"
pytest==4.6.6; python_version < "3.0"
Expand Down
12 changes: 6 additions & 6 deletions container_registry/container_analysis/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def delete_note(note_id, project_id):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
note_name = grafeas_client.note_path(project_id, note_id)
note_name = f"projects/{project_id}/notes/{note_id}"

grafeas_client.delete_note(note_name)
# [END containeranalysis_delete_note]
Expand All @@ -77,7 +77,7 @@ def create_occurrence(resource_url, note_id, occurrence_project, note_project):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
formatted_note = grafeas_client.note_path(note_project, note_id)
formatted_note = f"projects/{note_project}/notes/{note_id}"
formatted_project = grafeas_client.project_path(occurrence_project)

occurrence = {
Expand Down Expand Up @@ -113,7 +113,7 @@ def delete_occurrence(occurrence_id, project_id):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
parent = grafeas_client.occurrence_path(project_id, occurrence_id)
parent = f"projects/{project_id}/occurrences/{occurrence_id}"
grafeas_client.delete_occurrence(parent)
# [END containeranalysis_delete_occurrence]

Expand All @@ -128,7 +128,7 @@ def get_note(note_id, project_id):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
note_name = grafeas_client.note_path(project_id, note_id)
note_name = f"projects/{project_id}/notes/{note_id}"
response = grafeas_client.get_note(note_name)
return response
# [END containeranalysis_get_note]
Expand All @@ -144,7 +144,7 @@ def get_occurrence(occurrence_id, project_id):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
parent = grafeas_client.occurrence_path(project_id, occurrence_id)
parent = f"projects/{project_id}/occurrences/{occurrence_id}"
return grafeas_client.get_occurrence(parent)
# [END containeranalysis_get_occurrence]

Expand Down Expand Up @@ -181,7 +181,7 @@ def get_occurrences_for_note(note_id, project_id):

client = containeranalysis_v1.ContainerAnalysisClient()
grafeas_client = client.get_grafeas_client()
note_name = grafeas_client.note_path(project_id, note_id)
note_name = f"projects/{project_id}/notes/{note_id}"

response = grafeas_client.list_note_occurrences(note_name)
count = 0
Expand Down
4 changes: 2 additions & 2 deletions container_registry/container_analysis/samples_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_poll_discovery_occurrence(self):
grafeas_client.\
create_note(grafeas_client.project_path(PROJECT_ID), note_id, note)
occurrence = {
'note_name': grafeas_client.note_path(PROJECT_ID, note_id),
'note_name': f"projects/{PROJECT_ID}/notes/{note_id}",
'resource_uri': self.image_url,
'discovery': {
'analysis_status': DiscoveryOccurrence.AnalysisStatus
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_find_high_severity_vulnerabilities(self):
grafeas_client.\
create_note(grafeas_client.project_path(PROJECT_ID), note_id, note)
occurrence = {
'note_name': client.note_path(PROJECT_ID, note_id),
'note_name': f"projects/{PROJECT_ID}/notes/{note_id}",
'resource_uri': self.image_url,
'vulnerability': {
'effective_severity': Severity.CRITICAL,
Expand Down