-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: extract python library, write a notifier that uses it (#3)
* Created a new notifier: `release-auto-promoter` advances releases by creating rollouts for the next target in a release pipeline when the previous succeeded. * Extracted a python library to simplify the process of building a notifier. * bugfixes and various additions across the terraform modules.
- Loading branch information
1 parent
9f6cc03
commit 94e8619
Showing
38 changed files
with
2,934 additions
and
1,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] - Jan 31, 2022 | ||
|
||
### Added | ||
|
||
- Everything. This is the initial repo contents. | ||
- Created 2 new notifiers: `echo-fastapi` demonstrates the basics of how to build a notifier using fastapi. `release-auto-promoter` advances releases by creating rollouts for the next target in a release pipeline when the previous succeeded. | ||
- Extracted a python library to simplify the process of building a notifier. | ||
- Created a terraform module (`terraform/cloud-deploy-notification-infra`) for the notification infrastructure needing to be instantiated once on a project that hosts notifiers. | ||
- Created a terraform module (`terraform/cloud-deploy-notifier`) that can manage all infra components of a typical notifier. Both `echo-fastapi` and `release-auto-promoter` though having slightly different infra requirements, are able to use this module to create all necessary resources. | ||
- The `/demo` directory packs both an example application (`nginx-app`) with its release pipeline IaC and a set of configurations in a `terragrunt` directory. The `terragrunt.hcl` configurations wire together and call the various terraform modules thorughout this repo, showing how all the components relate and can be deployed as separate units. | ||
- `data-samples/` provides 3 example PubSub message payloads so devs can quickly understand the payloads we're working with. | ||
- `.devcontainer` provides configurations for developing this project within a reproducable containerized environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
demo/terragrunt/release-auto-promoter-notifier/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
include { | ||
path = find_in_parent_folders("terragrunt.hcl") | ||
} | ||
|
||
terraform { | ||
# TODO(bjb): switch to a tag ref | ||
# source = "github.com/computeclub/gcp-cloud-deploy-notifiers//terraform/cloud-deploy-notifier?ref=main" | ||
source = "${find_in_parent_folders("gcp-cloud-deploy-notifiers")}//terraform/cloud-deploy-notifier" | ||
before_hook "before_hook" { | ||
commands = ["apply"] | ||
execute = [ | ||
"gcloud", | ||
"builds", | ||
"submit", | ||
"--config=${local.notifier_path}/cloudbuild.yaml", | ||
"--project=${local.config.locals.project_id}", | ||
"--substitutions=_REGISTRY_REPO_URL=${dependency.cloud_deploy_foundation.outputs.artifact_registry_repo_endpoint}", | ||
"${local.notifier_path}/" | ||
] | ||
} | ||
} | ||
|
||
locals { | ||
config = read_terragrunt_config(find_in_parent_folders("config.hcl")) | ||
notifier_path = "${find_in_parent_folders("gcp-cloud-deploy-notifiers")}/notifiers/release-auto-promoter" | ||
} | ||
|
||
dependency "cloud_deploy_foundation" { | ||
config_path = "${find_in_parent_folders("terragrunt")}/cloud-deploy-foundation" | ||
mock_outputs = { | ||
artifact_registry_repo = { | ||
location = "foo" | ||
name = "bar" | ||
format = "docker" | ||
project = "my-project-id" | ||
} | ||
cloud_deploy_pubsub_topics = { | ||
clouddeploy-resources = {} | ||
clouddeploy-operations = {} | ||
clouddeploy-approvals = {} | ||
} | ||
} | ||
} | ||
|
||
inputs = { | ||
artifact_registry_repo = dependency.cloud_deploy_foundation.outputs.artifact_registry_repo | ||
cloud_deploy_notification_subscriptions = [ | ||
{ | ||
topic = "clouddeploy-operations" | ||
filter = "attributes.Action = \"Succeed\" AND attributes.ResourceType = \"Rollout\"" | ||
}, | ||
] | ||
env_vars = [ | ||
{ | ||
name = "LOG_LEVEL" | ||
value = "INFO" | ||
}, | ||
{ | ||
name = "SRC_SHA1" | ||
value = sha1( | ||
join( | ||
"", | ||
[ | ||
for f in fileset( | ||
"${local.notifier_path}/", | ||
"**" | ||
) : filesha1("${local.notifier_path}/${f}") | ||
] | ||
) | ||
) | ||
}, | ||
] | ||
notifier_name = "release-auto-promoter" | ||
project_id = local.config.locals.project_id | ||
region = "us-central1" | ||
workload_sa_project_roles = [ | ||
"roles/clouddeploy.releaser", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# python-notifier | ||
|
||
A Python library to simplify building a Cloud Deploy notifier. This optional | ||
library provides a base class `BaseNotifier` with an `action()` method needing | ||
to be implemented by inheriting classes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
class UnknownMessageType(Exception): | ||
pass | ||
|
||
|
||
class UnkownPipeline(Exception): | ||
pass |
25 changes: 3 additions & 22 deletions
25
notifiers/echo-fastapi/src/config.py → ...tifier/clouddeploy_notifier/log_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.