From 071d27cd3db8a8395677431727501ff28997edb8 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 8 May 2025 21:13:20 -0700 Subject: [PATCH] Add contributor guidelines for where to put source code in packages Signed-off-by: Derek McGowan --- CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6335e36478..a756e8d239 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,6 +83,39 @@ contributions, see [the advanced contribution section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in the contributors guide. +### Where to put your changes + +You can make changes to any Go package within Moby outside of the vendor directory. There are no +restrictions on packages but a few guidelines to follow for deciding on making these changes. +When adding new packages, first consider putting them in an internal directory to prevent +unintended importing from other modules. Code changes should either go under `api`, `client`, +or `daemon` modules, or one of the integration test directories. + +Try to put a new package under the appropriate directories. The root directory is reserved for +configuration and build files, no source files will be accepted in the root. + +- `api` - All types shared by client and daemon along with swagger definitions. +- `client` - All Go files for the docker client +- `contrib` - Files, configurations, and packages related to external tools or libraries +- `daemon` - All Go files and packages for building the daemon +- `docs` - All Moby technical documentation using markdown +- `hack` - All scripts used for testing, development, and CI +- `integration` - Testing the integration of the API, client, and daemon +- `integration-cli` - Deprecated integration tests of the docker cli with the daemon, no new tests allowed +- `pkg` - Legacy Go packages used externally, no new packages should be added here +- `project` - All files related to Moby project governance +- `vendor` - Autogenerated vendor files from `make vendor` command, do not manually edit files here + +The daemon module has many subpackages. Consider putting new packages under one of these +directories. + +- `daemon/cmd` - All Go main packages and the packages used only for that main package +- `daemon/internal` - All utility packages used by daemon and not intended for external use +- `daemon/man`- All Moby reference manuals used for the `man` command +- `daemon/plugins` - All included daemon plugins which are intended to be registered via init +- `daemon/pkg` - All libraries used by daemon and for integration testing +- `daemon/version` - Version package with the current daemon version + ### Connect with other Moby Project contributors