|
| 1 | +--- |
| 2 | +slug: 2023-08-09-biweekly-newsletter |
| 3 | +title: KCL Biweekly Newsletter (2023 08.10 - 08.23) | KCL v0.5.3, v0.5.4 and v0.5.5 are out! |
| 4 | +authors: |
| 5 | + name: KCL Team |
| 6 | + title: KCL Team |
| 7 | +tags: [KCL, Biweekly-Newsletter] |
| 8 | +--- |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +[KCL](https://github.com/kcl-lang) is an open-source, constraint-based record and functional language 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. |
| 13 | + |
| 14 | +This section will update the KCL language community's latest developments every two weeks, including features, website updates, and the latest community news, helping everyone better understand the KCL community! |
| 15 | + |
| 16 | +***KCL Website: [https://kcl-lang.io](https://kcl-lang.io)*** |
| 17 | + |
| 18 | +## Overview |
| 19 | + |
| 20 | +Thank you to all contributors for their outstanding work over the past two weeks (08.10-08.23 2023). Here is an overview of the key content: |
| 21 | + |
| 22 | +**🔧 Language and Toolchain Updates** |
| 23 | + |
| 24 | +- **KCL Formatting Tool Updates** - Support for formatting code snippets with syntax errors and partial code snippets and automatic correction of indentation errors in configuration blocks. |
| 25 | +- **KCL Documentation Tool Updates** - Support for exporting document index pages |
| 26 | +- **KCL Import Tool Updates** - Support for converting Terraform Provider Schema to KCL Schema |
| 27 | +- **KCL Export Tool Updates** - Support for exporting OpenAPI Spec from KCL Schema, integrating with OpenAPI ecosystem |
| 28 | +- **KCL IDE Updates** - Support for compilation cache feature to improve performance of some IDE features and providing rich error messages and import statement quick fix capabilities |
| 29 | +- **KCL Package Management Tool Updates** - Support for output information experience optimization for the `kpm push` command and adding duplicate tag check when pushing KCL package. Adding the `--vendor` parameter for the `kpm push` and `kpm pkg` commands to determine whether to package third-party libraries in KCL packages together |
| 30 | +- **KCL Language Updates** - Optimize Schema semantic check and union type check error messages and support for exporting type output of configuration blocks. |
| 31 | + |
| 32 | +🏄 **API Updates** |
| 33 | + |
| 34 | +- KCL Schema model parsing GetSchemaType API newly added KCL package related information and schema attribute default values. |
| 35 | + |
| 36 | +**📰 Official Website and Use Case Updates** |
| 37 | + |
| 38 | +- KCL package docker.io integration example: *[https://github.com/kcl-lang/kpm/blob/main/docs/publish_to_docker_reg.md](https://github.com/kcl-lang/kpm/blob/main/docs/publish_to_docker_reg.md)* |
| 39 | +- KCL Gitlab CI integration example: *[https://kcl-lang.io/docs/user_docs/guides/ci-integration/gitlab-ci](https://kcl-lang.io/docs/user_docs/guides/ci-integration/gitlab-ci)* |
| 40 | +- KCL Vault and Vals Integration example: *[https://kcl-lang.io/docs/user_docs/guides/secret-management/vault](https://kcl-lang.io/docs/user_docs/guides/secret-management/vault)* |
| 41 | + |
| 42 | +## Special Thanks |
| 43 | + |
| 44 | +The following are listed in no particular order: |
| 45 | + |
| 46 | +- Thanks to @jakezhu9 for the contribution of the KCL Import Tool Terraform Schema to KCL Schema conversion 🙌 [https://github.com/kcl-lang/kcl-go/pull/141](https://github.com/kcl-lang/kcl-go/pull/141) |
| 47 | +- Thanks to @xxmao123 and @starkers for the discussion and contribution of the NeoVim KCL extension 🙌 [https://github.com/kcl-lang/vim-kcl/pull/2](https://github.com/kcl-lang/vim-kcl/pull/2) |
| 48 | +- Thanks to @starkers for adding KCL installation support to the mason.nvim registry 🙌 [https://github.com/mason-org/mason-registry/pull/2425](https://github.com/mason-org/mason-registry/pull/2425) |
| 49 | +- Thanks to @prahaladramji for upgrading and updating the KCL Homebrew installation script 🙌 [https://github.com/kcl-lang/homebrew-tap/pull/1](https://github.com/kcl-lang/homebrew-tap/pull/1) |
| 50 | +- Thanks to @yamin-oanda for the discussion of Pulumi's official KCL support 🙌 [https://github.com/pulumi/pulumi/discussions/13722](https://github.com/pulumi/pulumi/discussions/13722) |
| 51 | +- In addition, thanks to @nkabir, @mihaigalos, @prahaladramji, @yamin-oanda, @magick93, @MirKml, and others for their valuable feedback and discussions while using KCL in the past two weeks. 🙌 |
| 52 | + |
| 53 | +## Featured Updates |
| 54 | + |
| 55 | +### KCL Import Tool Update |
| 56 | + |
| 57 | +The KCL Import Tool now adds support for converting Terraform Provider Schema to KCL Schema based on Protobuf, JsonSchema OpenAPI models, and Go Structures, such as the following Terraform Provider Json (obtained through the command `terraform providers schema -json > provider.json` , For more details, please refer to [https://developer.hashicorp.com/terraform/cli/commands/providers/schema](https://developer.hashicorp.com/terraform/cli/commands/providers/schema)) |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "format_version": "0.2", |
| 62 | + "provider_schemas": { |
| 63 | + "registry.terraform.io/aliyun/alicloud": { |
| 64 | + "provider": { |
| 65 | + "version": 0, |
| 66 | + "block": { |
| 67 | + "attributes": {}, |
| 68 | + "block_types": {}, |
| 69 | + "description_kind": "plain" |
| 70 | + } |
| 71 | + }, |
| 72 | + "resource_schemas": { |
| 73 | + "alicloud_db_instance": { |
| 74 | + "version": 0, |
| 75 | + "block": { |
| 76 | + "attributes": { |
| 77 | + "db_instance_type": { |
| 78 | + "type": "string", |
| 79 | + "description_kind": "plain", |
| 80 | + "computed": true |
| 81 | + }, |
| 82 | + "engine": { |
| 83 | + "type": "string", |
| 84 | + "description_kind": "plain", |
| 85 | + "required": true |
| 86 | + }, |
| 87 | + "security_group_ids": { |
| 88 | + "type": [ |
| 89 | + "set", |
| 90 | + "string" |
| 91 | + ], |
| 92 | + "description_kind": "plain", |
| 93 | + "optional": true, |
| 94 | + "computed": true |
| 95 | + }, |
| 96 | + "security_ips": { |
| 97 | + "type": [ |
| 98 | + "set", |
| 99 | + "string" |
| 100 | + ], |
| 101 | + "description_kind": "plain", |
| 102 | + "optional": true, |
| 103 | + "computed": true |
| 104 | + }, |
| 105 | + "tags": { |
| 106 | + "type": [ |
| 107 | + "map", |
| 108 | + "string" |
| 109 | + ], |
| 110 | + "description_kind": "plain", |
| 111 | + "optional": true |
| 112 | + } |
| 113 | + }, |
| 114 | + "block_types": {}, |
| 115 | + "description_kind": "plain" |
| 116 | + } |
| 117 | + }, |
| 118 | + "alicloud_config_rule": { |
| 119 | + "version": 0, |
| 120 | + "block": { |
| 121 | + "attributes": { |
| 122 | + "compliance": { |
| 123 | + "type": [ |
| 124 | + "list", |
| 125 | + [ |
| 126 | + "object", |
| 127 | + { |
| 128 | + "compliance_type": "string", |
| 129 | + "count": "number" |
| 130 | + } |
| 131 | + ] |
| 132 | + ], |
| 133 | + "description_kind": "plain", |
| 134 | + "computed": true |
| 135 | + }, |
| 136 | + "resource_types_scope": { |
| 137 | + "type": [ |
| 138 | + "list", |
| 139 | + "string" |
| 140 | + ], |
| 141 | + "description_kind": "plain", |
| 142 | + "optional": true, |
| 143 | + "computed": true |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + }, |
| 149 | + "data_source_schemas": {} |
| 150 | + } |
| 151 | + } |
| 152 | +} |
| 153 | +``` |
| 154 | + |
| 155 | +Then the tool can output the following KCL code |
| 156 | + |
| 157 | +```python |
| 158 | +""" |
| 159 | +This file was generated by the KCL auto-gen tool. DO NOT EDIT. |
| 160 | +Editing this file might prove futile when you re-run the KCL auto-gen generate command. |
| 161 | +""" |
| 162 | + |
| 163 | +schema AlicloudConfigRule: |
| 164 | + """ |
| 165 | + AlicloudConfigRule |
| 166 | +
|
| 167 | + Attributes |
| 168 | + ---------- |
| 169 | + compliance: [ComplianceObject], optional |
| 170 | + resource_types_scope: [str], optional |
| 171 | + """ |
| 172 | + |
| 173 | + compliance?: [ComplianceObject] |
| 174 | + resource_types_scope?: [str] |
| 175 | + |
| 176 | +schema ComplianceObject: |
| 177 | + """ |
| 178 | + ComplianceObject |
| 179 | +
|
| 180 | + Attributes |
| 181 | + ---------- |
| 182 | + compliance_type: str, optional |
| 183 | + count: int, optional |
| 184 | + """ |
| 185 | + |
| 186 | + compliance_type?: str |
| 187 | + count?: int |
| 188 | + |
| 189 | +schema AlicloudDbInstance: |
| 190 | + """ |
| 191 | + AlicloudDbInstance |
| 192 | +
|
| 193 | + Attributes |
| 194 | + ---------- |
| 195 | + db_instance_type: str, optional |
| 196 | + engine: str, required |
| 197 | + security_group_ids: [str], optional |
| 198 | + security_ips: [str], optional |
| 199 | + tags: {str:str}, optional |
| 200 | + """ |
| 201 | + |
| 202 | + db_instance_type?: str |
| 203 | + engine: str |
| 204 | + security_group_ids?: [str] |
| 205 | + security_ips?: [str] |
| 206 | + tags?: {str:str} |
| 207 | + |
| 208 | + check: |
| 209 | + isunique(security_group_ids) |
| 210 | + isunique(security_ips) |
| 211 | +``` |
| 212 | + |
| 213 | +### KCL Vault Integration |
| 214 | + |
| 215 | +In just three steps, we can use Vault to store and manage sensitive information and use it in KCL. |
| 216 | + |
| 217 | +Firstly, we install and use `Vault` to store `foo` and `bar` information |
| 218 | + |
| 219 | +```shell |
| 220 | +vault kv put secret/foo foo=foo |
| 221 | +vault kv put secret/bar bar=bar |
| 222 | +``` |
| 223 | + |
| 224 | +Then write the following KCL code (main.k) |
| 225 | + |
| 226 | +```python |
| 227 | +apiVersion = "apps/v1" |
| 228 | +kind = "Deployment" |
| 229 | +metadata = { |
| 230 | + name = "nginx" |
| 231 | + labels.app = "nginx" |
| 232 | + annotations: { |
| 233 | + "secret-store": "vault" |
| 234 | + # Valid format: |
| 235 | + # "ref+vault://PATH/TO/KV_BACKEND#/KEY" |
| 236 | + "foo": "ref+vault://secret/foo#/foo" |
| 237 | + "bar": "ref+vault://secret/bar#/bar" |
| 238 | + } |
| 239 | +} |
| 240 | +spec = { |
| 241 | + replicas = 3 |
| 242 | + selector.matchLabels = metadata.labels |
| 243 | + template.metadata.labels = metadata.labels |
| 244 | + template.spec.containers = [ |
| 245 | + { |
| 246 | + name = metadata.name |
| 247 | + image = "${metadata.name}:1.14.2" |
| 248 | + ports = [{ containerPort = 80 }] |
| 249 | + } |
| 250 | + ] |
| 251 | +} |
| 252 | +``` |
| 253 | + |
| 254 | +Finally, the decrypted configuration can be obtained through the `Vals` command-line tool |
| 255 | + |
| 256 | +```shell |
| 257 | +kcl main.k | vals eval -f - |
| 258 | +``` |
| 259 | + |
| 260 | +> For more details and use cases, please refer to [https://kcl-lang.io/docs/user_docs/guides/secret-management/vault](https://kcl-lang.io/docs/user_docs/guides/secret-management/vault) |
| 261 | +
|
| 262 | +## Community |
| 263 | + |
| 264 | +- 🎉 Congratulations to Zhu Junxing from Huazhong University of Science and Technology for successfully passing the mid-term assessment of the Gitlink Coding Summer Camp (GLCC) and completing the conversion of KCL Import tool Jsonschema and Terraform Provider Schema to KCL Schema. The community will grant him the KCL Community Maintainer role in the future. |
| 265 | +- 💻 KCL participated in the CNCF TAG Application Delivery community meeting and reported on the project. |
| 266 | + |
| 267 | +## Resources |
| 268 | + |
| 269 | +❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. We will write more articles on the new features of KCL v0.5.x, so stay tuned! |
| 270 | + |
| 271 | +For more resources, please refer to |
| 272 | + |
| 273 | +- [KCL Website](https://kcl-lang.io/) |
| 274 | +- [KusionStack Website](https://kusionstack.io/) |
| 275 | + |
| 276 | +- [KCL 2023 Roadmap](https://kcl-lang.io/docs/community/release-policy/roadmap) |
| 277 | +- [KCL v0.6.0 Milestone](https://github.com/kcl-lang/kcl/milestone/6) |
| 278 | +- [KCL Github Issues](https://github.com/kcl-lang/kcl/issues) |
| 279 | +- [KCL Github Discussion](https://github.com/orgs/kcl-lang/discussions) |
| 280 | +- [KCL Community](https://github.com/kcl-lang/community) |
0 commit comments