Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
feat(secretmanager): fixed linter errors for added pub/sub example
Browse files Browse the repository at this point in the history
  • Loading branch information
sigilite committed Jun 23, 2021
1 parent 6afec72 commit 56ecde4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions samples/snippets/consume_event_notification.py
Expand Up @@ -18,12 +18,12 @@

import base64


# [START secretmanager_consume_event_notification]
def consume_event_notification(event, unused_context):
"""
consume_event_notification demonstrates how to consume and process a
Pub/Sub notification from Secret Manager.
Args:
event (dict): Event payload.
unused_context (google.cloud.functions.Context): Metadata for the event.
Expand All @@ -32,4 +32,4 @@ def consume_event_notification(event, unused_context):
secret_id = event['attributes']['secretId']
secret_metadata = base64.b64decode(event['data']).decode('utf-8')
return 'Received {} for {}. New metadata: {}'.format(event_type, secret_id, secret_metadata)
# [END secretmanager_consume_event_notification]
# [END secretmanager_consume_event_notification]
3 changes: 2 additions & 1 deletion samples/snippets/snippets_test.py
Expand Up @@ -11,9 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

import base64
import os
import uuid
import base64

from google.api_core import exceptions
from google.cloud import secretmanager
Expand Down Expand Up @@ -207,6 +207,7 @@ def test_update_secret(secret):
secret = update_secret(project_id, secret_id)
assert secret.labels["secretmanager"] == "rocks"


def test_consume_event_notification(pubsub_message):
got = consume_event_notification(pubsub_message, None)
assert got == "Received SECRET_UPDATE for projects/p/secrets/s. New metadata: hello!"

0 comments on commit 56ecde4

Please sign in to comment.