Skip to content

Commit a4a95d6

Browse files
authored
Merge pull request #357 from miharp/cleanup/markdownlint-openvox-manual
Finish _openvox_8x markdownlint cleanup and enforce repo-wide
2 parents a28e3a2 + c8a0807 commit a4a95d6

120 files changed

Lines changed: 1457 additions & 1211 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/markdownlint.yml

Lines changed: 13 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,20 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v7
19-
with:
20-
fetch-depth: 0 # required to resolve base.sha for PR diff comparison
21-
- name: Find changed Markdown files
22-
id: changed-markdown
19+
- name: List tracked Markdown files
20+
id: tracked-markdown
2321
shell: bash
22+
# Lint git-tracked files only. This lints the canonical versioned dirs
23+
# once and skips the `_latest` symlinks (git stores them as single
24+
# symlink entries, so a filesystem glob would double-lint their targets).
25+
# It also excludes generated reference docs, which are gitignored.
2426
run: |
25-
case "${GITHUB_EVENT_NAME}" in
26-
pull_request)
27-
base_sha="${{ github.event.pull_request.base.sha }}"
28-
head_sha="${GITHUB_SHA}"
29-
;;
30-
push)
31-
base_sha="${{ github.event.before }}"
32-
head_sha="${GITHUB_SHA}"
33-
;;
34-
*)
35-
# workflow_dispatch: lints only files changed in the most recent commit, not the full branch
36-
# || true handles initial commits with no parent
37-
base_sha="$(git rev-parse "${GITHUB_SHA}^" 2>/dev/null || true)"
38-
head_sha="${GITHUB_SHA}"
39-
;;
40-
esac
41-
42-
if [[ -z "${base_sha}" || "${base_sha}" =~ ^0+$ ]]; then
43-
base_sha="$(git rev-list --max-parents=0 "${head_sha}")"
44-
fi
45-
46-
git diff --name-only --diff-filter=A "${base_sha}" "${head_sha}" -- '*.md' '*.markdown' > added-markdown-files.txt
47-
git diff --name-only --diff-filter=CMRT "${base_sha}" "${head_sha}" -- '*.md' '*.markdown' > modified-markdown-files.txt
48-
49-
if [[ -s added-markdown-files.txt ]]; then
50-
echo "has_added=true" >> "${GITHUB_OUTPUT}"
51-
{
52-
echo 'added_files<<EOF'
53-
cat added-markdown-files.txt
54-
echo 'EOF'
55-
} >> "${GITHUB_OUTPUT}"
56-
else
57-
echo "has_added=false" >> "${GITHUB_OUTPUT}"
58-
fi
59-
60-
if [[ -s modified-markdown-files.txt ]]; then
61-
echo "has_modified=true" >> "${GITHUB_OUTPUT}"
62-
{
63-
echo 'modified_files<<EOF'
64-
cat modified-markdown-files.txt
65-
echo 'EOF'
66-
} >> "${GITHUB_OUTPUT}"
67-
else
68-
echo "has_modified=false" >> "${GITHUB_OUTPUT}"
69-
fi
70-
71-
- name: No changed Markdown files
72-
if: steps.changed-markdown.outputs.has_added != 'true' && steps.changed-markdown.outputs.has_modified != 'true'
73-
run: echo "No changed Markdown files to lint."
74-
75-
- name: Lint new Markdown files (enforced)
76-
uses: DavidAnson/markdownlint-cli2-action@v23
77-
if: steps.changed-markdown.outputs.has_added == 'true'
78-
with:
79-
globs: ${{ steps.changed-markdown.outputs.added_files }}
80-
81-
- name: Lint modified Markdown files (advisory)
27+
{
28+
echo 'files<<EOF'
29+
git ls-files '*.md' '*.markdown'
30+
echo 'EOF'
31+
} >> "${GITHUB_OUTPUT}"
32+
- name: Lint tracked Markdown files
8233
uses: DavidAnson/markdownlint-cli2-action@v23
83-
if: steps.changed-markdown.outputs.has_modified == 'true'
84-
continue-on-error: true
8534
with:
86-
globs: ${{ steps.changed-markdown.outputs.modified_files }}
35+
globs: ${{ steps.tracked-markdown.outputs.files }}

docs/_openvox_8x/_environment_conf_settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
In this version of Puppet, the environment.conf file is only allowed to override five settings:
23

34
- `modulepath`

docs/_openvox_8x/_hiera.yaml_v5.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
``` yaml
1+
<!-- markdownlint-disable MD041 -->
2+
```yaml
23
---
34
version: 5
45
defaults: # Used for any hierarchy level that omits these keys.

docs/_openvox_8x/_hiera_context_object.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
## The `Puppet::LookupContext` object
23

34
To support caching and other needs, Hiera provides backends a special `Puppet::LookupContext` object, which has several methods you can call for various effects.
@@ -24,7 +25,7 @@ The following methods are available:
2425

2526
### `not_found()`
2627

27-
[method_not]: #notfound
28+
[method_not]: #not_found
2829

2930
Tells Hiera to move on to the next data source. Call this method when your function can't find a value for a given lookup. **This method does not return.**
3031

@@ -44,13 +45,13 @@ In `lookup_key` and `data_dig` backends, you **must** call this method if you wa
4445

4546
### `environment_name()`
4647

47-
[method_env]: #environmentname
48+
[method_env]: #environment_name
4849

4950
Returns the name of the environment whose hiera.yaml called the function. Returns `undef` (in Puppet) or `nil` (in Ruby) if the function was called by the global or module layer.
5051

5152
### `module_name()`
5253

53-
[method_module]: #modulename
54+
[method_module]: #module_name
5455

5556
Returns the name of the module whose hiera.yaml called the function. Returns `undef` (in Puppet) or `nil` (in Ruby) if the function was called by the global or environment layer.
5657

@@ -62,7 +63,9 @@ Caches a value, in a per-data-source private cache; also returns the cached valu
6263

6364
On future lookups in this data source, you can retrieve values with `cached_value(key)`. Cached values are immutable, but you can replace the value for an existing key. Cache keys can be anything valid as a key for a Ruby hash. (Notably, this means you can use `nil` as a key.)
6465

65-
For example, on its first invocation for a given YAML file, the built-in `eyaml_lookup_key` backend reads the whole file and caches it, and then decrypts only the specific value that was requested. On subsequent lookups into that file, it gets the encrypted value from the cache instead of reading the file from disk again. It also caches decrypted values, so that it won't have to decrypt again if the same key is looked up repeatedly.
66+
For example, on its first invocation for a given YAML file, the built-in `eyaml_lookup_key` backend reads the whole file and caches it, and then decrypts only the specific value that was requested.
67+
On subsequent lookups into that file, it gets the encrypted value from the cache instead of reading the file from disk again.
68+
It also caches decrypted values, so that it won't have to decrypt again if the same key is looked up repeatedly.
6669

6770
The cache is also useful for storing session keys or connection objects for backends that access a network service.
6871

@@ -77,39 +80,39 @@ If any inputs to a function change (for example, a path interpolates a local var
7780

7881
### `cache_all(hash)`
7982

80-
[method_cache_all]: #cacheallhash
83+
[method_cache_all]: #cache_allhash
8184

8285
Caches all the key/value pairs from a given hash; returns `undef` (in Puppet) or `nil` (in Ruby).
8386

8487
### `cached_value(key)`
8588

86-
[method_cached]: #cachedvaluekey
89+
[method_cached]: #cached_valuekey
8790

8891
Returns a previously cached value from the per-data-source private cache. Returns `nil` or `undef` if no value with this name has been cached. See [`cache(key, value)`][method_cache] above for more info about how the cache works.
8992

9093
### `cache_has_key(key)`
9194

92-
[method_haskey]: #cachehaskeykey
95+
[method_haskey]: #cache_has_keykey
9396

9497
Checks whether the cache has a value for a given key yet. Returns `true` or `false`.
9598

9699
### `cached_entries()`
97100

98-
[method_allcached]: #cachedentries
101+
[method_allcached]: #cached_entries
99102

100103
Returns everything in the per-data-source cache, as an iterable object. Note that this iterable object isn't a hash; if you want a hash, you can use `Hash($context.all_cached())` (in the Puppet language) or `Hash[context.all_cached()]` (in Ruby).
101104

102105
### `cached_file_data(path) {|content| ...}`
103106

104-
[method_cached_file]: #cachedfiledatapath-content-
107+
[method_cached_file]: #cached_file_datapath-content-
105108

106109
> **Note:** The header above uses Ruby's block syntax. To call this method in the Puppet language, you would use `cached_file_data(path) |content| { ... }`.
107110
108111
For best performance, use this method to read files in Hiera backends.
109112

110113
Returns the content of the specified file, as a string. If an optional block is provided, it passes the content to the block and returns the block's return value. For example, the built-in JSON backend uses a block to parse JSON and return a hash:
111114

112-
``` ruby
115+
```ruby
113116
context.cached_file_data(path) do |content|
114117
begin
115118
JSON.parse(content)

docs/_openvox_8x/_hiera_options_hash.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
### The options hash
23

34
Hierarchy levels are configured in [hiera.yaml](./hiera_config_yaml_5.html). When calling a backend function, Hiera passes a modified version of that configuration as a hash.
@@ -6,13 +7,13 @@ The options hash contains the following keys:
67

78
* `path` --- The absolute path to a file on disk. Only present if the user set one of the `path`, `paths`, `glob`, or `globs` settings. Hiera ensures the file exists before passing it to the function.
89

9-
> **Note:** If your backend uses data files, use the context object's [`cached_file_data` method][method_cached_file] to read them.
10+
> **Note:** If your backend uses data files, use the context object's [`cached_file_data` method][method_cached_file] to read them. <!-- markdownlint-disable-line MD052 -->
1011
* `uri` --- A URI that your function can use to locate a data source. Only present if the user set `uri` or `uris`. Hiera doesn't verify the URI before passing it to the function.
1112
* Every key from the hierarchy level's `options` setting. In your documentation, make sure to list any options your backend requires or accepts. Note that the `path` and `uri` keys are reserved.
1213

1314
For example: this hierarchy level in hiera.yaml...
1415

15-
``` yaml
16+
```yaml
1617
- name: "Secret data: per-node, per-datacenter, common"
1718
lookup_key: eyaml_lookup_key # eyaml backend
1819
datadir: data
@@ -27,7 +28,7 @@ For example: this hierarchy level in hiera.yaml...
2728
2829
...would result in several different options hashes (depending on the current node's facts, whether the files exist, etc.), but they would all resemble the following:
2930
30-
``` ruby
31+
```ruby
3132
{
3233
'path' => '/etc/puppetlabs/code/environments/production/data/secrets/nodes/web01.example.com.eyaml',
3334
'pkcs7_private_key' => '/etc/puppetlabs/puppet/eyaml/private_key.pkcs7.pem',

docs/_openvox_8x/_naming_variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
[qualified_var]: ./lang_variables.html#accessing-out-of-scope-variables
23

34
Variable names begin with a `$` (dollar sign) and are case-sensitive.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
<!-- markdownlint-disable MD041 -->
12
[node_name_fact]: ./configuration.html#node_name_fact
23
[node_name_value]: ./configuration.html#node_name_value
34

45
> #### Note on Non-Certname Node Names
56
>
6-
> Although it's possible to set something other than the [certname][] as the node name (using either the [`node_name_fact`][node_name_fact] or [`node_name_value`][node_name_value] setting), we don't generally recommend it. It allows you to re-use one node certificate for many nodes, but it reduces security, makes it harder to reliably identify nodes, and can interfere with other features.
7+
> Although it's possible to set something other than the [certname][] as the node name (using either the [`node_name_fact`][node_name_fact] or [`node_name_value`][node_name_value] setting), we don't generally recommend it. <!-- markdownlint-disable-line MD052 -->
8+
> It allows you to re-use one node certificate for many nodes, but it reduces security, makes it harder to reliably identify nodes, and can interfere with other features.
79
>
810
> Setting a non-certname node name is **not officially supported** in Puppet Enterprise.

docs/_openvox_8x/_puppet_types_to_ruby_types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
[boolean]: ./lang_data_boolean.html
23
[undef]: ./lang_data_undef.html
34
[string]: ./lang_data_string.html

docs/_openvox_8x/_registered_oids.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- markdownlint-disable MD041 -->
12
The "ppRegCertExt" OID range contains the following OIDs:
23

34
Numeric ID | Short Name | Descriptive Name

docs/_openvox_8x/bgtm.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ To help plan your module appropriately, consider:
2727
2828
It is standard practice for Puppet users to have 200 or more modules in an environment. Simple is better. Each module in your environment should contain related resources that enable it to accomplish a task. Create multiple modules for more complex needs. The practice of having many small, focused modules promotes code reuse and turns modules into building blocks.
2929

30-
As an example, let's take a look at the [`puppetlabs-puppetdb`](https://forge.puppet.com/puppetlabs/puppetdb) module. This module deals solely with the the setup, configuration, and management of PuppetDB. However, PuppetDB stores its data in a PostgreSQL database. Rather than having the module manage PostgreSQL, the author included the [`puppetlabs-postgresql`](https://forge.puppet.com/puppetlabs/postgresql) module as a dependency, leveraging the postgresql module's classes and resources to build out the right configuration for PuppetDB. Similarly, the `puppetdb-module` needs to manipulate the `puppet.conf` file in order to operate PuppetDB. Instead of having the `puppetdb-module` handle `puppet.conf` changes internally, the author used the [`puppetlabs-inifile`](https://forge.puppet.com/puppetlabs/inifile) module to enable `puppetlabs-puppetdb` to make only the required edits to `puppet.conf`.
30+
As an example, let's take a look at the [`puppetlabs-puppetdb`](https://forge.puppet.com/puppetlabs/puppetdb) module. This module deals solely with the the setup, configuration, and management of PuppetDB. However, PuppetDB stores its data in a PostgreSQL database.
31+
Rather than having the module manage PostgreSQL, the author included the [`puppetlabs-postgresql`](https://forge.puppet.com/puppetlabs/postgresql) module as a dependency, leveraging the postgresql module's classes and resources to build out the right configuration for PuppetDB.
32+
Similarly, the `puppetdb-module` needs to manipulate the `puppet.conf` file in order to operate PuppetDB. Instead of having the `puppetdb-module` handle `puppet.conf` changes internally, the author used the [`puppetlabs-inifile`](https://forge.puppet.com/puppetlabs/inifile) module to enable `puppetlabs-puppetdb` to make only the required edits to `puppet.conf`.
3133

3234
## Structuring your module
3335

@@ -54,7 +56,8 @@ In terms of class structure we recommend the following (more detail below):
5456

5557
#### `module`
5658

57-
The main class of any module must share the name of the module and be located in the `init.pp` file. The name and location of the main module class is extremely important, as it guides the [autoloader](./lang_namespaces.html#autoloader-behavior) behavior. The main class of a module is its interface point and ought to be the only parameterized class if possible. Limiting the parameterized classes to just the main class allows you to control usage of the entire module with the inclusion of a single class. This class should provide sensible defaults so that a user can get going with `include module`.
59+
The main class of any module must share the name of the module and be located in the `init.pp` file. The name and location of the main module class is extremely important, as it guides the [autoloader](./lang_namespaces.html#autoloader-behavior) behavior.
60+
The main class of a module is its interface point and ought to be the only parameterized class if possible. Limiting the parameterized classes to just the main class allows you to control usage of the entire module with the inclusion of a single class. This class should provide sensible defaults so that a user can get going with `include module`.
5861

5962
For instance, the main `ntp` class in the `ntp` module looks like this:
6063

@@ -199,7 +202,8 @@ To maximize the usability of your module, make it flexible by adding parameters.
199202

200203
You must not hardcode data in your modules, and having more parameters is the best alternative. Hardcoding data in your module makes it inflexible, and means your module requires manifest changes to be used in even slightly different circumstances.
201204

202-
Avoid adding parameters that allow you to override templates. When your parameters allow template overrides, users can override your template with a custom template that contains additional hardcoded parameters. Hardcoded parameters in templates inhibits flexibility over time. It is far better to create more parameters and then modify the original template, or have a parameter which accepts an arbitrary chunk of text added to the template, than it is to override the template with a customized one.
205+
Avoid adding parameters that allow you to override templates. When your parameters allow template overrides, users can override your template with a custom template that contains additional hardcoded parameters.
206+
Hardcoded parameters in templates inhibits flexibility over time. It is far better to create more parameters and then modify the original template, or have a parameter which accepts an arbitrary chunk of text added to the template, than it is to override the template with a customized one.
203207

204208
For an example of a module that capitalizes on offering many parameters, please see [puppetlabs-apache](https://forge.puppet.com/puppetlabs/apache).
205209

@@ -313,7 +317,8 @@ We encourage you to publish your modules on the [Puppet Forge](https://forge.pup
313317

314318
Sharing your modules allows other users to write improvements to the modules you make available and contribute them back to you, effectively giving you free improvements to your modules.
315319

316-
Additionally, publishing your modules to the Forge helps foster community among Puppet users, and allows other Puppet community members to download and use your module. If the Puppet community routinely releases and iterates on modules on the Forge, the quality of available modules increases dramatically and gives you access to more modules to download and modify for your own purposes. Details on how to publish modules to the Forge can be found in the [module publishing guide](./modules_publishing.html).
320+
Additionally, publishing your modules to the Forge helps foster community among Puppet users, and allows other Puppet community members to download and use your module.
321+
If the Puppet community routinely releases and iterates on modules on the Forge, the quality of available modules increases dramatically and gives you access to more modules to download and modify for your own purposes. Details on how to publish modules to the Forge can be found in the [module publishing guide](./modules_publishing.html).
317322

318323
## Community Resources
319324

0 commit comments

Comments
 (0)