Table of Contents
Ensure that build, release, test, and cluster-management scripts run on macOS
Know and avoid Go landmines
Comment your code.
Command-line flags should use dashes, not underscores
Please consider package name when selecting an interface name, and avoid redundancy.
storage.Interfaceis better than
Do not use uppercase characters, underscores, or dashes in package names.
Please consider parent directory name when choosing a package name.
package fooline should match the name of the directory in which the .go file exists.
Locks should be called
lock and should never be embedded (always
sync.Mutex). When multiple locks are present, give each lock a distinct name
following Go conventions -
All new packages and most new significant functionality must come with unit tests
Table-driven tests are preferred for testing multiple scenarios/inputs; for example, see TestNamespaceAuthorization
Significant features should come with integration (test/integration) and/or end-to-end (test/e2e) tests
Unit tests must pass on macOS and Windows platforms - if you use Linux specific features, your test case must either be skipped on windows or compiled out (skipped is better when running Linux specific commands, compiled out is required when your code does not compile on Windows).
Avoid relying on Docker hub (e.g. pull from Docker hub). Use gcr.io instead.
Avoid waiting for a short amount of time (or without waiting) and expect an asynchronous thing to happen (e.g. wait for 1 seconds and expect a Pod to be running). Wait and retry instead.
See the testing guide for additional testing advice.
Avoid package sprawl. Find an appropriate subdirectory for new packages. (See #4851 for discussion.)
Avoid general utility packages. Packages called “util” are suspect. Instead, derive a name that describes your desired function. For example, the utility functions dealing with waiting for operations are in the “wait” package and include functionality like Poll. So the full name is wait.Poll
All filenames should be lowercase
Go source files and directories use underscores, not dashes
Document directories and filenames should use dashes rather than underscores
Contrived examples that illustrate system features belong in /docs/user-guide or /docs/admin, depending on whether it is a feature primarily intended for users that deploy applications or cluster administrators, respectively. Actual application examples belong in /examples.
Other third-party code belongs in
Third-party code must include licenses
This includes modified third-party code and excerpts, as well