Skip to content

Commit

Permalink
Merge pull request #12 from opsmill/develop
Browse files Browse the repository at this point in the history
v0.0.4
  • Loading branch information
opsmill-bot authored Nov 15, 2023
2 parents 1f2b47e + 2b5048b commit 8d39cc3
Show file tree
Hide file tree
Showing 35 changed files with 1,862 additions and 182 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release-note.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# yamllint disable rule:truthy
name: Release Note

on:
push:
branches:
- develop
- stable
pull_request:
types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:

- uses: release-drafter/release-drafter@v5
with:
config-name: release-note.yml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.INFRAHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- name: "Setup environment"
run: "pip install black==23.10.1 ruff==0.1.0"
- name: "Linting: BLACK"
run: "black --check ."
- name: "Linting: ruff"
run: "ruff check ."
run: "pip install ruff==0.1.5"
- name: "Linting: ruff check"
run: "ruff check --diff ."
- name: "Linting: ruff format"
run: "ruff format --check --diff ."

unit-tests:
if: |
always() && !cancelled() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs: ["files-changed", "yaml-lint", "python-lint"]
Expand Down
13 changes: 13 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: 2
# sphinx:
# configuration: docs/conf.py

build:
os: ubuntu-22.04
tools:
python: "3.9"

python:
install:
- requirements: docs/requirements.txt
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends: default
ignore: |
/.venv
/examples
/tests/**/output*
rules:
new-lines: disable
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Requirements
- The two latest Infrahub releases
- Python >=3.9, <3.12
- Python modules:
- infrahub_sdk >= 0.2.0
- infrahub-sdk >= 0.2.0
- Ansible 2.12+
- Infrahub write-enabled token when using modules or read-only token for `lookup/inventory`

Expand Down
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
force_valid_group_names = always

[inventory]
enable_plugins = opsmill.infrahub.inventory, yaml, ini
enable_plugins = opsmill.infrahub.inventory, yaml, ini
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
210 changes: 210 additions & 0 deletions docs/_extensions/pygments_lexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# -*- coding: utf-8 -*-
# pylint: disable=no-self-argument
#

# https://bitbucket.org/birkenfeld/pygments-main/raw/7941677dc77d4f2bf0bbd6140ade85a9454b8b80/AUTHORS

#
# Licensed under BSD license:
#

# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import, division, print_function

__metaclass__ = type


from pygments import token
from pygments.lexer import DelegatingLexer, RegexLexer, bygroups, include
from pygments.lexers import DiffLexer


class AnsibleOutputPrimaryLexer(RegexLexer):
name = "Ansible-output-primary"

# The following definitions are borrowed from Pygment's JSON lexer.
# It has been originally authored by Norman Richards.

# integer part of a number
int_part = r"-?(0|[1-9]\d*)"

# fractional part of a number
frac_part = r"\.\d+"

# exponential part of a number
exp_part = r"[eE](\+|-)?\d+"

tokens = {
# #########################################
# # BEGIN: states from JSON lexer #########
# #########################################
"whitespace": [(r"\s+", token.Text)],
# represents a simple terminal value
"simplevalue": [
(r"(true|false|null)\b", token.Keyword.Constant),
(
("%(int_part)s(%(frac_part)s%(exp_part)s|" "%(exp_part)s|%(frac_part)s)") % vars(),
token.Number.Float,
),
(int_part, token.Number.Integer),
(r'"(\\\\|\\"|[^"])*"', token.String),
],
# the right hand side of an object, after the attribute name
"objectattribute": [
include("value"),
(r":", token.Punctuation),
# comma terminates the attribute but expects more
(r",", token.Punctuation, "#pop"),
# a closing bracket terminates the entire object, so pop twice
(r"\}", token.Punctuation, "#pop:2"),
],
# a json object - { attr, attr, ... }
"objectvalue": [
include("whitespace"),
(r'"(\\\\|\\"|[^"])*"', token.Name.Tag, "objectattribute"),
(r"\}", token.Punctuation, "#pop"),
],
# json array - [ value, value, ... }
"arrayvalue": [
include("whitespace"),
include("value"),
(r",", token.Punctuation),
(r"\]", token.Punctuation, "#pop"),
],
# a json value - either a simple value or a complex value (object or array)
"value": [
include("whitespace"),
include("simplevalue"),
(r"\{", token.Punctuation, "objectvalue"),
(r"\[", token.Punctuation, "arrayvalue"),
],
# #########################################
# # END: states from JSON lexer ###########
# #########################################
"host-postfix": [
(r"\n", token.Text, "#pop:3"),
(
r"( )(=>)( )(\{)",
bygroups(token.Text, token.Punctuation, token.Text, token.Punctuation),
"objectvalue",
),
],
"host-error": [
(
r"(?:(:)( )(UNREACHABLE|FAILED)(!))?",
bygroups(token.Punctuation, token.Text, token.Keyword, token.Punctuation),
"host-postfix",
),
(r"", token.Text, "host-postfix"),
],
"host-name": [
(
r"(\[)([^ \]]+)(?:( )(=>)( )([^\]]+))?(\])",
bygroups(
token.Punctuation,
token.Name.Variable,
token.Text,
token.Punctuation,
token.Text,
token.Name.Variable,
token.Punctuation,
),
"host-error",
)
],
"host-result": [
(r"\n", token.Text, "#pop"),
(
r"( +)(ok|changed|failed|skipped|unreachable)(=)([0-9]+)",
bygroups(token.Text, token.Keyword, token.Punctuation, token.Number.Integer),
),
],
"root": [
(
r"(PLAY|TASK|PLAY RECAP)(?:( )(\[)([^\]]+)(\]))?( )(\*+)(\n)",
bygroups(
token.Keyword,
token.Text,
token.Punctuation,
token.Literal,
token.Punctuation,
token.Text,
token.Name.Variable,
token.Text,
),
),
(
r"(fatal|ok|changed|skipping)(:)( )",
bygroups(token.Keyword, token.Punctuation, token.Text),
"host-name",
),
(
r"(\[)(WARNING)(\]:)([^\n]+)",
bygroups(token.Punctuation, token.Keyword, token.Punctuation, token.Text),
),
(
r"([^ ]+)( +)(:)",
bygroups(token.Name, token.Text, token.Punctuation),
"host-result",
),
(
r"(\tto retry, use: )(.*)(\n)",
bygroups(token.Text, token.Literal.String, token.Text),
),
(r".*\n", token.Other),
],
}


class AnsibleOutputLexer(DelegatingLexer):
name = "Ansible-output"
aliases = ["ansible-output"]

def __init__(self, **options):
super(AnsibleOutputLexer, self).__init__(DiffLexer, AnsibleOutputPrimaryLexer, **options)


# ####################################################################################################
# # Sphinx plugin ####################################################################################
# ####################################################################################################

__version__ = "0.1.0"
__license__ = "BSD license"
__author__ = "Felix Fontein"
__author_email__ = "[email protected]"


def setup(app):
"""Initializer for Sphinx extension API.
See http://www.sphinx-doc.org/en/stable/extdev/index.html#dev-extensions.
"""
for lexer in [AnsibleOutputLexer(startinline=True)]:
app.add_lexer(lexer.name, lexer)
for alias in lexer.aliases:
app.add_lexer(alias, lexer)

return dict(version=__version__, parallel_read_safe=True)
59 changes: 59 additions & 0 deletions docs/_static/ansible.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8d39cc3

Please sign in to comment.