This repository contains the monorepo developed for Magalu Cloud (MGC). Each subdirectory within mgc/ corresponds to a Go module:
Core: Definition of data types used for the intermediate structure generated by the SDK after parsing either an OpenAPI spec or a static definition.
SDK: Implement the concrete data types defined by core to generate usable commands. The commands can be used by the CLI via Cobra commands, or by Terraform Plugin Provider to perform CRUD on resources.
CLI: Go CLI, using Cobra, with commands and actions defined by the SDK. The commands can either come from dynamic loaded OpenAPI spec or static modules, i.e: authentication.
Our code is written in Golang, however there are some utility scripts written in Python as well.
Looking for Terraform code? Check out the Terraform provider repository
To run the project, the main dependency needed is Go. To install, visit the official link with the instructions.
There are some utility scripts written in Python. For this, Poetry is used. Check Poetry.md for instructions.
Building needs goreleaser and can be done using Makefile targets.
If you have API spec changes, update them on specs, on the corresponding product and run the following commands:
$ make prepare-specs
$ make downgrade-specs
$ make refresh-specs
After that (or if there are no further spec changes), build the CLI with:
$ make build-local
If all goes well, the output binary will be a platform-dependent directory, where it can be run:
$ cd dist/mgc_<your_platform>
$ ./mgc
To add a new API spec, see instructions.
Manually written APIs should be added to mgc/sdk/static, follow the
structure in the exiting modules (auth, config).
We use pre-commit to install git hooks and enforce lint, formatting, tests, commit messages and others. This tool depends on Python as well. On pre-commit we enforce:
commit-msg for all commits:pre-commit for Go files:errcheck,
gosimple, govet, ineffasign, staticcheck, unusedpre-commit for Python files:flake8 and black enforcing pep code stylesbrew install pre-commit
pip install pre-commit
For other types of installation, check their official doc.
After installing, the developer must configure the git hooks inside its clone:
pre-commit install
We install the go linters via pre-commit, so it is automatically run by the
pre-commit git hook. However, if one wants to run standalone it can be done via:
pre-commit run golangci-lint
Run pre-commit without any file modified:
pre-commit run -a
$ claude mcp add magalu \
-- python -m otcore.mcp_server <graph>