Skip to content

Commit 07657fb

Browse files
authored
Merge pull request #237 from dafyddj/fix/rst-underlines
fix(convert-formula.sh): fix reST underlining during conversion
2 parents 1b8604d + 80ed8cd commit 07657fb

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

.gitlab-ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# `image`
1616
image_commitlint: &image_commitlint 'myii/ssf-commitlint:11'
1717
image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3'
18-
image_dindrubybionic: &image_dindrubybionic 'myii/ssf-dind-ruby-bionic:1_2.5.1'
18+
image_dindrubybionic: &image_dindrubybionic 'myii/ssf-dind-ruby-bionic:2.7.1-1bbox1'
1919
image_precommit: &image_precommit
2020
name: 'myii/ssf-pre-commit:2.9.2'
2121
entrypoint: ['/bin/bash', '-c']
@@ -142,7 +142,9 @@ rubocop:
142142
# TODO: This should work from the env vars above automatically
143143
- 'bundle config set path "${BUNDLE_CACHE_PATH}"'
144144
- 'bundle config set without "${BUNDLE_WITHOUT}"'
145-
- 'bundle install'
145+
- 'bundle update --bundler --conservative'
146+
- 'bundle binstubs bundler --force'
147+
- 'PATH=./bin:"$PATH" bundle install'
146148
script:
147149
- 'bin/kitchen verify default-debian-11-master-py3'
148150
# REMOVEME>

bin/convert-formula.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ sedi() {
2525
fi
2626
}
2727

28+
repeat_char() {
29+
printf %"${NEW_NAME_LENGTH}"s | tr " " "$1"
30+
}
31+
2832
args() {
2933
if [ $# -ne 1 ]; then
3034
usage
3135
exit 1
3236
fi
3337
NEW_NAME=$1
3438
NEW_NAME_PYSAFE=$(echo "$NEW_NAME" | sed 's/-/__/g')
39+
NEW_NAME_LENGTH=${#NEW_NAME}
3540
if echo "$NEW_NAME" | grep -E --quiet --invert-match '^[a-z0-9_-]+$'; then
3641
usage
3742
exit 1
@@ -78,6 +83,17 @@ convert_formula() {
7883
sedi "/^\( \)TEMPLATE\(:\)$/s//\1${NEW_NAME_PYSAFE}\2/" "$filename"
7984
done
8085

86+
# Where a section heading contains TEMPLATE, ensure the length of underlining
87+
# on the following line matches the length of the new formula name
88+
sedi "/TEMPLATE/{
89+
n
90+
s/========/$(repeat_char =)/
91+
s/--------/$(repeat_char -)/
92+
s/\^^^^^^^^/$(repeat_char ^)/
93+
s/\~~~~~~~~/$(repeat_char \~)/"'
94+
s/""""""""/'"$(repeat_char \")/
95+
}" docs/README.rst docs/map.jinja.rst
96+
8197
# Replace all other instances of TEMPLATE with the regular new formula name
8298
grep --recursive --files-with-matches --exclude-dir=.git TEMPLATE . \
8399
| while read -r filename; do

docs/map.jinja.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For this example, I'll define 2 kinds of `fileserver`_ sources:
3737

3838

3939
Configure the fileserver backends
40-
`````````````````````````````````
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4141

4242
I configure the `fileserver`_ backends to serve:
4343

@@ -73,7 +73,7 @@ Create the file ``/etc/salt/master.d/fileserver.conf`` and restart the ``master`
7373
7474
7575
Create per DNS configuration for ``TEMPLATE`` formula
76-
`````````````````````````````````````````````````````
76+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7777

7878
Now, we can provides the per DNS domain name configuration files for the ``TEMPLATE`` formulas under ``/srv/salt/TEMPLATE/parameters/``.
7979

@@ -104,7 +104,7 @@ We create another configuration for the DNS domain ``example.com`` in the Jinja
104104
105105
106106
Create per role configuration for ``TEMPLATE`` formula
107-
``````````````````````````````````````````````````````
107+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108108

109109
Now, we can provides the per role configuration files for the ``TEMPLATE`` formulas under ``/srv/salt/TEMPLATE/parameters/``.
110110

@@ -139,7 +139,7 @@ We create another configuration for the role ``TEMPLATE/client`` in ``/srv/salt/
139139
140140
141141
Enable roles and the ``dns:domain`` and ``domain`` grains for ``map.jinja``
142-
```````````````````````````````````````````````````````````````````````````
142+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143143

144144
We need to redefine the sources for ``map.jinja`` to load values from our new configuration files, we provide a global configuration for all our minions.
145145

@@ -177,7 +177,7 @@ The syntax is explained later at `Sources of configuration values`_.
177177

178178

179179
Bind roles to minions
180-
`````````````````````
180+
~~~~~~~~~~~~~~~~~~~~~
181181

182182
We associate roles `grains`_ to minion using `grains.append`_.
183183

@@ -198,7 +198,7 @@ For the clients:
198198
Since we used ``Y:C@roles``, ``map.jinja`` will do a ``salt['config.get']('roles')`` to retrieve the roles so you could use any other method to bind roles to minions (`pillars`_ or `SDB`_) but `grains`_ seems to be the preferred method.
199199

200200
Note for Microsoft Windows systems
201-
``````````````````````````````````
201+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202202

203203
If you have a minion running under windows, you can't use colon ``:`` as a delimiter for grain path query (see `bug 58726`_) in which case you should use an alternate delimiter:
204204

@@ -265,7 +265,7 @@ Here is a valid example:
265265
266266
267267
Using Jinja2 YAML template
268-
``````````````````````````
268+
~~~~~~~~~~~~~~~~~~~~~~~~~~
269269

270270
You can provide a Jinja2 YAML template file with a name suffixed with ``.yaml.jinja``, it must produce a YAML file conform to the `Format of configuration YAML files`_, for example:
271271

@@ -296,7 +296,7 @@ For the values loaded from YAML files, ``map.jinja`` will automatically try to l
296296
After loading values from all sources, it will try to include the ``salt://parameters/post-map.jinja`` Jinja file if it exists which can post-process the ``mapdata`` variable.
297297

298298
Configuring ``map.jinja`` sources
299-
`````````````````````````````````
299+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300300

301301
The ``map.jinja`` file uses several sources where to lookup parameter values. The list of sources can be configured in two places:
302302

@@ -373,7 +373,7 @@ This is strictly equivalent to the following ``map_jinja.yaml.jinja``:
373373
374374
375375
Loading values from the configuration sources
376-
`````````````````````````````````````````````
376+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
377377

378378
For each configuration source defined, ``map.jinja`` will:
379379

@@ -399,7 +399,7 @@ There will be no error if a YAML or Jinja2 file does not exists, they are all op
399399

400400

401401
Configuration values from ``salt['config.get']``
402-
````````````````````````````````````````````````
402+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403403

404404
For sources with of type ``C`` declared in ``map_jinja:sources``, you can configure the ``merge`` option of `salt['config.get']`_ by defining per formula ``strategy`` configuration key (retrieved with ``salt['config.get'](tplroot ~ ':strategy')`` with one of the following values:
405405

@@ -410,7 +410,7 @@ By default, no merging is done, the first value found is returned.
410410

411411

412412
Global view of the order of preferences
413-
```````````````````````````````````````
413+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
414414

415415
To summarise, here is a complete example of the load order of formula configuration values for an ``AMD64`` ``Ubuntu 18.04`` minion named ``minion1.example.net`` for the ``libvirt`` formula:
416416

0 commit comments

Comments
 (0)