Skip to content

Commit

Permalink
script: add sweep script and make task
Browse files Browse the repository at this point in the history
  • Loading branch information
joemiller committed Jan 5, 2025
1 parent 5c6240e commit a69a69e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
default: testacc

.PHONY: build
build:
CGO_ENABLED=0 go build -v -trimpath .

.PHONY: lint
lint:
golangci-lint run -v ./...
Expand All @@ -13,4 +17,8 @@ testacc:
generate:
bash ./script/update_openapi_spec
bash ./script/generate
go generate ./...
go generate ./...

.PHONY: sweep
sweep:
bash ./script/sweep
14 changes: 14 additions & 0 deletions script/sweep
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# delete db's older than 24 hours in the test org whose name starts with "testacc"

set -eou pipefail

ORG="${ORG:-planetscale-terraform-testing}"

pscale database list --org "$ORG" --format json |
jq -r '.[] | select(
(.name | startswith("testacc")) and
(.created_at | sub("\\.\\d+"; "") | fromdateiso8601 < (now - 86400))).name' |
while read -r dbname; do
pscale database delete "$dbname" --org "$ORG" --force
done

0 comments on commit a69a69e

Please sign in to comment.