KCL

license

Kusion Configuration Language (KCL) is an open source constraint-based record & functional language mainly used in Kusion Stack. KCL improves the writing of a large number of complicated configuration data and logic through mature programming language theory and practice, and simplifies and verifies the development and operation of configuration through declarative syntax combined with technical features such as static typing.

Features

  • Well-designed: Independently designed syntax, semantics, runtime and system modules, providing core language elements such as configuration, schema, lambda and rule.
  • Modeling: Schema-centric modeling abstraction.
  • Easy to use: the language itself covers most configuration and policy functions.
  • Stability: Static type system and custom rule constraints.
  • Scalability: Configuration block definition ability and rich configuration merge coverage ability.
  • Automation capabilities: Rich language-level CRUD API and multi-language API.
  • High performance: The language compiler is implemented in Rust and C mainly with LLVM optimizer, supports compilation to native and WASM targets and executes efficiently.
  • Cloud Native Affinity: Native support for OpenAPI and Kubernetes CRD Specs to KCL conversion, support for Kubernetes YAML specification.
  • Development friendly: Rich language tools (Lint, Test, Vet, Doc, etc.), IDE Plugins and language plugins.

What is it for?

You can use KCL to

  • generate low-level configuration data like JSON, YAML, etc.
  • reduce boilerplate in configuration data with the schema modeling.
  • define schemas with rule constraints for configuration data and validate them automatically.
  • write configuration data separately and merge them using different strategies.
  • organize, simplify, unify and manage large configurations without side effects.
  • define your application delivery and operation ecosystem with Kusion Stack.

Installation

Download the latest release from GitHub and add {install-location}/kclvm/bin to the environment PATH.

Quick Showcase

./samples/fib.k is an example of calculating the Fibonacci sequence.

schema Fib:
    n1: int = n - 1
    n2: int = n1 - 1
    n: int
    value: int

    if n <= 1:
        value = 1
    elif n == 2:
        value = 1
    else:
        value = Fib {n: n1}.value + Fib {n: n2}.value

fib8 = Fib {n: 8}.value

We can execute the following command to get a YAML output.

kcl ./samples/fib.k

YAML output

fib8: 21

Documentation

Detailed documentation is available at https://kusionstack.io

Contributing

See Developing Guide.

Roadmap

See KCLVM Roadmap.

License

[Apache License Version 2.0]