From 5dda5ca39c36878616f6b5217033fd2430ecad8d Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 3 Nov 2023 09:56:19 +0100 Subject: [PATCH] Improve documentation Signed-off-by: Bastien --- README.rst | 22 +++++++++++++--------- cmd/sops/main.go | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 491cadbe3d..2393c47e9c 100644 --- a/README.rst +++ b/README.rst @@ -1130,15 +1130,15 @@ Below is an example of publishing to Vault (using token auth with a local dev in Important information on types ------------------------------ -YAML and JSON type extensions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +YAML, JSON, ENV and INI type extensions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SOPS uses the file extension to decide which encryption method to use on the file content. ``YAML``, ``JSON``, ``ENV``, and ``INI`` files are treated as trees of data, and key/values are extracted from the files to only encrypt the leaf values. The tree structure is also used to check the integrity of the file. -Therefore, if a file is encrypted using a specific format, it need to be decrypted +Therefore, if a file is encrypted using a specific format, it needs to be decrypted in the same format. The easiest way to achieve this is to conserve the original file extension after encrypting a file. For example: @@ -1165,11 +1165,14 @@ When operating on stdin, use the ``--input-type`` and ``--output-type`` flags as JSON indentation ~~~~~~~~~~~~~~~~ -``sops`` indent ``SOPS`` files by default using one ``tab``. However, you can change -this default behaviour to use spaces by either using the additional ``--indent=2`` cli option or -by configuring ``.sops.yaml`` with the code below. (value ``0`` is no indentation) +SOPS indents ``JSON`` files by default using one ``tab``. However, you can change +this default behaviour to use ``spaces`` by either using the additional ``--indent=2`` CLI option or +by configuring ``.sops.yaml`` with the code below. + +The special value ``0`` disables indentation, and ``-1`` uses a single tab. .. code:: yaml + stores: json: indent: 2 @@ -1177,11 +1180,12 @@ by configuring ``.sops.yaml`` with the code below. (value ``0`` is no indentatio YAML indentation ~~~~~~~~~~~~~~~~ -``sops`` indent ``YAML`` files by default using 4 spaces. However, you can change -this default behaviour by either using the additional ``--indent=2`` cli option or -by configuring ``.sops.yaml`` with : +SOPS indents ``YAML`` files by default using 4 spaces. However, you can change +this default behaviour by either using the additional ``--indent=2`` CLI option or +by configuring ``.sops.yaml`` with: .. code:: yaml + stores: yaml: indent: 2 diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 3ee3ec0e87..9dfb63e6da 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -706,7 +706,7 @@ func main() { }, cli.IntFlag{ Name: "indent", - Usage: "the number of space to indent YAML encoded file for encryption", + Usage: "the number of spaces to indent YAML or JSON encoded file for encryption", }, cli.BoolFlag{ Name: "verbose", @@ -1087,7 +1087,7 @@ func inputStore(context *cli.Context, path string) common.Store { func outputStore(context *cli.Context, path string) common.Store { storesConf, _ := loadStoresConfig(context, path) - if context.Int("indent") != 0 { + if context.IsSet("indent") { indent := context.Int("indent") storesConf.YAML.Indent = indent storesConf.JSON.Indent = indent