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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

djivey
Copy link
Contributor

@djivey djivey commented Jan 13, 2025

What does this PR do?

This PR introduces several enhancements to the Kubernetes extension:

  1. Template Context Support

    • Adds context variable support for Kubernetes resource states
    • Enables dynamic template configuration for deployments, pods, services, configmaps, and secrets
  2. Secret Management Improvements

    • Added base64 encoding handling
    • Docker registry secret support
    • Preserves secret types during updates
  3. Service Specification Enhancement

    • Enhanced service port specifications
  4. Connection Handling

    • Simplified kubeconfig management
    • Removed individual override options
  5. Updated Unit Tests

    • Added unit tests for use of context variables

What issues does this PR fix or reference?

Fixes: #10 - Add support for context variables in Kubernetes templates.
Potentially fixes - saltstack/salt#59758

Previous Behavior

  • Templates lacked context support
  • Did not handle base64 encoded strings required for secrets
  • Limited service port configuration options

New Behavior

Template Context

  • Dynamic variable support in all resource templates
  • Consistent with Salt's file.managed approach

Secret Management

  • Automatic base64 encoding detection
  • Docker registry secret support
  • Type preservation during updates

Service Configuration

  • Enhanced port specification support

Connection Handling

  • Simplified kubeconfig usage

Merge requirements satisfied?

  • Docs - Updated all affected function docstrings
  • Changelog - Added entries in changelog/2.feature.md
  • Tests - Added for all new features

Commits signed with GPG?

Yes

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 86.94779% with 195 lines in your changes missing coverage. Please review.

Project coverage is 77.82%. Comparing base (9df015d) to head (1f3c417).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/saltext/kubernetes/modules/kubernetesmod.py 62.97% 74 Missing and 33 partials ⚠️
tests/functional/modules/test_kubernetesmod.py 89.20% 30 Missing and 31 partials ⚠️
tests/integration/modules/test_kubernetesmod.py 90.13% 15 Missing ⚠️
tests/conftest.py 75.55% 10 Missing and 1 partial ⚠️
tests/functional/states/test_kubernetes.py 99.69% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #11       +/-   ##
===========================================
+ Coverage   55.63%   77.82%   +22.18%     
===========================================
  Files          13       16        +3     
  Lines        2439     3752     +1313     
  Branches      290      383       +93     
===========================================
+ Hits         1357     2920     +1563     
+ Misses       1066      722      -344     
- Partials       16      110       +94     
Flag Coverage Δ
Linux 77.82% <86.94%> (+22.26%) ⬆️
macOS 44.24% <20.14%> (+9.44%) ⬆️
project 62.09% <64.21%> (+25.04%) ⬆️
py310 77.82% <86.94%> (+22.14%) ⬆️
py39 ?
salt_3006_9 44.24% <20.14%> (-11.40%) ⬇️
salt_3007_1 77.82% <86.94%> (+22.14%) ⬆️
tests 90.54% <92.63%> (+3.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djivey djivey marked this pull request as ready for review January 14, 2025 14:39
@djivey djivey marked this pull request as draft January 15, 2025 14:10
@djivey
Copy link
Contributor Author

djivey commented Jan 15, 2025

I have some more changes for this pr, but having issues with new unit tests.

@djivey djivey marked this pull request as ready for review January 16, 2025 15:06
@djivey djivey marked this pull request as draft January 18, 2025 18:48
@djivey
Copy link
Contributor Author

djivey commented Jan 18, 2025

I marked this back to draft, I am going to try and write functional/integration tests for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Add functionality for using context values for jinja templating in kubernetesmod.
1 participant