Skip to main content

· 4 min read

KCL is a constraint-based record and functional language hosted by Cloud Native Computing Foundation (CNCF) that enhances the writing of complex configurations and polices, including those for cloud-native scenarios. With its advanced programming language technology and practices, KCL is dedicated to promoting better modularity, scalability, and stability for configurations. It enables simpler logic writing and offers ease of automation APIs and integration with homegrown systems.

This section will update the KCL language community's latest news, including features, website updates, and the latest community news, helping everyone better understand the KCL community!

KCL Website: https://kcl-lang.io

Overview

Thanks to to all contributors for their outstanding work over the past twenty days (2024 02.02 - 2024 02.22). Here is an overview of the key content:

📦 Module Updates

The JSON Schema module 0.0.4 has released, fixing type definition errors. You can update or add dependencies by running the following command:

kcl mod add jsonschema:0.0.4

🏄 Language Updates

KCL has released preview version 0.8.0, mainly including the following updates:

  • Added the file system library for reading KCL module information and system files, including the read, glob, workdir, and modpath functions. See more details in this issue
  • Optimized syntax error messages for unexpected tokens.
  • Removed output for unexpected internal built-in type attributes in schema objects.
  • Fixed variable calculation in unexpected dictionary generation expressions where the key is the same as the loop variable.
  • Fixed errors in defining string identifiers within schemas, such as "$if".

🔧 Toolchain Updates

  • kcl run supports using the -H parameter to output hidden fields starting with _.
  • kcl run supports running remote Git repository code directly.
  • Introduce the kcl mod graph subcommand used to output module dependency graphs.
  • Fixed formatting errors when there is an if statement within an else block.

💻 IDE Updates

  • Enhanced autocompletion and hover documentation for built-in functions and system libraries
  • Fixed issues with navigating and autocompleting if statements symbols within configuration blocks
  • Added quick fix feature for variable reference errors

🎁 API Updates

  • The OverrideFile API has added path for querying and modifying configurations, such as a["b"].c
  • The Run API has added the WithShowHidden and the WithTypePath flags.

🚀 Plugin System Updates

In addition to using Python for KCL plugin functions, it now supports using Go to write plugin functions for KCL, which is very simple to use.

  • Define a plugin (using a hello plugin containing the add function as an example)
package hello_plugin

import (
"kcl-lang.io/kcl-go/pkg/plugin"
)

func init() {
plugin.RegisterPlugin(plugin.Plugin{
Name: "hello",
MethodMap: map[string]plugin.MethodSpec{
"add": {
Body: func(args *plugin.MethodArgs) (*plugin.MethodResult, error) {
v := args.IntArg(0) + args.IntArg(1)
return &plugin.MethodResult{V: v}, nil
},
},
},
})
}
  • Use the plugin
package main

import (
"fmt"

"kcl-lang.io/kcl-go/pkg/kcl"
"kcl-lang.io/kcl-go/pkg/native" // Import the native API
_ "kcl-lang.io/kcl-go/pkg/plugin/hello_plugin" // Import the hello plugin
)

func main() {
// Note we use `native.MustRun` here instead of `kcl.MustRun`, because it needs the cgo feature.
yaml := native.MustRun("main.k", kcl.WithCode(code)).GetRawYamlResult()
fmt.Println(yaml)
}

const code = `
import kcl_plugin.hello

name = "kcl"
three = hello.add(1,2) # 3
`

🚢 Integration Updates

  • Released initial version of Ansible KCL module, supporting basic execution of KCL code, with other functionalities being improved
  • Optimized Git Source functionality for KCL FluxCD Controller, with OCI Source functionality in progress

Special Thanks

The following are listed in no particular order:

  • Thanks to @octonawish-akcodes and @d4v1d03 for their continuous contributions to KCL FAQ documentation and KCL IDE functionality 🙌
  • Thanks to @octonawish-akcodes for the contribution to the Ansible KCL Module
  • Thanks to @AkashKumar7902 and @Vanshikav123 for the contribution to the KCL package management tool functionality 🙌
  • Thanks to @StevenLeiZhang for the contribution to KCL documentation and KCL plugins
  • Thanks to @TheChinBot, @Evgeny Shepelyuk, @yonas, @steeling, @vtomilov, @Fdall, @CloudZero357, @bozaro, @starkers, @MrGuoRanDuo and @FLAGLORD, among others, for their valuable feedback and suggestions while using KCL recently. 🙌

Resources

❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. See here to join us!

For more resources, please refer to

· 4 min read

KCL is a constraint-based record and functional language hosted by Cloud Native Computing Foundation (CNCF) that enhances the writing of complex configurations, including those for cloud-native scenarios. With its advanced programming language technology and practices, KCL is dedicated to promoting better modularity, scalability, and stability for configurations. It enables simpler logic writing and offers ease of automation APIs and integration with homegrown systems.

KCL Website: https://kcl-lang.io\ KCL Github Repo: https://github.com/kcl-lang

For those interested in cloud-native, platform engineering,compiler, package management tools, and IDEs, we invite you to apply for the 2024 Spring Linux Foundation LFX Mentorship project. You can earn a minimum of $3000 for completing the project! Apply now!

LFX Mentorship Project

We have three Mentorship projects, covering package management tools, compiler, and IDEs.

1. Add version management for KCL package management tool

KCL package management tool (kpm) currently supports uploading, downloading, and distributing KCL packages, but does not support version management of KCL packages. In the process of using kpm to add third-party dependencies to KCL package, kpm will automatically download all third-party dependencies based on the dependency relationship. If different versions of the same package appear during the download, the corresponding selection strategy should be provided according to the package version management policy to select the appropriate version for download.

In this project, you need to add the package version management part of kpm to ensure that kpm can select the appropriate third-party dependencies.

2. KCL IDE Quick Fix

For KCL IDE, develop a quick fix feature. When a KCL program has a compilation error in the IDE, the Quick Fix feature can provide quick problem fixes at the location of the KCL program error based on the user's error type.

In this project, you need to develop different Quick Fix functions for IDE based on the error type of the KCL program.

3. KCL IDE automatically loads KCL third-party dependencies

KCL IDE is the most direct interface for KCL users. It often fails to find third-party dependencies. Currently, KCL's package management tool kpm has provided the ability to automatically download and update third-party dependencies, but users still need to update third-party libraries through the command line, which affects the user's development experience. Therefore, KCL IDE needs to be integrated with KCL's package management tool kpm to provide the ability to automatically download and update third-party libraries for the IDE.

In this project, you need to use the ability of kpm to implement common functions in the IDE, such as automatically downloading third-party dependencies, automatically updating third-party dependencies when kcl.mod changes, and Quick Fix triggering third-party dependencies automatic download, to ensure that KCL IDE can provide a more complete development experience with the support of package management tools.

4. How to Apply

Apply for your favorite project on the LFX mentorship platform. You can visit the LFX mentorship platform through the following link. The application starts on January 29, 2024, and ends on February 13, 2024.

If you have any questions, please feel free to get more information directly from the corresponding issue or discuss with us:

5. Project Timeline

EventStart DateEnd Date
Mentee Applications OpenJanuary 29February 13, 5:00 PM PDT
Application Review/Admission Decisions/HR PaperworkFebruary 13February 27, 5:00 PM PDT
Mentorship Program Begins with Initial Work AssignmentsMarch 4 (Week 1)
Midterm Mentee Evaluations / First Stipend PaymentsApril 10 (Week 6)
Final Mentee Evaluations Due / Mentee Feedback Submission Due / Second and Final Stipend Payment ApprovalsMay 22, 5:00 PM PST (Week 12)
Last Day of TermMay 31