Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

feat: Add native containers support #23

Merged
merged 7 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/generate-docs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"show_toc": false,
"examples_as_yaml": "true",
"custom_template_path": ".github/generate-docs/templates/github/base.md",
"template_md_options": {
"badge_as_image": true,
"show_heading_numbers": false,
"show_array_restrictions": false
}
}
7 changes: 7 additions & 0 deletions .github/generate-docs/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Clear existing documentation
rm -f docs/variables/*.md

# Generate variable documentation
generate-schema-doc --config-file ./.github/generate-docs/config.json defaults/schemas docs/variables/
16 changes: 16 additions & 0 deletions .github/generate-docs/templates/github/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% set depth = 0 %}
{{ schema.keywords.get("title").literal | default("Schema Docs") | md_heading(depth) }}
{% set contentBase %}
{% with schema=schema, skip_headers=False, depth=depth %}
{% include "content.md" %}
{% endwith %}
{% endset %}

{{ md_get_toc() }}

{{ contentBase }}

----------------------------------------------------------------------------------------------------------------------------
{% if config.with_footer -%}
Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans){% if config.footer_show_time %} on {{ get_local_time() }}{% endif %}
{%- endif -%}
9 changes: 9 additions & 0 deletions .github/generate-docs/templates/github/breadcrumbs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% filter md_escape_for_table %}
{%- if config.show_breadcrumbs %}
{%- for node in schema.nodes_from_root -%}
{{ node.name_for_breadcrumbs }}{%- if not loop.last %} > {% endif -%}
{%- endfor -%}
{%- else -%}
{{- schema.property_name -}}
{% endif %}
{% endfilter %}
92 changes: 92 additions & 0 deletions .github/generate-docs/templates/github/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{#
content is a template and not a macro in md
because macro parameters are not through context
when rendering a template from the macro and it caused
serious problems when using recursive calls
mandatory context parameters:
schema
#}
{# context parameters default values #}
{% set skip_headers = skip_headers or False %}
{% set depth = depth or 0 %}
{# end context parameters #}

{% set keys = schema.keywords %}
{%- if not skip_headers %}

{% if schema.title and schema.title | length > 0 %}
**Title:** {{ schema.title }}
{% endif %}

{% set description = (schema | get_description) %}
{% include "section_description.md" %}
{% endif %}

{% if schema.should_be_a_link(config) %}
{% elif schema.refers_to -%}
{%- with schema=schema.refers_to_merged, skip_headers=True, depth=depth -%}
{% include "content.md" %}
{% endwith %}
{% else %}
{# Display examples #}
{% set examples = schema.examples %}
{% if examples %}
{% include "section_examples.md" %}
{% endif %}

{# Properties, pattern properties, additional properties #}
{% if schema.type_name == "object" %}
{{- schema | md_properties_table | md_generate_table -}}
{% endif %}

{# Combining: allOf, anyOf, oneOf, not #}
{% if schema.kw_all_of %}
{% with operator="allOf", title="All of(Requirement)", current_node=schema.kw_all_of, skip_required=True %}
{% include "tabbed_section.md" %}
{% endwith %}
{% endif %}
{% if schema.kw_any_of %}
{% with operator="anyOf", title="Any of(Option)", current_node=schema.kw_any_of, skip_required=True %}
{% include "tabbed_section.md" %}
{% endwith %}
{% endif %}
{% if schema.kw_one_of %}
{% with operator="oneOf", title="One of(Option)",current_node=schema.kw_one_of, skip_required=True %}
{% include "tabbed_section.md" %}
{% endwith %}
{% endif %}
{% if schema.kw_not %}
{% include "section_not.md" %}
{% endif %}

{# Enum and const #}
{% if schema.kw_enum -%}
{% include "section_one_of.md" %}
{%- endif %}
{%- if schema.kw_const -%}
Specific value: `{{ schema.kw_const.raw | python_to_json }}`
{%- endif -%}

{# Conditional subschema, or if-then-else section #}
{% if schema.has_conditional %}
{% with skip_headers=False, depth=depth+1 %}
{% include "section_conditional_subschema.md" %}
{% endwith %}
{% endif %}

{# Required properties that are not defined under "properties". They will only be listed #}
{% include "section_undocumented_required_properties.md" %}

{# Show the requested type(s) #}
{{- schema | md_restrictions_table | md_generate_table -}}

{# Show array restrictions #}
{% if schema.type_name.startswith("array") %}
{% include "section_array.md" %}
{% endif %}

{# details of Properties, pattern properties, additional properties #}
{% if schema.type_name == "object" %}
{% include "section_properties_details.md" %}
{% endif %}
{% endif %}
21 changes: 21 additions & 0 deletions .github/generate-docs/templates/github/section_array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ schema | md_array_restrictions | md_generate_table }}

{% if schema.kw_items %}
{{ schema | md_array_items_restrictions | md_generate_table }}

{% for item in schema.kw_items %}
{% filter md_heading(depth+1) %}
{% with schema=item %}{%- include "breadcrumbs.md" %}{% endwith %}
{% endfilter %}
{% with schema=item, skip_headers=False, depth=depth+1, skip_required=True %}
{% include "content.md" %}
{% endwith %}
{% endfor %}
{% endif %}

{% if schema.kw_contains and schema.kw_contains.literal != {} %}
{{ "At least one of the items must be" | md_heading(depth+1) }}
{% with schema=schema.kw_contains, skip_headers=False, depth=depth+1, skip_required=True %}
{% include "content.md" %}
{% endwith %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% if schema.kw_if %}
{% set first_property = schema.kw_if | get_first_property %}

{% if schema.kw_then %}
{%- filter md_heading(depth) -%}If (
{{- first_property.property_name | md_escape_for_table -}}
{{- " = " -}}
{{- first_property.kw_const.literal | python_to_json -}}
){%- endfilter -%}
{% with schema=schema.kw_then, skip_headers=False, depth=depth %}
{% include "content.md" %}
{% endwith %}
{% endif %}
{% if schema.kw_else %}
{%- filter md_heading(depth) -%}Else (i.e. {{ " " }}
{{- first_property.property_name | md_escape_for_table -}}
{{- " != " -}}
{{- first_property.kw_const.literal | python_to_json -}}
){%- endfilter -%}
{% with schema=schema.kw_else, skip_headers=False, depth=depth %}
{% include "content.md" %}
{% endwith %}
{% endif %}
{% endif %}
4 changes: 4 additions & 0 deletions .github/generate-docs/templates/github/section_description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{# Display description #}
{% if description %}
{{ description }}
{% endif %}
16 changes: 16 additions & 0 deletions .github/generate-docs/templates/github/section_examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**Example{% if examples|length > 1 %}s{% endif %}:**{{ " " }}

{% for example in examples %}
{%- if loop.first %}{{ "\n" }}{% endif -%}
{% set example_id = schema.html_id ~ "_ex" ~ loop.index %}
{%- if not examples_as_yaml -%}
{{- "" }}```json
{{- "\n" }}{{ example }}
{{- "\n" }}```
{%- else -%}
{{- "" }}```yaml
{{- "\n" }}{{ example | yaml_example }}
{{- "\n" }}```
{%- endif -%}
{{ "\n" }}
{% endfor %}
4 changes: 4 additions & 0 deletions .github/generate-docs/templates/github/section_not.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ "Must **not** be" | md_heading(depth+1) }}
{% with schema=schema.kw_not, skip_headers=False, depth=depth+1, skip_required=True %}
{% include "content.md" %}
{% endwith %}
4 changes: 4 additions & 0 deletions .github/generate-docs/templates/github/section_one_of.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Must be one of:
{% for enum_choice in schema.kw_enum.array_items %}
* {{ enum_choice.literal | python_to_json }}
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% for sub_property in schema.iterate_properties %}
{%- if sub_property.is_additional_properties and not sub_property.is_additional_properties_schema -%}
{% continue %}
{% endif %}

{% set html_id = sub_property.html_id %}

{% set description = sub_property | get_description %}

{% filter md_heading(depth + 1, html_id) -%}
{%- filter replace('\n', '') -%}
{%- if not skip_required and sub_property.property_name -%}
{{ md_badge("Required", "blue") if sub_property.is_required_property else md_badge("Optional", "yellow") -}}
{%- endif -%}
{%- if sub_property is deprecated -%}~~{%- endif -%}
{%- if sub_property.is_pattern_property %}Pattern{% endif %} `{% with schema=sub_property %}{%- include "breadcrumbs.md" %}{% endwith %}`
{%- if sub_property is deprecated -%}~~{%- endif -%}
{%- endfilter %}
{%- endfilter %}

{% if sub_property.is_pattern_property %}
> All property whose name matches the regular expression
```{{ sub_property.property_name }}``` ([Test](https://regex101.com/?regex={{ sub_property.property_name | urlencode }}))
must respect the following conditions
{% endif %}


{% with schema=sub_property, skip_headers=False, depth=depth+1 %}
{% include "content.md" %}
{% endwith %}

{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% set undocumented_required_properties = schema | get_undocumented_required_properties %}
{% if undocumented_required_properties%}
{{ "The following properties are required" | md_heading(depth+1) }}
{% for required_property in undocumented_required_properties %}
* {{ required_property }}
{% endfor %}
{% endif %}
11 changes: 11 additions & 0 deletions .github/generate-docs/templates/github/tabbed_section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{{ current_node | md_array_items(title) | md_generate_table }}

{% for node in current_node.array_items %}
{% filter md_heading(depth+1, node.html_id) -%}
{% if node.is_pattern_property %}Pattern{% endif %} `{% with schema=node %}{%- include "breadcrumbs.md" %}{% endwith %}`
{%- endfilter %}
{% with schema=node, skip_headers=False, depth=depth+1 %}
{% include "content.md" %}
{% endwith %}
{% endfor %}
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
fail_fast: false

exclude: ^(docs/variables)

repos:
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Ansible role for setting up a VyOS router

## Release notes

Please see [Releases](https://github.com/bjw-s/ansible-role-vyos/releases) for information
Please see [Releases](https://github.com/bjw-s/ansible-role-vyos/releases) for information
about the contents of each release.

## Requirements
Expand All @@ -15,7 +15,11 @@ You can install dependencies using the requirements.txt file in this repository:

This role has been tested against the following VyOS versions:

- 1.4 (Rolling)
- 1.4 (vyos-1.4-rolling-202111181848)

## Documentation

More documentation can be found [here](https://bjw-s.github.io/ansible-role-vyos/)

## License

Expand Down
9 changes: 9 additions & 0 deletions defaults/main/containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# -----------------------
# Container configuration
# -----------------------

vyos_container:
registries: []
networks: {}
containers: {}
1 change: 1 addition & 0 deletions defaults/main/dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vyos_coredns:
interfaces: []
config_path: /config/coredns
container:
name: vyos-coredns
repository: ghcr.io/k8s-at-home/coredns
tag: v1.8.4
k8s_gateway:
Expand Down
2 changes: 0 additions & 2 deletions defaults/main/post_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
vyos_save_config: true

vyos_run_post_config_script: true

vyos_containers: {}
Loading