Browse code

Add contributor guidelines for where to put source code in packages

Signed-off-by: Derek McGowan <derek@mcg.dev>

Derek McGowan authored on 2025/05/09 13:13:20
Showing 1 changed files
... ...
@@ -83,6 +83,39 @@ contributions, see [the advanced contribution
83 83
 section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in
84 84
 the contributors guide.
85 85
 
86
+### Where to put your changes
87
+
88
+You can make changes to any Go package within Moby outside of the vendor directory. There are no
89
+restrictions on packages but a few guidelines to follow for deciding on making these changes.
90
+When adding new packages, first consider putting them in an internal directory to prevent
91
+unintended importing from other modules. Code changes should either go under `api`, `client`,
92
+or `daemon` modules, or one of the integration test directories.
93
+
94
+Try to put a new package under the appropriate directories. The root directory is reserved for
95
+configuration and build files, no source files will be accepted in the root.
96
+
97
+- `api` - All types shared by client and daemon along with swagger definitions.
98
+- `client` - All Go files for the docker client
99
+- `contrib` - Files, configurations, and packages related to external tools or libraries
100
+- `daemon` - All Go files and packages for building the daemon
101
+- `docs` - All Moby technical documentation using markdown
102
+- `hack` - All scripts used for testing, development, and CI
103
+- `integration` - Testing the integration of the API, client, and daemon
104
+- `integration-cli` - Deprecated integration tests of the docker cli with the daemon, no new tests allowed
105
+- `pkg` - Legacy Go packages used externally, no new packages should be added here
106
+- `project` - All files related to Moby project governance
107
+- `vendor` - Autogenerated vendor files from `make vendor` command, do not manually edit files here
108
+
109
+The daemon module has many subpackages. Consider putting new packages under one of these
110
+directories.
111
+
112
+- `daemon/cmd` - All Go main packages and the packages used only for that main package
113
+- `daemon/internal` - All utility packages used by daemon and not intended for external use
114
+- `daemon/man`- All Moby reference manuals used for the `man` command
115
+- `daemon/plugins` - All included daemon plugins which are intended to be registered via init
116
+- `daemon/pkg` - All libraries used by daemon and for integration testing
117
+- `daemon/version` - Version package with the current daemon version
118
+
86 119
 ### Connect with other Moby Project contributors
87 120
 
88 121
 <table class="tg">