Skip to content

About

Proactively encouraging cloud.gov customers to restage their apps so they can benefit from buildpack updates.

Resources

Contributing

Security policy

Stars

4 stars

Watchers

10 watching

Forks

Repository files navigation

buildpack-notify

Encouraging cloud foundry customers to restage their apps so they can benefit from buildpack updates.


Notification logic

The application will look at all the system buildpacks (i.e., result of cf buildpacks) and look at the time stamp of when each buildpack was last updated. It will find all the applications using the system buildpacks and compare the current droplet creation time with the buildpack update time. If the current droplet predates the buildpack update, it will queue all the space managers and space developers to receive an e-mail about that application. To prevent users from receiving multiple e-mails, all the applications in violation are grouped per user so that the user receives one e-mail notifying them about all the applications instead of an e-mail per application. After the notifications are sent out, the buildpack version metadata (GUID and last updated time) is stored in the state. By storing that data, notifications won't be sent out again when the cron job runs unless the buildpack is updated by system admins again.

Credentials

Email:

  • SMTP_FROM: The email-address that will be in the From field in the e-mail. e.g. test@example.com or Me <test@example.com>
  • SMTP_HOST: The SMTP host to authenticate with. e.g. smtp.host.com
  • SMTP_PASSWORD: The password to authenticate with. e.g. somepassword
  • SMTP_PORT: The SMTP port to connect to. e.g. 587
  • SMTP_USER: The username to authenticate with. e.g. someuser@example.com

CF API:

The client mentioned above should be created with the following attributes:

  • authorities: cloud_controller.global_auditor
  • authorized_grant_types: client_credentials

An example of creating the client with uaac can be seen below for local purposes but it is recommended that you add the client to your Cloud Foundry deployment YAML for production.

Development

Requirements

  • Go v1.17+
  • PCFDev (optional)
  • Docker & Docker-Compose (for integration tests)

Setup

  1. Download Go dependencies
go get
  1. Setup UAA Client on PCFDev's UAA
uaac target https://uaa.local.pcfdev.io --skip-ssl-validation && \
uaac token client get admin -s "admin-client-secret" && \
uaac client delete buildpack-notify; \
uaac client add buildpack-notify \
--authorities="cloud_controller.global_auditor" \
--authorized_grant_types "client_credentials" -s "notarealsecret"

Unit Tests

You can run tests with: go test. Template tests compare test output against pre-rendered templates that are included in version control. To update pre-rendered templates, run tests with OVERRIDE_TEMPLATES=1.

Integration Tests

These tests provide a good idea of how everything will work once in use. You should run these before pushing your code upstream.

Integration Tests can be found in the integration folder

If you want to run it locally with pcfdev and docker, create an empty starting state file printf '{}' > /tmp/buildpack-notify-state.json && docker-compose up -d && TEST_PASS="notarealpass" SMTP_FROM="no-reply@cloud.gov" SMTP_PASSWORD="" SMTP_PORT="2525" SMTP_USER="" SMTP_HOST="localhost" CF_API="https://api.local.pcfdev.io" CLIENT_ID="buildpack-notify" CLIENT_SECRET="notarealsecret" IN_STATE="/tmp/buildpack-notify-state.json" OUT_STATE="/tmp/buildpack-notify-state-out.json" CF_USER="admin" CF_PASS="admin" CF_API_SSL_FLAG="--skip-ssl-validation" ./integration/test.sh

You can check out the e-mail by navigating to http://localhost:8025

Next steps: Run this after deploy to each environment instead of locally.


Contributing

See CONTRIBUTING for additional information.

Public domain

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

About

Proactively encouraging cloud.gov customers to restage their apps so they can benefit from buildpack updates.

Resources

Contributing

Security policy

Stars

4 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages