Skip to content

Commit

Permalink
feat: refresh all documents
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Feb 4, 2024
1 parent d21c5b4 commit 9e7b39b
Show file tree
Hide file tree
Showing 47 changed files with 375 additions and 168 deletions.
12 changes: 6 additions & 6 deletions blog/2024-01-04-biweekly-newsletter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Thank you to all contributors for their outstanding work over the past two weeks

**Package Management Tool Update**

- Adds support for automatic translation of external package names containing the - symbol to an underscore _ that KCL recognizes, such as set-annotation -> set_annotation
- Adds support for automatic translation of external package names containing the - symbol to an underscore \_ that KCL recognizes, such as set-annotation -> set_annotation
- Fixes a null pointer error caused when kcl mod add encounters a mismatch between the Registry package version and the version of the package already present locally

**💻 IDE Update**
Expand Down Expand Up @@ -53,9 +53,9 @@ Crossplane and its XRs allow developers to create higher-level abstractions that

Combining KCL with Composition Functions offers several benefits:

+ **Simplification of Complex Configurations**: KCL provides a more concise syntax and structure as a DSL, reducing the complexity of configurations. When combined with Crossplane’s composite resources, you can create more intuitive and easy-to-understand configuration templates with loop and condition features, simplifying the definition and maintenance of resources instead of duplicate YAML and Go code snippets.
+ **Reusability and Modularity**: KCL supports modularity and code reuse through OCI Registry, which means you can create reusable configuration components. Combined with Crossplane, this promotes the modularity of composite resources, increases the reuse of configurations, and reduces errors.
+ **Automation and Policy-Driven**: You can use KCL’s powerful features to write policies and constraints that, combined with Crossplane’s declarative resource management, can be automatically enforced, ensuring compliance within the cloud environment.
- **Simplification of Complex Configurations**: KCL provides a more concise syntax and structure as a DSL, reducing the complexity of configurations. When combined with Crossplane’s composite resources, you can create more intuitive and easy-to-understand configuration templates with loop and condition features, simplifying the definition and maintenance of resources instead of duplicate YAML and Go code snippets.
- **Reusability and Modularity**: KCL supports modularity and code reuse through OCI Registry, which means you can create reusable configuration components. Combined with Crossplane, this promotes the modularity of composite resources, increases the reuse of configurations, and reduces errors.
- **Automation and Policy-Driven**: You can use KCL’s powerful features to write policies and constraints that, combined with Crossplane’s declarative resource management, can be automatically enforced, ensuring compliance within the cloud environment.

Additionally, you can refer to [here](https://kcl-lang.io/docs/user_docs/getting-started/intro#how-to-choose) to learn about the differences between KCL and other configuration formats or DSLs.

Expand Down Expand Up @@ -204,14 +204,14 @@ EOF

##### 5. Verify the Generated Managed Resources

+ VPC
- VPC

```shell
kubectl get VPC -o yaml | grep network-id
networks.meta.fn.crossplane.io/network-id: network-test-functions
```

+ InternetGateway
- InternetGateway

```shell
kubectl get InternetGateway -o yaml | grep network-id
Expand Down
8 changes: 6 additions & 2 deletions blog/2024-01-18-biweekly-newsletter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ Thank you to all contributors for their outstanding work over the past two weeks

**🎁 API Update**

- Added APIs for syntax and semantic analysis
- Added APIs for syntax and semantic analysis

**🔧 Toolchain Update**

- **kcl-go sdk update**

- KCL Doc tool supports output in OpenAPI format.
- Added Parsing related APIs.

- **Import tool update**

- Optimized the user experience of the import tool to generate KCL, and added support for keywords oneOf and allOf.

- **KCL Package Management Tool**
Expand All @@ -43,6 +45,7 @@ Thank you to all contributors for their outstanding work over the past two weeks
**💻 IDE Update**

- **Semantic Highlighting**

- KCL IDE optimized semantic highlighting.

- **Enhancement for Completion Features**
Expand Down Expand Up @@ -74,10 +77,11 @@ For more information about the KCL semantic architecture model, please refer to:

### KCL Package Management Tool Supports Adding Git Dependencies via Commit

KCL Package Management Tool supports adding git dependencies via commit.
KCL Package Management Tool supports adding git dependencies via commit.
Take https://github.com/KusionStack/catalog as an example, add commit a29e3db as a dependency. You can add it directly through the dependency in the kcl.mod file or the command line.

Edit the kcl.mod file as follows:

```
[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", commit = "a29e3db" }
Expand Down
19 changes: 10 additions & 9 deletions blog/2024-02-21-biweekly-newsletter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ kcl run oci://ghcr.io/kcl-lang/podinfo -D replicas=2

- Improved error messages when object attribute are not found at compile time.
- Fixed the recursive check error for mandatory attribute of schema objects.
- Enhanced the robustness of type-checking for schema index signatures.
- Enhanced the robustness of type-checking for schema index signatures.

**🔧 Toolchain Updates**

Expand All @@ -42,11 +42,12 @@ kcl run oci://ghcr.io/kcl-lang/podinfo -D replicas=2
**💻 IDE Updates**

- **Semantic Highlighting**

- KCL IDE optimized semantic highlighting.

- **Enhancement for Completion Features**
- Fixed the issue with erroneous completions after strings followed by comments.
- Fixed the issue where internal property symbols in Schema could not be navigated.
- Fixed the issue with erroneous completions after strings followed by comments.
- Fixed the issue where internal property symbols in Schema could not be navigated.

**🎁 API Updates**

Expand Down Expand Up @@ -84,9 +85,9 @@ The following are listed in no particular order:

Using KCL together with GitOps tools like Flux has the following benefits:

+ The abstraction and programmability capabilities of KCL can help simplify complex Kubernetes deployment configurations, reducing the error rate of manually writing YAML files. It allows for configuration constraint checks at compile-time, making it easier to detect errors. Additionally, it eliminates redundant configuration templates, improves the scalability of configurations across multiple environments and tenants, and enhances configurability and maintainability.
+ KCL allows developers to define the required resources for an application in a declarative manner. Combining KCL with Flux enables better implementation of Infrastructure as Code (IaC), improving deployment efficiency and simplifying application configuration management.
+ With Flux, developers and operations teams can manage the deployment of applications by separately modifying application and configuration code. The Flux Controller automatically synchronizes changes to the configuration, enabling continuous deployment and ensuring consistency. In case of issues, quick rollbacks can be achieved.
- The abstraction and programmability capabilities of KCL can help simplify complex Kubernetes deployment configurations, reducing the error rate of manually writing YAML files. It allows for configuration constraint checks at compile-time, making it easier to detect errors. Additionally, it eliminates redundant configuration templates, improves the scalability of configurations across multiple environments and tenants, and enhances configurability and maintainability.
- KCL allows developers to define the required resources for an application in a declarative manner. Combining KCL with Flux enables better implementation of Infrastructure as Code (IaC), improving deployment efficiency and simplifying application configuration management.
- With Flux, developers and operations teams can manage the deployment of applications by separately modifying application and configuration code. The Flux Controller automatically synchronizes changes to the configuration, enabling continuous deployment and ensuring consistency. In case of issues, quick rollbacks can be achieved.

#### Workflow

Expand All @@ -111,16 +112,16 @@ The overall workflow is as follows:

##### 1. Prepare a Kubernetes Cluster

+ Install [K3d](https://github.com/k3d-io/k3d) and create a cluster:
- Install [K3d](https://github.com/k3d-io/k3d) and create a cluster:

```shell
k3d cluster create
```

> Note: You can use other methods to create your own Kubernetes cluster, such as kind, minikube, etc.
+ Install kubectl
+ Install kustomize
- Install kubectl
- Install kustomize

##### 2. Install Flux KCL Controller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ kcl mod update [options][module_name]

You can also update a package by specifying the path of that package.


## Options

### --help, -h
Expand Down
6 changes: 3 additions & 3 deletions docs/user_docs/getting-started/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ Pkl is a configuration as code language that has programmable, extensible, and s
There some similarities between KCL and Pkl here:
+ Language features: schema, validation, immutability, etc.
+ Multi language binding, KCL provides binding for Python, Go, and Java, etc. and Pkl providers others.
+ Multiple IDE plugin support: NeoVim, VS Code, etc.
- Language features: schema, validation, immutability, etc.
- Multi language binding, KCL provides binding for Python, Go, and Java, etc. and Pkl providers others.
- Multiple IDE plugin support: NeoVim, VS Code, etc.
Differently, KCL provides more relevant integration with cloud native tools and model code libraries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21

- name: Install KCL CLI
run: go install kcl-lang.io/cli/cmd/kcl@latest
Expand Down
19 changes: 13 additions & 6 deletions docs/user_docs/guides/package-management/4-how-to/8-kcl_mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The `kcl.mod` file for each module is called its manifest. It is written in the TOML format. It contains metadata that is needed to compile the module.

In the MVP version, the sections we plan to support are as follows:

- Package metadata:
- [package](#package) - Defines a package.
- [name](#package) — The name of the package.
Expand Down Expand Up @@ -44,28 +45,29 @@ You can specify a dependency from git repository by git tag.

```toml
[dependencies]
<package name> = { git = "<git repo url>", tag = "<git repo tag>" }
<package name> = { git = "<git repo url>", tag = "<git repo tag>" }
```

You can specify a dependency from git repository by git commit id.

```toml
[dependencies]
<package name> = { git = "<git repo url>", commit = "<git repo commit>" }
```
<package name> = { git = "<git repo url>", commit = "<git repo commit>" }
```

You can specify a dependency from local file path.

```toml
# Find the kcl.mod under "./xxx/xxx".
[dependencies]
<package name> = {path = "<package local path>"}
<package name> = {path = "<package local path>"}
```

## entries

You can specify the entry points of the package when compiling.

`entries` is a sub section of `profile` section.
`entries` is a sub section of `profile` section.

```toml
[profile]
Expand Down Expand Up @@ -100,30 +102,34 @@ entries = [
]
```

The `mod relative paths` must contains the preffix `${k8s:KCL_MOD}`, `k8s` is the package name, `${k8s:KCL_MOD}` means the package root path of the package `k8s`. Therefore, if the package root path of `k8s` is `/.kcl/kpm/k8s`, the `entries` show above will take `/usr/my_pkg/entry1.k`, `/usr/my_pkg/subdir/entry2.k` and `/.kcl/kpm/k8s/core/api/v1/deployment.k` as the entry point of the kcl compiler.
The `mod relative paths` must contains the preffix `${k8s:KCL_MOD}`, `k8s` is the package name, `${k8s:KCL_MOD}` means the package root path of the package `k8s`. Therefore, if the package root path of `k8s` is `/.kcl/kpm/k8s`, the `entries` show above will take `/usr/my_pkg/entry1.k`, `/usr/my_pkg/subdir/entry2.k` and `/.kcl/kpm/k8s/core/api/v1/deployment.k` as the entry point of the kcl compiler.

### Note

You can use `normal path` to specify the compilation entry point in the current package path, and use `mod relative path` to specify the entry point in a third-party package.

Therefore, the file path specified by `normal path` must come from the same package, that is, the `kcl.mod` path found from the normal path must only find one `kcl.mod` file, otherwise the compiler will output an error.

For example:

In the path `/usr/kcl1`:

```
/usr/kcl1
|--- kcl.mod
|--- entry1.k
```

In the path `/usr/kcl2`:

```
/usr/kcl2
|--- kcl.mod
|--- entry2.k
```

If you compile with this `kcl.mod` in the path `/usr/kcl1`:

```
entries = [
"entry1.k", # The corresponding kcl.mod file is /usr/kcl1/kcl.mod
Expand All @@ -132,6 +138,7 @@ entries = [
```

You will get an error:

```
error[E3M38]: conflict kcl.mod file paths
```
14 changes: 7 additions & 7 deletions docs/user_docs/guides/package-management/4-how-to/9-kpm_oci.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The default content of the configuration file is as follows:

```json
{
"DefaultOciRegistry":"ghcr.io",
"DefaultOciRepo":"kcl-lang",
"DefaultOciPlainHttp":true
"DefaultOciRegistry": "ghcr.io",
"DefaultOciRepo": "kcl-lang",
"DefaultOciPlainHttp": true
}
```

Expand Down Expand Up @@ -95,9 +95,9 @@ You can use `kcl mod push` to upload a KCL package to an OCI Registry.

```shell
# Create a new kcl package.
$ kcl mod init <package_name>
$ kcl mod init <package_name>
# Enter the root directory of the kcl package
$ cd <package_name>
$ cd <package_name>
# Upload the kcl package to an oci registry
$ kcl mod push
```
Expand All @@ -114,9 +114,9 @@ You can also specify the url of the OCI registry in the `kcl mod push` command.

```shell
# Create a new kcl package.
$ kcl mod init <package_name>
$ kcl mod init <package_name>
# Enter the root directory of the kcl package
$ cd <package_name>
$ cd <package_name>
# Upload the kcl package to an oci registry
$ kcl mod push <oci_url>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Crossplane and Crossplane Composite Functions are used to decouple XR and Compos

Combining KCL with Crossplane composite functions offers several benefits:

+ **Simplification of Complex Configurations**: KCL provides a more concise syntax and structure as a DSL, reducing the complexity of configurations. When combined with Crossplane’s composite resources, you can create more intuitive and easy-to-understand configuration templates with loop and condition features, simplifying the definition and maintenance of resources instead of duplicate YAML and Go code snippets.
+ **Reusability and Modularity**: KCL supports modularity and code reuse through OCI Registry, which means you can create reusable configuration components. Combined with Crossplane, this promotes the modularity of composite resources, increases the reuse of configurations, and reduces errors.
+ **Automation and Policy-Driven**: You can use KCL’s powerful features to write policies and constraints that, combined with Crossplane’s declarative resource management, can be automatically enforced, ensuring compliance within the cloud environment.
- **Simplification of Complex Configurations**: KCL provides a more concise syntax and structure as a DSL, reducing the complexity of configurations. When combined with Crossplane’s composite resources, you can create more intuitive and easy-to-understand configuration templates with loop and condition features, simplifying the definition and maintenance of resources instead of duplicate YAML and Go code snippets.
- **Reusability and Modularity**: KCL supports modularity and code reuse through OCI Registry, which means you can create reusable configuration components. Combined with Crossplane, this promotes the modularity of composite resources, increases the reuse of configurations, and reduces errors.
- **Automation and Policy-Driven**: You can use KCL’s powerful features to write policies and constraints that, combined with Crossplane’s declarative resource management, can be automatically enforced, ensuring compliance within the cloud environment.

## Prerequisites

Expand Down Expand Up @@ -158,14 +158,14 @@ EOF

### 5. Verify the Generated Managed Resources

+ VPC
- VPC

```shell
kubectl get VPC -o yaml | grep network-id
networks.meta.fn.crossplane.io/network-id: network-test-functions
```

+ InternetGateway
- InternetGateway

```shell
kubectl get InternetGateway -o yaml | grep network-id
Expand Down Expand Up @@ -221,12 +221,12 @@ spec:
Here's what you can do in the KCL script:
+ Return an error using `assert {condition}, {error_message}`.
+ Read the `ObservedCompositeResource` from `option("params").oxr`.
+ Read the `ObservedComposedResources` from `option("params").ocds`.
+ Read the `DesiredCompositeResource` from `option("params").dxr`.
+ Read the `DesiredComposedResources` from `option("params").dcds`.
+ Read the environment variables. e.g. `option("PATH")` (**Not yet implemented**).
- Return an error using `assert {condition}, {error_message}`.
- Read the `ObservedCompositeResource` from `option("params").oxr`.
- Read the `ObservedComposedResources` from `option("params").ocds`.
- Read the `DesiredCompositeResource` from `option("params").dxr`.
- Read the `DesiredComposedResources` from `option("params").dcds`.
- Read the environment variables. e.g. `option("PATH")` (**Not yet implemented**).

## Library

Expand Down
12 changes: 6 additions & 6 deletions docs/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,7 @@ schema Data:

## 52. How to output pretty json string in KCL?

KCL has in-built support for getting formatted JSON strings. Here's how you can do it:
KCL has in-built support for getting formatted JSON strings. Here's how you can do it:

Paste the below content in your main.k file.

Expand All @@ -2369,7 +2369,7 @@ config = {
configJson = json.encode(config, ignore_private=True, indent=4)
```

After running this code, `configJson` variable will contain a prettified JSON string.
After running this code, `configJson` variable will contain a prettified JSON string.

```json
config:
Expand All @@ -2394,7 +2394,7 @@ import crypto

schema Person:
a: int

aa = Person {a = 1}
bb = Person {a = 2}
cc = Person {a = 2}
Expand All @@ -2403,7 +2403,7 @@ bbhash = crypto.md5(str(bb))
cchash = crypto.md5(str(cc))
```

After running above script, You'll get output like this:
After running above script, You'll get output like this:

```bash
aa:
Expand All @@ -2430,12 +2430,12 @@ data = to_set(["aa", "bb", "bb", "cc"])
dataIsUnique = isunique(data)
```

After running above script, You'll get output like this:
After running above script, You'll get output like this:

```bash
data:
- aa
- bb
- cc
dataIsUnique: true
```
```
Loading

0 comments on commit 9e7b39b

Please sign in to comment.