This is a list of coding conventions you should observe when contributing code for this project.
Current conventions:
-
module structure
-
adopting the right case type
-
good names for files and terraform objects (resources, variables, outputs)
It is not an exhaustive list and it will be updated as we go. In the mean time, your PR reviewer may suggest conventions that are not listed here.
Use PR comments and the GitHub suggestion feature to agree on the final result.
-
We adhere to the Terraform Standard Module Structure
-
Any nested module calls should be in the main file:
main.tf
is the primary entrypoint of the module -
All variables and ouputs declarations should be in
variables.tf
andoutputs.tf
-
All variables and outputs should have descriptions
-
Nested modules should exist under the
modules/
folder -
Examples of using the module should exist under the
examples/
folder and have a README to explain the goal and usage of the example
We use AsciiDoc with the *.adoc
file extension. The only exception is for the README files that need to be displayed on the Terraform Registry.
ℹ️
|
As GitHub renders AsciiDoc files using AsciiDoctor, it is the current reference regarding AsciiDoc syntax we use in the documentation. |
Terraform Registry currently do not support AsciiDoc,so documentation content such as README
files must be in Markdown format.
For internal links to AsciiDoc file (repo documentation content), we use relative links with the xref:
macro.
xref:CONTRIBUTING.adoc[CONTRIBUTING]
For internal links to non-AsciiDoc file (e.g: README files), we use relative links with the link:
macro.
link:examples/README.md[examples README]
For external links, we use autolinks.
💡
|
If a link is used mutiple times, prefer to add the link in the header with a reference in the format
:uri-repo: https://github.com/oracle-terraform-modules/terraform-oci-compute-instance {uri-repo}[link caption] |
-
Use
snake_case
when naming Terraform files, variables and resources -
If you need a new .tf file at the root of the module for better clarity, use this naming scheme:
<module_name>_<resources_group>
: e.g.vcn_gateways.tf
,vcn_defaultresources.tf
-
If your variable is controlling a behaviour, use imperative style to name it: e.g.
create_internet_gateway
Variables should always be in the format below:
-
description. Add
(Updatable)
at the begining of the description if this value do not triggers a resourcerecreate
) -
type
-
default (if any)
Do not hesitate to insert a brief comment in the variable block if it helps to clarify your intention.
|
No default value for compartment_id or any other variables related to provider authentication in module or examples files. The user will have to explicitly set these values.
|