8000 GitHub - cloudcoil/models-kpack: Generated model repository for kpack
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cloudcoil/models-kpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cloudcoil-models-kpack

Versioned kpack 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 kpack support
uv add cloudcoil.models.kpack

Using pip:

pip install cloudcoil.models.kpack

πŸ’‘ Examples

Using kpack Models

from cloudcoil import apimachinery
import cloudcoil.models.kpack.v1alpha2 as kpack
import cloudcoil.models.kpack.core as core
import cloudcoil.models.kubernetes.core.v1 as k8score

# Create an Image resource
image = kpack.Image(
    metadata=apimachinery.ObjectMeta(name="my-app"),
    spec=kpack.ImageSpec(
        tag="registry.example.com/my-app",
        builder_=k8score.ObjectReference(
            name="my-builder",
            kind="ClusterBuilder"
        ),
        source=core.SourceConfig(
            git=core.Git(
                url="https://github.com/my-org/my-app.git",
                revision="main"
            )
        )
    )
).create()

# Create a Builder
builder = kpack.BuilderResource(
    metadata=apimachinery.ObjectMeta(name="my-builder"),
    spec=kpack.BuilderSpec(
        tag="registry.example.com/builder",
        stack=k8score.ObjectReference(
            name="base",
            kind="ClusterStack"
        ),
        store=k8score.ObjectReference(
            name="default",
            kind="ClusterStore"
        )
    )
).create()

# List Images
for img in kpack.Image.list():
    print(f"Found image: {img.metadata.name}")

# Update an Image
image.spec.source.git.revision = "v1.0.0"
image.save()

# Delete resources
kpack.Image.delete("my-app")
kpack.BuilderResource.delete("my-builder")

Using the Fluent Builder API

from cloudcoil.models.kpack.v1alpha2 import Image

# Create an Image using the fluent builder
image = (
    Image.builder()
    .metadata(lambda m: m
        .name("my-app")
        .namespace("default")
    )
    .spec(lambda s: s
        .tag("registry.example.com/my-app")
        .builder_(lambda b: b
            .name("my-builder")
            .kind("ClusterBuilder")
        )
        .source(lambda src: src
            .git(lambda g: g
                .url("https://github.com/my-org/my-app.git")
                .revision("main")
            )
        )
    )
    .build()
)

Using the Context Manager Builder API

from cloudcoil.models.kpack.v1alpha2 import Image, BuilderResource

# Create an image using context managers
with Image.new() as app_image:
    with app_image.metadata() as metadata:
        metadata.name("my-app")
        metadata.namespace("default")
    
    with app_image.spec() as spec:
        spec.tag("registry.example.com/my-app")
        
        with spec.builder_() as builder:
            builder.name("my-builder")
            builder.kind("ClusterBuilder")
        
        with spec.source() as source:
            with source.git() as git:
                git.url("https://github.com/my-org/my-app.git")
                git.revision("main")

final_image = app_image.build()

# Create a builder using context managers
with BuilderResource.new() as builder:
    with builder.metadata() as metadata:
        metadata.name("my-builder")
        metadata.namespace("default")
    
    with builder.spec() as spec:
        spec.tag("registry.example.com/builder")
        
        with spec.stack() as stack:
            stack.name("base")
            stack.kind("ClusterStack")
        
        with spec.store() as store:
            store.name("default")
            store.kind("ClusterStore")
        
        # Add buildpacks to the builder
        with spec.buildpacks() as buildpacks:
            with buildpacks.add() as pack:
                pack.id("paketo-buildpacks/java")
                pack.version("3.0.0")

final_builder = builder.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

πŸ“š Documentation

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

πŸ“œ License

Apache License, Version 2.0 - see LICENSE

About

Generated model repository for kpack

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0