Dagger
Search

kubeconform

kubeconform is a tool that validates Kubernetes resources against the Kubernetes OpenAPI specification. It can be used to check if Kubernetes manifests (YAML or JSON files containing Kubernetes resources) are valid according to the specification.

What does this module exactly do?:

Directory specification: The module takes as input a directory containing Kubernetes manifests. This could be a single directory or a hierarchy of directories with multiple manifest files.

Manifest validation: For each manifest file in the specified directory, the module runs kubeconform to validate the resources in the file. This includes checking if the resources are valid Kubernetes resources, if they have all required fields, if the fields have valid values, etc.

Kustomization support: If the --kustomize option is provided, the module uses kustomize build to process kustomization files before validating them. Kustomization is a template-free way to customize application configuration, which simplifies the management of configuration files.

Exclusion of directories or files: The module supports excluding directories or files from validation using the --exclude option. This is useful if you have directories or files that you don't want to validate, such as test files, temporary files, etc.

Additional schemas: The module supports additional schemas located in the /schemas directory. This is useful if you have custom resources that are not part of the standard Kubernetes API. You can add schemas for these resources to the /schemas directory, and kubeconform will use them during validation.

Error handling: If kubeconform finds invalid resources, the module prints an error message and exits with a non-zero status. This allows the module to be used in scripts and CI/CD pipelines that need to fail when invalid resources are found.

Installation

dagger install github.com/Smana/daggerverse/kubeconform@v0.0.2

Entrypoint

Return Type
Kubeconform
Example
func (m *myModule) example() *Kubeconform  {
	return dag.
			Kubeconform()
}
@function
def example() -> dag.Kubeconform:
	return (
		dag.kubeconform()
	)
@func()
example(): Kubeconform {
	return dag
		.kubeconform()
}

Types

Kubeconform 🔗

version() 🔗

Kubeconform version to use for validation.

Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Kubeconform().
			Version(ctx)
}
@function
async def example() -> str:
	return await (
		dag.kubeconform()
		.version()
	)
@func()
async example(): Promise<string> {
	return dag
		.kubeconform()
		.version()
}

validate() 🔗

Validate the Kubernetes manifests in the provided directory and optional source CRDs directories

Return Type
String !
Arguments
NameTypeDefault ValueDescription
versionString "v0.6.6"Kubeconform version to use for validation.
manifestsDirectory !-Base directory to walk through in order to validate Kubernetes manifests.
kustomizeBoolean -kustomize if set to true it will look for kustomization.yaml files and validate them otherwise it will validate all the YAML files in the directory.
excludeString -exclude is string listing directories or files to exclude from the validation separated by commas (example: "./terraform,.gitignore").
schemasDirs[Directory ! ] -schemaDirs is a list of directories containing the CRDs to validate against.
Example
func (m *myModule) example(ctx context.Context, manifests *Directory) string  {
	return dag.
			Kubeconform().
			Validate(ctxmanifests)
}
@function
async def example(manifests: dagger.Directory) -> str:
	return await (
		dag.kubeconform()
		.validate(manifests)
	)
@func()
async example(manifests: Directory): Promise<string> {
	return dag
		.kubeconform()
		.validate(manifests)
}