This document describes the high-level architecture of Octopilot. If you want to familiarize yourself with the code base, you are just in the right place!
There are 2 main packages:
update
: the updaters that change content in the git repositoriesrepository
: everything related to working with git repositories hosted on GitHub: cloning, commits, creating branches, pushing, creating/updating/merging pull requests, and so on.
The main.go
file contains the main entry point, which:
- defines all the CLI flags
- parses the updaters and the repositories
- updates all the repositories in parallel
Everything related to working to git repositories hosted on GitHub is in the repository
package:
repository.go
: the definition of a repository, and how to parse one from a command line argumentstrategy_*.go
: the implementation of the different strategies for updating a repositoryoptions.go
: definition of the options exposed by the CLI flagsgit.go
: set of functions to work with git repositories: clone, commit, push, ...pull_request.go
: find, create, update and merge a pull requesttemplate.go
: definition and execution of the (golang) templates used to generate the commit and pull request title/body
The updaters, which change content in the git repositories, are defined in the update
package: 1 package for each updater. Each updater is mainly defined by an Update
function, which operates on a repository.
Note that an updater's Update
function may be called by multiple goroutines at the same time - from multiple repositories - so it must be "thread-safe".
If you want to add an updater, you'll need to:
- add a new package in the
update
directory - update the
updater/updater.go
file to register your new package/updater
There are a few small internal packages, in the internal
directory - using the Go convention that makes these packages private by default:
git
: provides helper functions to work with Git repository - and mainly its configuration.parameters
: provides functions to work with "parameters": key-value maps.