Skip to content

Commit

Permalink
Add support for ADT server (#167)
Browse files Browse the repository at this point in the history
* Add support for ADT server

Signed-off-by: NilashishC <[email protected]>

* revert .gitignore changes

Signed-off-by: NilashishC <[email protected]>

* revert _version changes

Signed-off-by: NilashishC <[email protected]>

* Add some tests, CI related cleanup

* Update constraints

* Speeling

* assorted fixes

Signed-off-by: NilashishC <[email protected]>

* fix CI

Signed-off-by: NilashishC <[email protected]>

* update README

Signed-off-by: NilashishC <[email protected]>

* Update README.md

* Update README.md

* fix typo

Signed-off-by: NilashishC <[email protected]>

---------

Signed-off-by: NilashishC <[email protected]>
Co-authored-by: Bradley A. Thornton <[email protected]>
  • Loading branch information
NilashishC and cidrblock authored Apr 25, 2024
1 parent 0eb47f5 commit cc0cd8f
Show file tree
Hide file tree
Showing 24 changed files with 727 additions and 125 deletions.
44 changes: 32 additions & 12 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras pyproject.toml
Expand All @@ -13,6 +13,7 @@ ansible-lint==24.2.2
ansible-navigator==24.2.0
ansible-runner==2.3.6
ansible-sign==0.1.1
asgiref==3.8.1
attrs==23.2.0
babel==2.14.0
beautifulsoup4==4.12.3
Expand All @@ -31,30 +32,36 @@ charset-normalizer==3.3.2
click==8.1.7
click-help-colors==0.9.4
colorama==0.4.6
coverage==7.4.4
coverage==7.5.0
cryptography==42.0.5
csscompressor==0.9.5
cssselect2==0.7.0
defusedxml==0.7.1
distlib==0.3.8
distro==1.9.0
django==4.2.11
django-stubs==4.2.7
django-stubs-ext==4.2.7
dnspython==2.6.1
docstring-parser-fork==0.0.5
docutils==0.21.1
enrich==1.2.7
exceptiongroup==1.2.0
execnet==2.1.1
filelock==3.13.4
ghp-import==2.1.0
griffe==0.42.2
griffe==0.44.0
gunicorn==22.0.0
htmlmin2==0.1.13
identify==2.5.35
identify==2.5.36
idna==3.7
iniconfig==2.0.0
isodate==0.6.1
jinja2==3.1.3
jsmin==3.0.1
jsonschema==4.21.1
jsonschema-path==0.3.2
jsonschema-specifications==2023.12.1
lazy-object-proxy==1.10.0
linkchecker==10.4.0
lockfile==0.12.2
markdown==3.6
Expand All @@ -69,20 +76,27 @@ mkdocs-ansible==24.3.0
mkdocs-autorefs==1.0.1
mkdocs-gen-files==0.5.0
mkdocs-htmlproofer-plugin==1.2.1
mkdocs-macros-plugin==1.0.5
mkdocs-material==9.5.18
mkdocs-material-extensions==1.3.1
mkdocs-minify-plugin==0.8.0
mkdocs-monorepo-plugin==1.1.0
mkdocstrings==0.24.3
mkdocstrings-python==1.9.2
mkdocstrings-python==1.10.0
molecule==24.2.1
mypy==1.9.0
more-itertools==10.2.0
mypy==1.7.1
mypy-extensions==1.0.0
nodeenv==1.8.0
onigurumacffi==1.3.0
openapi-core==0.19.1
openapi-schema-validator==0.6.2
openapi-spec-validator==0.7.1
packaging==24.0
paginate==0.5.6
parse==1.20.1
parsley==1.3
pathable==0.4.3
pathspec==0.12.1
pbr==6.0.0
pexpect==4.9.0
Expand All @@ -96,7 +110,7 @@ ptyprocess==0.7.0
pycparser==2.22
pydoclint==0.4.1
pygments==2.17.2
pymdown-extensions==10.7.1
pymdown-extensions==10.8
pyproject-api==1.6.1
pyproject-hooks==1.0.0
pytest==8.1.1
Expand All @@ -108,26 +122,31 @@ python-gnupg==0.5.2
python-slugify==8.0.4
pyyaml==6.0.1
pyyaml-env-tag==0.1
referencing==0.34.0
referencing==0.31.1
regex==2024.4.16
requests==2.31.0
requirements-parser==0.9.0
resolvelib==1.0.1
rfc3339-validator==0.1.4
rich==13.7.1
rpds-py==0.18.0
ruamel-yaml==0.18.6
ruamel-yaml-clib==0.2.8
ruff==0.3.7
ruff==0.4.1
six==1.16.0
soupsieve==2.5
sqlparse==0.5.0
subprocess-tee==0.4.1
termcolor==2.4.0
text-unidecode==1.3
tinycss2==1.2.1
tinycss2==1.3.0
toml-sort==0.23.1
tomli==2.0.1
tomlkit==0.12.4
tox==4.14.2
tox-ansible==24.2.0
types-pytz==2024.1.0.20240417
types-pyyaml==6.0.12.20240311
types-requests==2.31.0.20240406
types-setuptools==69.5.0.20240415
typing-extensions==4.11.0
tzdata==2024.1
Expand All @@ -136,6 +155,7 @@ virtualenv==20.25.2
watchdog==4.0.0
wcmatch==8.5.1
webencodings==0.5.1
werkzeug==3.0.2
wheel==0.43.0
yamllint==1.35.1

Expand Down
13 changes: 10 additions & 3 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
ADT
Ansibuddy
antsibull
arcname
autoplay
capsys
devel
gunicorn
libera
netcommon
testenv
Uninstallation
netcommon
Ansibuddy
antsibull
Unmarshal
unmarshalling
urandom
82 changes: 0 additions & 82 deletions .config/requirements-lock.txt

This file was deleted.

3 changes: 3 additions & 0 deletions .config/requirements-server.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
django>4.1,<4.3
gunicorn
openapi-core>=0.19.1
4 changes: 4 additions & 0 deletions .config/requirements-test.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ pip-tools
pre-commit
pydoclint
pytest
requests
ruff
toml-sort
types-pyyaml
types-requests
django-stubs[compatible-mypy]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/src/ansible_dev_tools/_version.py


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,30 @@ repos:
additional_dependencies:
- pytest
- tox
- PyYAML
- ansible-creator
- django
- openapi_core
- pytest
- gunicorn

- repo: https://github.com/pre-commit/mirrors-mypy.git
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
- django-stubs[compatible-mypy]
- jinja2
- pytest
- tox
- types-pyyaml
- types-requests
- types-setuptools
args:
- src
- tests
pass_filenames: false
language_version: "3.10"

- repo: https://github.com/jazzband/pip-tools
rev: 7.4.1
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ pytest-ansible <version>
tox-ansible <version>
```

## Developer Notes

The `ansible-dev-tools` package also offers an Ansible Devtools server which can be launched with `adt server`. Currently, this server only supports REST APIs for `ansible-creator`.

Refer to the [server](https://github.com/ansible/ansible-dev-tools/blob/main/src/ansible_dev_tools/subcommands/server.py) code for available endpoints.

**Note:** This is primarily for backend integrations and is not intended to be an user-facing functionality.

## Documentation

For more information, please visit our [documentation](https://ansible.readthedocs.io/projects/dev-tools/) page.
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ repository = "https://github.com/ansible/ansible-dev-tools"
files = ["src", "tests"]
strict = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = ["gunicorn.*", "openapi_core.*", "ansible_creator.*"]

[tool.pydoclint]
allow-init-docstring = true
arg-type-hints-in-docstring = false
Expand Down Expand Up @@ -232,6 +236,9 @@ disable = [
"unsubscriptable-object"
]

[tool.pytest.ini_options]
addopts = "-p no:pytest-ansible"

[tool.ruff]
builtins = ["__"]
fix = true
Expand Down Expand Up @@ -259,6 +266,7 @@ convention = "pep257"
dependencies = {file = [".config/requirements.in"]}
optional-dependencies.docs = {file = [".config/requirements-docs.in"]}
optional-dependencies.test = {file = [".config/requirements-test.in"]}
optional-dependencies.server = {file = [".config/requirements-server.in"]}

[tool.setuptools_scm]
# To prevent accidental pick of mobile version tags such 'v6'
Expand Down
32 changes: 31 additions & 1 deletion src/ansible_dev_tools/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def parse() -> argparse.Namespace:
"""Parse the command line arguments.
Returns:
The arguments
The parsed arguments.
"""
parser = argparse.ArgumentParser(
description="The ansible content development kit.",
Expand All @@ -23,4 +23,34 @@ def parse() -> argparse.Namespace:
help="Print the included tool versions and exit.",
)

subparsers = parser.add_subparsers(
help="The subcommand to invoke.",
title="Commands",
dest="subcommand",
required=True,
)

server_command_parser = subparsers.add_parser(
"server",
help="Start the Ansible Devtools server.",
description=(
"Starts the Ansible Devtools server on port 8000. Use --port to specify a custom port."
),
)

server_command_parser.add_argument(
"--port",
"-p",
default="8000",
help="Specify the port for the Ansible Devtools server.",
)

server_command_parser.add_argument(
"--debug",
dest="debug",
action="store_true",
default=False,
help="Run Ansible Devtools server with debug logging enabled.",
)

return parser.parse_args()
Loading

0 comments on commit cc0cd8f

Please sign in to comment.