Collie is an internal devops tool to help with cluster maintenance.
This app is built in Go to help with some of the random devops tasks we need to do for maintaining clusters.
Some things this app does:
- format branch names into a k8s compatible format
- connect to a postgresql server and clean up dead databases
- compare PullRequest branches with active namespaces and delete ones where the prs have been closed.
- Comment on PullRequests
To get a local copy up and running follow these simple steps.
You will need go installed. Either download from golang or use winget.
winget install GoLang.Go -v 1.16.6-
Clone the repo
git clone https://bitbucket.org/centeva/Collie.git
-
Install go modules (not required but will cache modules)
go mod download
Go does not have an IDE. Most people either use VSCode or Vim. JetBrains also offers GoLand.
For VSCode there is an extension called golang.go that you need to install. Also run >go.tools.install and select all 10 of the tools in the list. These are tools the extension uses to check lint, build, etc. By installing them all now we avoid annoying popup notifications.
You can use this tool with docker or manually.
Running go build will create a collie.exe that you can then run manually. This will work locally but this exe is not cross platform.
You can build the dockerfile locally with docker build . -t collie:latest. Then run with docker run -it collie:latest --CleanBranch="feature/UNI-1234-test"
Test commands should be ran from the lib directory. Go has several commands for testing. Test files in Go are appended with _test.go. Inside test files a test func must begin with Test. Go also has Benchmark tests built in. A benchmark func must begin with Benchmark. Benchmarks are useful to see how a change affects performance.
go test: Runs all tests.go test -cover: Runs all tests and gives coverage.go test -bench .: Runs all benchmarks.