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.
-
Lib: A Go library, a human-readable SDK. Its code is automatically generated.
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.
See cli/RUNNING.md
To add a new API spec, see ADD_NEW_API.md
.
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:
- On
commit-msg
for all commits:- Conventional commit pattern with commitzen
- On
pre-commit
for Go files:- Complete set of golangci-lint:
errcheck
,gosimple
,govet
,ineffasign
,staticcheck
,unused
- Complete set of golangci-lint:
- On
pre-commit
for Python files:flake8
andblack
enforcing pep code styles
brew 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