A chat application to eventually demonstrate the usefulness of Kubernetes
This chatbot posts to a Chatback application API (see Cloning & Setup below) periodically. The username, message, and the posting intervals can be specified using CLI commands (see CLI Commands).
- Go required version 1.16
- Git
- golangci-lint (Optional) - Used for running lint on your development machine.
- Minikube
- Docker - recommended, can use other container or VM
git clone https://github.com/Project-Reclass/reclass_chatbot.git
minikube start
minikube kubectl -- apply -f https://raw.githubusercontent.com/scottjr632/chatback-k8s-example/main/chatback-remote.yml
minikube service frontend -n chatback
minikube service backend -n chatback
go run main.go
go test ./...
When main.go is run, a new post is created with default parameters. The username is "Reclass Bot," the message is the current time, and the API is posted to every 3 seconds. Note that the time printed in the body of the post and the time written in the post details may be off by a fraction of a second.
The parameters, however, can be specified with CLI commands. The CLI commands are now as follows:
-username="..."
// Sets the username of each post (string)-message="..."
// Sets the message of each post (string)-interval=5
// Sets the wait time for each post OR the upper range for wait times if 'random' is selected (int)-random
// Determines how interval is used (boolean)-preset
// Overrides and sets username, message, interval, and random with presets. Valid inputs include strings Tay, Kunal, Theo, and Scott
This project has 3 CI jobs that run on every push. This jobs can be found in the .github/workflows/ci.yml file.
-
Test: The test jobs run
go test ./...
to run every unit test in the codebase. -
Vet: The Vet job runs the
go vet ./...
on the codebase. Thego vet
command is used to report suspicious constructs and smelly code. More aboutvet
can be read on the golang.org/cmd/vet webpage. -
Lint: The Lint job, like the
vet
command, also checks for smelly code but runs more checks (e.g. are all errors handled?). The Lint job will also provide annotations on pull requests for issues related to new commits.
These CI jobs help to ensure that only good quality code makes it into the codebase. At Project Reclass, each of our code bases has some form of CI setup so being familiar with these is helpful.