# README

Notifiers Golang library

This notifiers Go package exposes a lightweight, zero-magic, optional framework for writing new notifiers and extensions.

To write your own notifier using this package, all you need to do is write something that implements the notifiers.Notifier interface and then pass that to notifiers.Main in your Go executable's main method (or wherever). That Main function will set up your notifiers with your config from GCS and your secrets stored on Secret Manager. Feel free to copy the cloudbuild.yaml and Dockerfile in the notifiers that use this package, like http, to build and deploy your own notifier.

In order to filter on specific notifications, you can use the notifiers.EventFilter interface, again, optionally. This library provides two EventFilter implementations:

  • notifiers.CELPredicate: This filter uses a compiled-at-startup CEL program string to filter on incoming notifications. It uses a single input variable named build, which is the incoming Build proto from the Pub/Sub notifications. For example, you can write a filter like build.status == Build.Status.SUCCESS || "special" in build.tags to only notify on events that are successful or have the "special" build tag.

# Functions

AddUTMParams adds UTM campaign tracking parameters to the given Build log URL and returns the new version.
FindSecretResourceName is a helper function that returns the Secret's resource name that is associated with the given local reference name.
GetEnv fetches, logs, and returns the given environment variable.
GetSecretRef is a helper function for getting a Secret's local reference name from the given config.
Main is a function that can be called by `main()` functions in notifier binaries.
MakeCELPredicate returns a CELPredicate for the given filter string of CEL code.

# Constants

ChatMedium is for Build log URLs that are sent over chat applications.
EmailMedium is for Build log URLs that are sent via email.
HTTPMedium is for Build log URLs that are sent over HTTP(S) communication (that does not belong to one of the other mediums).
OtherMedium is for Build log URLs that sent are over a medium that does not correspond to one of the above mediums.
StorageMedium is for Build log URLS that are sent to a storage medium (i.e.

# Structs

BuildView is the data container that contains the build.
CELPredicate is an EventFilter that uses a CEL program to determine if notifications should be sent for a given Pub/Sub message.
Config is the common type for (YAML-based) configuration files for notifications.
Metadata is a KRD-compliant data container used for metadata references.
Notification is the data container for the fields that are relevant to the configuration of sending the notification.
Secret is a data container matching the local name of a secret to its GCP SecretManager resource name.
SecretConfig is the data container used in a Spec.Notification config for referencing a secret in the Spec.Secrets list.
Spec is the data container for the fields that are relevant to the functionality of the notifier.
No description provided by the author
No description provided by the author

# Interfaces

BindingResolver is an object that given a Build and a way to get secrets, returns all bound substitutions from the notifier configuration.
EventFilter is a type that can be used to filter Builds for notifications.
Notifier is the interface type that users should implement for usage in Cloud Build notifiers.
SecretGetter allows for fetching secrets from some key store.

# Type aliases

UTMMedium is an enum that corresponds to a strict set of values for `utm_medium`.