Skip to main content

Versioned kyverno models for cloudcoil

Project description

cloudcoil-models-kyverno

Versioned kyverno models for cloudcoil.

PyPI Downloads License: Apache-2.0 CI

[!WARNING]
This repository is auto-generated from the cloudcoil repository. Please do not submit pull requests here. Instead, submit them to the main repository at https://github.com/cloudcoil/cloudcoil.

🔧 Installation

[!NOTE] For versioning information and compatibility, see the Versioning Guide.

Using uv (recommended):

# Install with Kyverno support
uv add cloudcoil.models.kyverno

Using pip:

pip install cloudcoil.models.kyverno

💡 Examples

Using Kyverno Models

from cloudcoil import apimachinery
import cloudcoil.models.kyverno.v1 as kyverno

# Create a ClusterPolicy
policy = kyverno.ClusterPolicy(
    metadata=apimachinery.ObjectMeta(name="require-labels"),
    spec=kyverno.ClusterPolicySpec(
        rules=[
            kyverno.Rule(
                name="require-team-label",
                match=kyverno.Match(
                    resources=kyverno.Resources(
                        kinds=["Deployment", "StatefulSet"]
                    )
                ),
                validate=kyverno.Validate(
                    message="The label 'team' is required",
                    pattern={
                        "metadata": {
                            "labels": {
                                "team": "*"
                            }
                        }
                    }
                )
            )
        ]
    )
).create()

# List Policies
for pol in kyverno.ClusterPolicy.list():
    print(f"Found policy: {pol.metadata.name}")

# Update a Policy
policy.spec.rules[0].validate.message = "The 'team' label is mandatory"
policy.save()

# Delete a Policy
kyverno.ClusterPolicy.delete("require-labels")

Using the Fluent Builder API

Cloudcoil provides a powerful fluent builder API for Kyverno resources with full IDE support and rich autocomplete capabilities:

from cloudcoil.models.kyverno.v1 import ClusterPolicy

# Create a ClusterPolicy using the builder
policy = (
    ClusterPolicy.builder()
    .metadata(lambda m: m
        .name("require-labels")
    )
    .spec(lambda s: s
        .rules([
            lambda r: r
            .name("require-team-label")
            .match(lambda m: m
                .resources(lambda res: res
                    .kinds(["Deployment", "StatefulSet"])
                )
            )
            .validate(lambda v: v
                .message("The label 'team' is required")
                .pattern({
                    "metadata": {
                        "labels": {
                            "team": "*"
                        }
                    }
                })
            )
        ])
    )
    .build()
)

The fluent builder provides:

  • ✨ Full IDE support with detailed type information
  • 🔍 Rich autocomplete for all fields and nested objects
  • ⚡ Compile-time validation of your configuration
  • 🎯 Clear and chainable API that guides you through resource creation

Using the Context Manager Builder API

For complex nested resources, Cloudcoil also provides a context manager-based builder pattern that can make the structure more clear:

from cloudcoil.models.kyverno.v1 import ClusterPolicy

# Create a policy using context managers
with ClusterPolicy.new() as policy:
    with policy.metadata() as metadata:
        metadata.name("require-labels")
        metadata.labels({"app": "kyverno"})
    
    with policy.spec() as spec:
        with spec.rules() as rules:
            with rules.add() as rule:
                rule.name("require-team-label")
                
                with rule.match() as match:
                    with match.resources() as resources:
                        resources.kinds(["Deployment", "StatefulSet"])
                
                with rule.validate() as validate:
                    validate.message("The label 'team' is required")
                    validate.pattern({
                        "metadata": {
                            "labels": {
                                "team": "*"
                            }
                        }
                    })

final_policy = policy.build()

The context manager builder provides:

  • 🎭 Clear visual nesting of resource structure
  • 🔒 Automatic resource cleanup
  • 🎯 Familiar Python context manager pattern
  • ✨ Same great IDE support as the fluent builder

Mixing Builder Styles

CloudCoil's intelligent builder system automatically detects which style you're using and provides appropriate IDE support:

from cloudcoil.models.kyverno.v1 import ClusterPolicy
from cloudcoil import apimachinery

# Mixing styles lets you choose the best approach for each part
with ClusterPolicy.new() as policy:
    # Direct object initialization with full type checking
    policy.metadata(apimachinery.ObjectMeta(
        name="require-labels",
        labels={"app": "kyverno"}
    ))
    
    with policy.spec() as spec:
        # Fluent style for rules
        spec.rules([
            lambda r: r
            .name("require-team-label")
            .match(lambda m: m
                .resources(lambda res: res
                    .kinds(["Deployment", "StatefulSet"])
                )
            )
            # Context manager style for validate
            .validate(lambda v: v
                .message("The label 'team' is required")
                .pattern({
                    "metadata": {
                        "labels": {
                            "team": "*"
                        }
                    }
                })
            )
        ])

final_policy = policy.build()

This flexibility allows you to:

  • 🔀 Choose the most appropriate style for each part of your configuration
  • 📖 Maximize readability for both simple and complex structures
  • 🎨 Format your code according to your team's preferences
  • 🧠 Get full IDE support with automatic style detection
  • ✨ Enjoy rich autocomplete in all styles
  • ⚡ Benefit from type checking across mixed styles
  • 🎯 Receive immediate feedback on type errors
  • 🔍 See documentation for all fields regardless of style

📚 Documentation

For complete documentation, visit cloudcoil.github.io/cloudcoil

📜 License

Apache License, Version 2.0 - see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudcoil_models_kyverno-1.13.4.0.tar.gz (308.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudcoil_models_kyverno-1.13.4.0-py3-none-any.whl (259.3 kB view details)

Uploaded Python 3

File details

Details for the file cloudcoil_models_kyverno-1.13.4.0.tar.gz.

File metadata

File hashes

Hashes for cloudcoil_models_kyverno-1.13.4.0.tar.gz
Algorithm Hash digest
SHA256 b4e0d7a500cd4db46978ef24674c1bf4a82787a2f8e9b0cf498d8e46647a8926
MD5 f501ce7c3b666e58a545c07b667d6850
BLAKE2b-256 9caaee61d8df5f483fd518f05e57cf5f9b5a171d0679cd38137579ed40dd86bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_kyverno-1.13.4.0.tar.gz:

Publisher: pypi_publish.yml on cloudcoil/models-kyverno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cloudcoil_models_kyverno-1.13.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcoil_models_kyverno-1.13.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35f2f7c714e5e15f0add9a71ff83a69e14a673de42d3ff57a6d1ac7a3975fb5b
MD5 935412c4c946792c9c8b8e42d4c14077
BLAKE2b-256 8b706fa6759e1a8bacbb965b9ee69380fd044db4c5e172e3305fc229bebd1485

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_kyverno-1.13.4.0-py3-none-any.whl:

Publisher: pypi_publish.yml on cloudcoil/models-kyverno

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page