Dagger
Search

kcl

This module provides KCL (KCL Configuration Language) functionality through Dagger.
It includes functions to run KCL code, validate configurations, and test the KCL CLI.

KCL is a constraint-based record and functional language hosted by CNCF that enhances
the writing of complex configurations, including those for cloud-native scenarios.

Installation

dagger install github.com/stuttgart-things/dagger/kcl@v0.66.0

Entrypoint

Return Type
Kcl
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
func (m *MyModule) Example() *dagger.Kcl  {
	return dag.
			Kcl()
}
@function
def example() -> dagger.Kcl:
	return (
		dag.kcl()
	)
@func()
example(): Kcl {
	return dag
		.kcl()
}

Types

Kcl 🔗

baseImage() 🔗

Return Type
String !
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 base-image
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Kcl().
			BaseImage(ctx)
}
@function
async def example() -> str:
	return await (
		dag.kcl()
		.base_image()
	)
@func()
async example(): Promise<string> {
	return dag
		.kcl()
		.baseImage()
}

testKcl() 🔗

TestKcl runs a basic KCL test to verify the container and CLI are working

Return Type
String !
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 test-kcl
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Kcl().
			TestKcl(ctx)
}
@function
async def example() -> str:
	return await (
		dag.kcl()
		.test_kcl()
	)
@func()
async example(): Promise<string> {
	return dag
		.kcl()
		.testKcl()
}

run() 🔗

Run executes KCL code from a provided directory or OCI source with parameters Supports three methods of passing parameters (in order of precedence): 1. CLI parameters (–parameters flag) - highest priority 2. Parameters file (–parametersFile) - middle priority 3. Default values in KCL code - lowest priority

Example usage with inline parameters:

dagger call -m kcl run --ociSource ghcr.io/stuttgart-things/kcl-ansible \
  --parameters 'pipelineRunName=run-test,namespace=tekton-ci'

Example usage with parameters file:

dagger call -m kcl run --ociSource ghcr.io/stuttgart-things/kcl-ansible \
  --parametersFile ./params.yaml

Example usage with both (CLI parameters override file values):

dagger call -m kcl run --ociSource ghcr.io/stuttgart-things/kcl-ansible \
  --parametersFile ./params.yaml \
  --parameters 'namespace=custom-namespace'

Returns a Dagger file containing the rendered output (YAML by default)

Return Type
File !
Arguments
NameTypeDefault ValueDescription
sourceDirectory -Local source directory (optional if using OCI source)
ociSourceString -OCI source path (e.g., oci://ghcr.io/stuttgart-things/kcl-flux-instance)
parametersString -KCL parameters as comma-separated key=value pairs For complex JSON structures, you can use JSON syntax Example: "name=my-flux,namespace=flux-system,storage={size:20Mi,mode:ReadWriteOnce}" Takes precedence over parametersFile
parametersFileFile -YAML/JSON file containing KCL parameters as key-value pairs File format example: pipelineRunName: run-ansible-test-6 namespace: tekton-ci ansiblePlaybooks: - sthings.baseos.setup Parameters from --parameters flag override values from this file
formatOutputBoolean "true"No description provided
outputFormatString "yaml"Output format: yaml or json
entrypointString "main.k"Entry point file name
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 run
func (m *MyModule) Example() *dagger.File  {
	return dag.
			Kcl().
			Run()
}
@function
def example() -> dagger.File:
	return (
		dag.kcl()
		.run()
	)
@func()
example(): File {
	return dag
		.kcl()
		.run()
}

pushModule() 🔗

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-No description provided
addressString !-No description provided
moduleNameString !-No description provided
userNameString "GITHUB_USER"No description provided
userSecret -No description provided
passwordNameString "GITHUB_TOKEN"No description provided
passwordSecret -No description provided
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 push-module --src DIR_PATH --address string --module-name string
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory, address string, moduleName string) string  {
	return dag.
			Kcl().
			PushModule(ctx, src, address, moduleName)
}
@function
async def example(src: dagger.Directory, address: str, module_name: str) -> str:
	return await (
		dag.kcl()
		.push_module(src, address, module_name)
	)
@func()
async example(src: Directory, address: string, moduleName: string): Promise<string> {
	return dag
		.kcl()
		.pushModule(src, address, moduleName)
}

createKubeconfigSecret() 🔗

CreateKubeconfigSecret creates or updates a Kubernetes secret from a kubeconfig secret This is an idempotent operation using kubectl apply

Example usage:

dagger call -m kcl create-kubeconfig-secret \
  --namespace crossplane-system \
  --secret-name dev \
  --kubeconfig-secret env:KUBECONFIG_SECRET \
  --kube-config env:KUBECONFIG_SECRET

Parameters: - namespace: Kubernetes namespace where the secret will be created - secretName: Name of the secret to create - kubeconfigSecret: kubeconfig secret to use as secret data - kubeConfig: kubeconfig secret for kubectl authentication

Returns the secret creation status

Return Type
String !
Arguments
NameTypeDefault ValueDescription
namespaceString "crossplane-system"Kubernetes namespace where secret will be created
secretNameString "kubeconfig"Name of the secret to create
kubeconfigSecretSecret !-Kubeconfig secret to create secret from
kubeConfigSecret -Kubeconfig secret for kubectl authentication
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 create-kubeconfig-secret --kubeconfig-secret env:MYSECRET
func (m *MyModule) Example(ctx context.Context, kubeconfigSecret *dagger.Secret) string  {
	return dag.
			Kcl().
			CreateKubeconfigSecret(ctxkubeconfigSecret)
}
@function
async def example(kubeconfig_secret: dagger.Secret) -> str:
	return await (
		dag.kcl()
		.create_kubeconfig_secret(kubeconfig_secret)
	)
@func()
async example(kubeconfigSecret: Secret): Promise<string> {
	return dag
		.kcl()
		.createKubeconfigSecret(kubeconfigSecret)
}

convertCrd() 🔗

ConvertCrd converts a single CRD file (local or web source) to KCL models Returns a directory containing the generated models/v1beta1/ structure

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
crdSourceString -No description provided
crdFileFile -No description provided
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 convert-crd
func (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Kcl().
			ConvertCrd()
}
@function
def example() -> dagger.Directory:
	return (
		dag.kcl()
		.convert_crd()
	)
@func()
example(): Directory {
	return dag
		.kcl()
		.convertCrd()
}

convertCrdToDirectory() 🔗

ConvertCrdToDirectory converts a CRD and outputs the models to a specified working directory This version gives more control over the output structure and allows custom organization

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
workdirDirectory !-No description provided
crdSourceString -No description provided
crdFileFile -No description provided
outputPathString -No description provided
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 convert-crd-to-directory --workdir DIR_PATH
func (m *MyModule) Example(workdir *dagger.Directory) *dagger.Directory  {
	return dag.
			Kcl().
			ConvertCrdToDirectory(workdir)
}
@function
def example(workdir: dagger.Directory) -> dagger.Directory:
	return (
		dag.kcl()
		.convert_crd_to_directory(workdir)
	)
@func()
example(workdir: Directory): Directory {
	return dag
		.kcl()
		.convertCrdToDirectory(workdir)
}

validateKcl() 🔗

ValidateKcl validates KCL configuration files by compiling them

Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-No description provided
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 validate-kcl --source DIR_PATH
func (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string  {
	return dag.
			Kcl().
			ValidateKcl(ctx, source)
}
@function
async def example(source: dagger.Directory) -> str:
	return await (
		dag.kcl()
		.validate_kcl(source)
	)
@func()
async example(source: Directory): Promise<string> {
	return dag
		.kcl()
		.validateKcl(source)
}

kclVersion() 🔗

KclVersion returns the installed KCL version

Return Type
String !
Example
dagger -m github.com/stuttgart-things/dagger/kcl@215785f29a9a2dda89efa4672cb3c9eab59dc408 call \
 kcl-version
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Kcl().
			KclVersion(ctx)
}
@function
async def example() -> str:
	return await (
		dag.kcl()
		.kcl_version()
	)
@func()
async example(): Promise<string> {
	return dag
		.kcl()
		.kclVersion()
}