Skip to content

Commit c6c6218

Browse files
authored
Merge pull request #287 from Peefy/blog-2024-02-22-newsletter
docs: add 2024-02-22 blogs
2 parents 1cfc42b + 2f3a844 commit c6c6218

File tree

2 files changed

+278
-0
lines changed
  • blog/2024-02-22-newsletter
  • i18n/zh-CN/docusaurus-plugin-content-blog/2024-02-22-newsletter

2 files changed

+278
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
slug: 2024-02-22-newsletter
3+
title: KCL Newsletter (2024 02.02 - 2024.02.22)
4+
authors:
5+
name: KCL Team
6+
title: KCL Team
7+
tags: [KCL, Newsletter]
8+
image: /img/biweekly-newsletter.png
9+
---
10+
11+
![](/img/biweekly-newsletter.png)
12+
13+
[KCL](https://github.com/kcl-lang) 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.
14+
15+
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!
16+
17+
**_KCL Website: [https://kcl-lang.io](https://kcl-lang.io)_**
18+
19+
## Overview
20+
21+
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:
22+
23+
**📦 Module Updates**
24+
25+
The JSON Schema module 0.0.4 has released, fixing type definition errors. You can update or add dependencies by running the following command:
26+
27+
```shell
28+
kcl mod add jsonschema:0.0.4
29+
```
30+
31+
**🏄 Language Updates**
32+
33+
KCL has released preview version 0.8.0, mainly including the following updates:
34+
35+
- 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](https://github.com/kcl-lang/kcl/issues/1049)
36+
- Optimized syntax error messages for unexpected tokens.
37+
- Removed output for unexpected internal built-in type attributes in schema objects.
38+
- Fixed variable calculation in unexpected dictionary generation expressions where the key is the same as the loop variable.
39+
- Fixed errors in defining string identifiers within schemas, such as `"$if"`.
40+
41+
**🔧 Toolchain Updates**
42+
43+
- `kcl run` supports using the -H parameter to output hidden fields starting with `_`.
44+
- `kcl run` supports running remote Git repository code directly.
45+
- Introduce the `kcl mod graph` subcommand used to output module dependency graphs.
46+
- Fixed formatting errors when there is an if statement within an else block.
47+
48+
**💻 IDE Updates**
49+
50+
- Enhanced autocompletion and hover documentation for built-in functions and system libraries
51+
- Fixed issues with navigating and autocompleting if statements symbols within configuration blocks
52+
- Added quick fix feature for variable reference errors
53+
54+
**🎁 API Updates**
55+
56+
- The `OverrideFile` API has added path for querying and modifying configurations, such as `a["b"].c`
57+
- The `Run` API has added the `WithShowHidden` and the `WithTypePath` flags.
58+
59+
**🚀 Plugin System Updates**
60+
61+
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.
62+
63+
+ Define a plugin (using a hello plugin containing the add function as an example)
64+
65+
```go
66+
package hello_plugin
67+
68+
import (
69+
"kcl-lang.io/kcl-go/pkg/plugin"
70+
)
71+
72+
func init() {
73+
plugin.RegisterPlugin(plugin.Plugin{
74+
Name: "hello",
75+
MethodMap: map[string]plugin.MethodSpec{
76+
"add": {
77+
Body: func(args *plugin.MethodArgs) (*plugin.MethodResult, error) {
78+
v := args.IntArg(0) + args.IntArg(1)
79+
return &plugin.MethodResult{V: v}, nil
80+
},
81+
},
82+
},
83+
})
84+
}
85+
```
86+
87+
+ Use the plugin
88+
89+
```go
90+
package main
91+
92+
import (
93+
"fmt"
94+
95+
"kcl-lang.io/kcl-go/pkg/kcl"
96+
"kcl-lang.io/kcl-go/pkg/native" // Import the native API
97+
_ "kcl-lang.io/kcl-go/pkg/plugin/hello_plugin" // Import the hello plugin
98+
)
99+
100+
func main() {
101+
// Note we use `native.MustRun` here instead of `kcl.MustRun`, because it needs the cgo feature.
102+
yaml := native.MustRun("main.k", kcl.WithCode(code)).GetRawYamlResult()
103+
fmt.Println(yaml)
104+
}
105+
106+
const code = `
107+
import kcl_plugin.hello
108+
109+
name = "kcl"
110+
three = hello.add(1,2) # 3
111+
`
112+
```
113+
114+
**🚢 Integration Updates**
115+
116+
- Released initial version of Ansible KCL module, supporting basic execution of KCL code, with other functionalities being improved
117+
- Optimized Git Source functionality for KCL FluxCD Controller, with OCI Source functionality in progress
118+
119+
## Special Thanks
120+
121+
The following are listed in no particular order:
122+
123+
The following list is in no particular order
124+
125+
- Thanks to @octonawish-akcodes and @d4v1d03 for their continuous contributions to KCL FAQ documentation and KCL IDE functionality 🙌
126+
- Thanks to @octonawish-akcodes for the contribution to the Ansible KCL Module
127+
- Thanks to @AkashKumar7902 and @Vanshikav123 for the contribution to the KCL package management tool functionality 🙌
128+
- Thanks to @StevenLeiZhang for the contribution to KCL documentation and KCL plugins
129+
- Thanks to @TheChinBot, @Evgeny Shepelyuk, @yonas, @steeling, @vtomilov, @Fdall, @CloudZero357, @bozaro, @starkers, and @FLAGLORD, among others, for their valuable feedback and suggestions while using KCL recently. 🙌
130+
131+
## Resources
132+
133+
❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. See [here](https://github.com/kcl-lang/community) to join us!
134+
135+
For more resources, please refer to
136+
137+
- [KCL Website](https://kcl-lang.io/)
138+
- [KusionStack Website](https://kusionstack.io/)
139+
- [KCL v0.8.0 Milestone](https://github.com/kcl-lang/kcl/milestone/8)
140+
- [KCL v0.9.0 Milestone](https://github.com/kcl-lang/kcl/milestone/9)
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
slug: 2024-02-22-newsletter
3+
title: KCL 最新动态速递 (2024 02.02 - 2024.02.22)
4+
authors:
5+
name: KCL 团队
6+
title: KCL 团队
7+
tags: [KCL, Newsletter]
8+
image: /img/biweekly-newsletter.png
9+
---
10+
11+
![](/img/biweekly-newsletter-zh.png)
12+
13+
[KCL](https://github.com/kcl-lang) 是一个 CNCF 基金会托管的基于约束的记录及函数语言,期望通过成熟的编程语言技术和实践来改进对大量繁杂配置比如云原生 Kubernetes 配置场景的编写,致力于构建围绕配置的更好的模块化、扩展性和稳定性,更简单的逻辑编写,以及更简单的自动化和生态工具集成。
14+
15+
本栏目将会双周更新 KCL 语言社区最新动态,包括功能、官网更新和最新的社区动态等,帮助大家更好地了解 KCL 社区!
16+
17+
**_KCL 官网:[https://kcl-lang.io](https://kcl-lang.io)_**
18+
19+
## 内容概述
20+
21+
感谢所有贡献者过去一段时间 (2024 02.02 - 2024.02.22) 的杰出工作,以下是重点内容概述
22+
23+
**📦 模型更新**
24+
25+
- JSON Schema 库发布 0.0.4 版本,修复类型定义错误, 可以执行如下命令更新或添加依赖
26+
27+
```shell
28+
kcl mod add jsonschema:0.0.4
29+
```
30+
31+
**🏄 语言更新**
32+
33+
**KCL 发布 0.8.0 预览版本**,主要包含如下更新
34+
35+
- 新增 file 系统库用于读取 KCL 模块信息和系统文件,包含 `read`, `glob`, `workdir``modpath` 函数,详见 Issue: https://github.com/kcl-lang/kcl/issues/1049
36+
- 优化非预期 token 的语法错误提示
37+
- 去除 Schema 对象内部非预期的内置类型属性通过 print 输出
38+
- 修复非预期的字典生成表达式中的 key 与循环变量相同时的变量计算
39+
- 修复 schema 内部诸如 "$if" 的字符串标识符定义找不到的错误
40+
41+
**🔧 工具链更新**
42+
43+
- kcl run 支持使用 `-H` 参数输出以 `_` 开头的隐藏字段
44+
- kcl run 支持直接运行远端 Git 仓库代码
45+
- kcl mod 新增 kcl mod graph 子命令输出模块依赖图
46+
- kcl fmt 修复 else 块中存在 if 语句时的格式化错误
47+
48+
**💻 IDE 更新**
49+
50+
- 优化了内置函数和系统库的补全以及悬停文档提升
51+
- 修复了配置块内部 if 语句符号不能跳转和补全的问题
52+
- 增加变量引用错误时的快速修复功能
53+
54+
**🎁 API 更新**
55+
56+
- OverrideFile API 新增诸如 `a["b"].c` 的 path 对配置进行查询和修改
57+
58+
**🚀 插件系统更新**
59+
60+
除了使用 Python 为 KCL 插件函数,现在支持使用 Go 为 KCL 编写插件函数,使用方式非常简单。
61+
62+
+ 定义插件 (以一个包含 add 函数的 hello 插件作为示例)
63+
64+
```go
65+
package hello_plugin
66+
67+
import (
68+
"kcl-lang.io/kcl-go/pkg/plugin"
69+
)
70+
71+
func init() {
72+
plugin.RegisterPlugin(plugin.Plugin{
73+
Name: "hello",
74+
MethodMap: map[string]plugin.MethodSpec{
75+
"add": {
76+
Body: func(args *plugin.MethodArgs) (*plugin.MethodResult, error) {
77+
v := args.IntArg(0) + args.IntArg(1)
78+
return &plugin.MethodResult{V: v}, nil
79+
},
80+
},
81+
},
82+
})
83+
}
84+
```
85+
86+
+ 使用插件
87+
88+
```go
89+
package main
90+
91+
import (
92+
"fmt"
93+
94+
"kcl-lang.io/kcl-go/pkg/kcl"
95+
"kcl-lang.io/kcl-go/pkg/native" // Import the native API
96+
_ "kcl-lang.io/kcl-go/pkg/plugin/hello_plugin" // Import the hello plugin
97+
)
98+
99+
func main() {
100+
// Note we use `native.MustRun` here instead of `kcl.MustRun`, because it needs the cgo feature.
101+
yaml := native.MustRun("main.k", kcl.WithCode(code)).GetRawYamlResult()
102+
fmt.Println(yaml)
103+
}
104+
105+
const code = `
106+
import kcl_plugin.hello
107+
108+
name = "kcl"
109+
three = hello.add(1,2) # 3
110+
`
111+
```
112+
113+
**🚢 集成更新**
114+
115+
- 发布 Ansible KCL 模块初始版本,支持基本的运行 KCL 代码功能,其他功能完善中
116+
- KCL FluxCD Controller 优化 Git Source 功能,OCI Source 功能支持中
117+
118+
## 特别鸣谢
119+
120+
以下排名不分先后
121+
122+
- 感谢 @octonawish-akcodes@d4v1d03
123+
对 KCL FAQ 文档和 KCL IDE 功能的持续贡献 🙌
124+
- 感谢 @octonawish-akcodes 对 Ansible KCL Module 的贡献
125+
- 感谢 @AkashKumar7902@Vanshikav123 对 KCL 包管理工具功能的贡献 🙌
126+
- 感谢 @StevenLeiZhang 对 KCL 文档和 KCL 插件的贡献
127+
- 感谢 @TheChinBot, @Evgeny Shepelyuk, @yonas, @steeling, @vtomilov, @Fdall, @CloudZero357, @bozaro, @starkers@FLAGLORD 等在近段时间使用 KCL 过程中提供的宝贵建议与反馈 🙌
128+
129+
## 其他资源
130+
131+
预计 2024 年 2 月底会发布 0.8 正式版本,感谢所有 KCL 用户和社区小伙伴在社区中提出的宝贵反馈与建议。后续我们会发布更多 KCL 技术和案例文章,敬请期待! 查看 _[KCL 社区](https://github.com/kcl-lang/community)_ 加入我们。
132+
133+
更多其他资源请参考:
134+
135+
- [KCL 网站](https://kcl-lang.io/)
136+
- [KusionStack 网站](https://kusionstack.io/)
137+
- [KCL v0.8.0 Milestone](https://github.com/kcl-lang/kcl/milestone/8)
138+
- [KCL v0.9.0 Milestone](https://github.com/kcl-lang/kcl/milestone/9)

0 commit comments

Comments
 (0)