Remove finalizer with patch operation

The kubebuilder documentation on finalizers has the following example code for removing a finalizer from an object. // remove our finalizer from the list and update it. controllerutil.RemoveFinalizer(cronJob, myFinalizerName) if err := r.Update(ctx, cronJob); err != nil { return ctrl.Result{}, err } I found when doing this, if the operation running above this in the Reconcile() function (typically to remove a remote resource from an API) this r.Update() call would return an error like this:...

November 30, 2023

Restrict FROM address with AWS SES domain identities

If you are working with an application that sends email, you’ve probably come across “DKIM” which is cryptographic signing of emails to prevent impersonation of people within an organisation. Unfortunately AWS SES only supports DKIM signing for domain identities - not single-address identities. This means even if your application only sends email from a single address such as contact@example.com - to set up DKIM you need the entire example.com domain verified....

November 9, 2022

Linguist syntax highlighting for Drupal file types

Drupal uses a few unusual file extensions that contain PHP - notably .module, .theme, and .install. GitHub use linguist for language detection. You can configure linguist using a .gitattributes file in your repo. Add a .gitattributes file with the following contents to your Drupal repo: # linguist configuration for syntax highlighting in github UI. *.module linguist-language=PHP *.install linguist-language=PHP *.theme linguist-language=PHP Now your pull requests and source viewer in Github should have PHP syntax highlighting for these file extensions....

November 16, 2021

Strategies for Managing a Fleet of Drupal Projects - DrupalGov, 2020

Running a fleet of Drupal projects presents a lot of challenges and problems to solve. Some things might fly for a handful of projects, but trying to scale that up will send you directly to the seventh circle of Drupal hell. Video

November 26, 2020

Drush 8 Exit Code Workaround

A bug in older versions of drush stop errors bubbling up to shell exit codes. This is problematic if you have a shell script with a sequence of commands that depend on the previous one completing successfully. It also makes detecting failed CI builds, deployments and cronjobs near impossible. Unfortunately I’m stuck using drush8 as Lagoon does not support dynamic drush aliases in newer versions. The bash function below will terminate a script with exit-code 1 if the output piped to it includes exception or error....

October 15, 2020

The ultimate CircleCI config for Terraform pull request workflow

Terraform is an extremely powerful tool, but the out-of-the-box workflow can lead to pitfalls such as forgetting to commit and push changes to manifest and terraform.tfstate files. Use this example CircleCI configuration for a rock-solid pull-request workflow for Terraform projects. The Workflow A project contributor creates a pull request with changes to terraform manifests. CircleCI runs a terraform plan and posts the diff as a comment in the pull request....

July 9, 2020

Faster, smaller, and sanitized MySQL database dumps

Developers often need copies of production data for local development, and standard workflows for getting these dumps have a lot of downsides. Moving SQL dumps around means an increased risk of sensitive data being exposed. Most sanitization methods are a multi-step process. Large databases put strain on slow internet connections. Large databases take way too long to import. The Solution mtk-dump is an extremely powerful replacement for mysqldump. Define your sanitization and minification rules in a simple yaml file, and produce small and safe SQL dumps for development....

April 28, 2020

Force git to use HTTPS

Recently I encountered an issue where a CI tool could not fetch certain dependencies as the SSH key used for cloning the main project did not have access to the other repositories. To work around this, I opted to clone the private dependencies via https, passing the credentials in the URI. The magic to force this without changing composer.json: # Set the COMPOSER_USER and COMPOSER_TOKEN environment variables to a user which has access to clone these repos....

April 28, 2020

Log in to GitHub Docker registry with just a token

I recently worked on a project to push our private docker images to GitHub’s package registry. Our CI only had a GITHUB_TOKEN environment variable set, but docker login requires a username too. Rather than add a new environment variable to the build and an assumption that the username and token had to match, I used this snippet to derive the username from the token and log in to the registry....

April 27, 2020

Get personal Slack tokens from the web interface

I am currently in 5 slack organisations and wanted to automate setting my status across all the orgs simultaneously. Unfortunately Slack have deprecated personal api tokens… You may also be in an environment where slack apps are tightly controlled. Don’t lose hope though - with a bit of l33t h4x0ring you can get a personal bearer token from the web UI! Log into slack in a browser with devtools available (a URL like https://your-org....

April 17, 2020