Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add support for context variables for better use of templating #11

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1e68c23
Fix undefined variable errors by importing V1Deployment and V1Deploym…
djivey Jan 9, 2025
7ea238d
fix unit test api versions
djivey Jan 9, 2025
ea13fa5
Update the function to include a default value for the selector field
djivey Jan 9, 2025
2c5b1c3
found another issue that ExtensionsV1Api was deprecated and removed i…
djivey Jan 9, 2025
f984245
add support for using context variables and add unit tests for the ne…
djivey Jan 13, 2025
0fc04d6
add example usage of context to the module doc string and remove a co…
djivey Jan 13, 2025
f092f88
fix lower bounds for kubernetes and update changelog
djivey Jan 14, 2025
5c6cabe
Merge branch 'main' into feat_add_context_support
djivey Jan 14, 2025
6b7850e
update secret functions to support more types, remove cli arguments f…
djivey Jan 15, 2025
67f03b0
remove the config override test and remove the rest of the kwargs from
djivey Jan 16, 2025
6955bb0
add minimal functional tests and environment
djivey Jan 20, 2025
0f98615
drop the noxfile changes
djivey Jan 20, 2025
cf9f54f
test adding platform darwin to docker req, move to dependencies, and …
djivey Jan 20, 2025
694e73d
explicit version testing rather than relying on defaults, move the en…
djivey Jan 21, 2025
d092596
change to mark.skipif decorator and use kubectl to validate cluster b…
djivey Jan 21, 2025
9191fa0
add pytestmark to the functional tests to skip tests
djivey Jan 21, 2025
8eca687
remove the manual update in the kubernetes fixture
djivey Jan 21, 2025
8658434
add functional test for the kubernetesmod execution module
djivey Jan 22, 2025
1d9e9f2
fix unit tests after the changes to accommodate functional tests
djivey Jan 22, 2025
77b29ea
fix doc string in create_service
djivey Jan 22, 2025
6be7eff
add functional test for the kubernetesmod state module
djivey Jan 24, 2025
4920ac5
modify pod and secret absent funtions to work how secret_absent handl…
djivey Jan 24, 2025
c2bc17b
set log warning to info and rename the state module to kubernetes.py
djivey Jan 24, 2025
dda3e17
remove old doc rst file, update changelog and remove testing on k8s v…
djivey Jan 24, 2025
089907d
test potential race condition scenarios for pods
djivey Jan 24, 2025
1f3c417
add integration tests for the execution module kubernetesmod.py
djivey Jan 24, 2025
ad73fdf
modify config handling and drop extra debug stuff
djivey Jan 27, 2025
e45e3ba
add cryptograpphy dependency for tests and increase pod delete timeout
djivey Jan 27, 2025
85dbb95
add state module integration tests and updated changelog
djivey Jan 27, 2025
efe6847
increase timeouts and retries for pod lificycle timing is inconsisten…
djivey Jan 27, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.pytest-kind/

# Translations
*.mo
Expand Down
43 changes: 43 additions & 0 deletions changelog/2.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Added Comprehensive Testing Suite and Enhanced State Module Functionality

Renamed the state module kubernetesmod to kubernetes due to a conflict with the salt core state module kubernetes

## Testing Infrastructure
Implemented pytest-based testing framework with pytest-kind
Added pytest fixtures for handling Kubernetes resources:
- Template management
- Configurable Kubernetes version testing

## Resource Management Tests
Added functional and integration tests covering:
- Namespace management (creation, deletion, templating)
- Pod lifecycle (creation, deletion, template support)
- Deployment operations (creation, updates, deletion)
- Secret handling (creation, updates, base64 encoding)
- Service configuration (ports, selectors, types)
- ConfigMap management (data handling, updates)
- Node label operations (single labels and folder-based management)

## Template Support
Added Jinja2 template support for all resource types
Implemented context-based resource creation:
- Namespace templates with label support
- Pod templates with container configuration
- Deployment templates with replica and selector support
- Service templates with flexible port configuration
- ConfigMap templates with multi-line data support
- Secret templates with data encoding support

## Spec Validation Enhancements
- Base64 encoding validation for secrets
- Service port configuration validation
- ConfigMap data consistency checks
- Namespace state validation
- Deployment spec verification
- Container configuration validation

## Documentation
Added detailed docstrings for all test functions
- Included usage examples in test cases
- Documented template structures and context usage
- Added comments explaining complex operations
2 changes: 1 addition & 1 deletion docs/ref/states/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ _____________
.. autosummary::
:toctree:

kubernetesmod
kubernetes
5 changes: 5 additions & 0 deletions docs/ref/states/saltext.kubernetes.states.kubernetes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``kubernetes``
==============

.. automodule:: saltext.kubernetes.states.kubernetes
:members:
5 changes: 0 additions & 5 deletions docs/ref/states/saltext.kubernetes.states.kubernetesmod.rst

This file was deleted.

2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _lint(session, rcfile, flags, paths, tee_output=True):
stdout.seek(0)
contents = stdout.read()
if contents:
contents = contents.decode("utf-8")
contents.decode("utf-8")
sys.stdout.write(contents)
sys.stdout.flush()
if pylint_report_path:
Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dynamic = ["version"]
dependencies = [
"salt>=3006",
"kubernetes>=19.15.0; platform_system == 'Linux'",
"PyYAML>=5.3.1",
"docker>=6.0.0",
]

[project.readme]
Expand Down Expand Up @@ -71,11 +73,16 @@ lint = [
]
tests = [
"pytest>=7.2.0",
"pytest-salt-factories>=1.0.0",
"pytest-custom-exit-code>=0.3",
"pytest-salt-factories>=1.0.0rc19",
"pytest-helpers-namespace>=2019.1.8",
"pytest-subtests",
"pytest-timeout",
"kubernetes>=19.15.0",
"PyYAML>=5.3.1",
"mock>=4.0.3",
"pytest-custom-exit-code>=0.3",
"pytest-kind>=22.8.0",
"cryptography>=42.0.0",
]

[project.entry-points."salt.loader"]
Expand Down
Loading