1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Improve documentation

Signed-off-by: Bastien <bastien.wermeille@gmail.com>
This commit is contained in:
Bastien
2023-11-03 09:56:19 +01:00
committed by Bastien Wermeille
parent 755c16d49c
commit 9d20985c58
2 changed files with 15 additions and 11 deletions

View File

@@ -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

View File

@@ -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