From 0eec89a98097748506757cc680034bea9e7a4b82 Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Thu, 23 Apr 2020 16:53:31 +0200 Subject: [PATCH] Add Ansible code formatting documentation This patch addresses reviewers need to point to a standart to follow for Ansible code formatting when contributing to the Airship project. It is expected that when code is submitted, it should have ansible-lint run against it before hand. Later these should be enforced at the gate. Change-Id: I67fdfa118a1cdecf8a5bc5224687366a18d60ee5 --- doc/source/develop/code-conventions.rst | 34 +++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/doc/source/develop/code-conventions.rst b/doc/source/develop/code-conventions.rst index 00b2a17..5d8c5c8 100644 --- a/doc/source/develop/code-conventions.rst +++ b/doc/source/develop/code-conventions.rst @@ -33,7 +33,7 @@ contain subdirectories for each of the charts maintained as part of that project. These subdirectories should be named for the component represented by that chart. -e.g.: For project ``foo``, which also maintains the charts for ``bar`` and +E.g.: For project ``foo``, which also maintains the charts for ``bar`` and ``baz``: - foo/charts/foo contains the chart for ``foo`` @@ -51,7 +51,7 @@ will contain subdirectories for each of the images created as part of that project. The subdirectory will contain the dockerfile that can be used to generate the image. -e.g.: For project ``foo``, which also produces a Docker image for ``bar``: +E.g.: For project ``foo``, which also produces a Docker image for ``bar``: - foo/images/foo contains the dockerfile for ``foo`` - foo/images/bar contains the dockerfile for ``bar`` @@ -106,18 +106,25 @@ readability and maintainability. Known Standards ------------------------------------------------------- Language Tools Used -=============== ====================================== +=============== ====================================== +Ansible ansible-lint Go gofmt Python YAPF, Flake8 =============== ====================================== - -Go Formatting -~~~~~~~~~~~~~~~~~~~ - -Go code should be formatted using gofmt. When using gofmt be sure to use the --s flag to include simplification of code for example:: - - gofmt -s /path/to/file.go + +Ansible formatting +~~~~~~~~~~~~~~~~~~ + +Ansible code should be linted to be conformant to the standards checked +by `ansible-lint`_ project. + +Go Formatting +~~~~~~~~~~~~~~~~~~~ + +Go code should be formatted using gofmt. When using gofmt be sure to use the +-s flag to include simplification of code for example:: + + gofmt -s /path/to/file.go Python PEP-8 Formatting ~~~~~~~~~~~~~~~~~~~~~~~ @@ -155,8 +162,8 @@ flake8-import-order:: Airship components must provide for automated checking of their formatting -standards, such as the lint step noted above in the makefile. Components may -provide automated reformatting. +standards, such as the lint step noted above in the Makefile, and in the future +via CI jobs. Components may provide automated reformatting. YAML Schema ~~~~~~~~~~~ @@ -271,3 +278,4 @@ prevail. .. _Docker: https://www.docker.com/ .. _helm-toolkit: https://git.openstack.org/cgit/openstack/openstack-helm-infra/tree/helm-toolkit .. _Openstack-Helm: https://wiki.openstack.org/wiki/Openstack-helm +.. _ansible-lint: https://github.com/ansible/ansible-lint