Skip to content

Commit

Permalink
Merge pull request #122 from Peefy/split-code-block-cmd-output
Browse files Browse the repository at this point in the history
feat: split code block cmd input and output for the convenience of copying commands.
  • Loading branch information
Peefy authored Jul 25, 2023
2 parents c7f1746 + c831840 commit 4b587fa
Show file tree
Hide file tree
Showing 92 changed files with 581 additions and 258 deletions.
18 changes: 14 additions & 4 deletions blog/2022-12-06-kcl-0.4.4-release-blog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ x1 = Person {

Execute the following command and get the output:

```bash
$ python3 -m kclvm hello.k
```shell
python3 -m kclvm hello.k
```

The expect output is

```yaml
name: kcl
age: 1
x0:
Expand All @@ -155,8 +160,13 @@ print(planner.plan(kclvm_exec.Run(["hello.k"]).filter_by_path_selector()))

Execute the following command and get the output:

```bash
$ python3 main.py
```shell
python3 main.py
```

The expect output is

```yaml
name: kcl
age: 1
x0:
Expand Down
21 changes: 18 additions & 3 deletions blog/2023-04-14-kcl-0.4.6-release/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ metadata = {
Execute the following KCL command, then you can see the syntax errors including the unterminated string and the brace mismatch errors.

```shell
$ kcl main.k
kcl main.k
```

The output is

```shell
error[E1001]: InvalidSyntax
--> main.k:2:21
|
Expand Down Expand Up @@ -121,7 +126,12 @@ person = Person {
We run the following command:

```shell
$ kcl main.k -S person
kcl main.k -S person
```

The output is

```yaml
name: Alice
age: 18
```
Expand Down Expand Up @@ -215,7 +225,12 @@ apps.Deployment {
Execute the following command to run the KCL code to obtain an nginx deployment YAML output.

```shell
$ kpm run
kpm run
```

The output is

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ spec = {

And then execute the KCL directly from the command line with:

```bash
$ kcl-go run ./hello.k
```shell
kcl-go run ./hello.k
```

The output is

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -112,8 +117,13 @@ go get kusionstack.io/kclvm-go@main

The following command runs the Go program:

```bash
$ go run main.go
```shell
go run main.go
```

The output is

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
33 changes: 25 additions & 8 deletions blog/2023-05-20-vs-kustomize/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ The base directory stores the basic deployment configuration, and the prod envir

We can display the real deployment configuration of the prod environment through the following command.

```bash
$ kubectl kustomize ./prod
```shell
kubectl kustomize ./prod
```

The output is

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -149,9 +154,13 @@ spec:
We can also directly apply the configuration to the cluster through the following command.
```bash
$ kubectl apply -k ./prod
```shell
kubectl apply -k ./prod
```

The output is

```shell
deployment.apps/ldap created
```

Expand Down Expand Up @@ -244,17 +253,25 @@ diff prod-deployment.yaml deployment.yaml

Of course, we can also use KCL tools together with kubectl and other tools to apply the configuration of the production environment to the cluster

```bash
$ kcl main.k -D env=prod | kubectl apply -f -
```shell
kcl main.k -D env=prod | kubectl apply -f -
```

The output is

```shell
deployment.apps/ldap created
```

Finally, check the deployment status through kubectl

```bash
$ kubectl get deploy
```shell
kubectl get deploy
```

The output is

```shell
NAME READY UP-TO-DATE AVAILABLE AGE
ldap 0/6 6 0 15s
```
Expand Down
27 changes: 21 additions & 6 deletions blog/2023-05-30-vs-helm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,13 @@ We can get the `Deployment` and `Service` resources throw the following command:

+ `Deployment`

```bash
$ kcl workload-kcl/deployment.k -Y workload-kcl/kcl.yaml
```shell
kcl workload-kcl/deployment.k -Y workload-kcl/kcl.yaml
```

The output is

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -401,8 +406,13 @@ spec:

+ `Service`

```bash
$ kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml
```shell
kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml
```

The output is

```yaml
apiVersion: v1
kind: Service
metadata:
Expand All @@ -425,8 +435,13 @@ spec:

In addition, we can overwrite the value in the `kcl.yaml` file with the `-D` parameter, such as executing the following command.

```bash
$ kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml -D service=None
```shell
kcl workload-kcl/service.k -Y workload-kcl/kcl.yaml -D service=None
```

The output is

```yaml
apiVersion: v1
kind: Service
metadata:
Expand Down
8 changes: 4 additions & 4 deletions blog/2023-06-05-k8s-sidecar-1/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:

The `Pod` is then created via the kubectl, and then the `Pod` execution status is viewed via `kubectl get po`.

```bash
```shell
$ kubectl create -f pod.yaml
$ kubectl get po
NAME READY STATUS RESTARTS AGE
Expand All @@ -45,7 +45,7 @@ web-app 1/1 Running 0 45m

You can see that a `Pod` named `web-app` is up and running properly, containing the `Nginx` service. To configure port forwarding for external access, the port 3999 of the host corresponds to port 80 of the master container:

```bash
```shell
$ kubectl port-forward web-app 3999:80
Forwarding from 127.0.0.1:3999 ->80
Forwarding from [::1]:3999 -> 80
Expand All @@ -59,7 +59,7 @@ Port forwarding is a blocking procedure, keep the command line open. Then open t

In this section, we try to add the ability to customize web pages to the `Nginx` service via Sidecar without modifying the original `Nginx` container image. Before we start, remove the previously started `Pod`:

```bash
```shell
$ kubectl delete po web-app
pod "web-app" deleted
```
Expand Down Expand Up @@ -113,7 +113,7 @@ The `Busybox` has only one function: it overwrites the `/var/log/index.html` fil

Then restart the Pod and remap the local host port to the container port.

```bash
```shell
$ kubectl create -f pod.yaml
pod/web-app created
$ kubectl port-forward web-app 3999:80
Expand Down
6 changes: 3 additions & 3 deletions blog/2023-07-14-kcl-0.5.0-release/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ kcl-openapi generate model -f processed-${spec_path}

The expected execution output of the script is the corresponding version of the KCL Kubernetes model, and the generated path is `<workspace path>/models/k8s`.

```bash
```shell
$ tree models/k8s
models/k8s
├── api
Expand Down Expand Up @@ -290,7 +290,7 @@ apps.Deployment {

By combining the `kpm run` and `kubectl` command lines, we can directly distribute resource configurations to the cluster.

```bash
```shell
$ kpm run | kubectl apply -f -

deployment.apps/nginx-deployment configured
Expand Down Expand Up @@ -420,7 +420,7 @@ spec:

In the above configuration, we used a Kubernetes web service application abstract model that has been predetermined on OCI `oci://ghcr.io/kcl-lang/web-service` and configured the required configuration fields for the model through the `params` field. The original Kubernetes YAML output can be obtained and applied by executing the following command:

```bash
```shell
$ kubectl kcl apply -f krm-kcl-abstration.yaml

deployment.apps/app created
Expand Down
21 changes: 18 additions & 3 deletions docs/reference/package-management/command-reference/6.login.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,37 @@ Show help for `kpm login` command.
### login to a registry with account and password

```shell
$ kpm login -u <account_name> -p <password> <oci_registry>
kpm login -u <account_name> -p <password> <oci_registry>
```

The output is

```shell
Login succeeded
```

### login to a registry with account, and enter the password interactively

```shell
$ kpm login -u <account_name> <oci_registry>
kpm login -u <account_name> <oci_registry>
```

The output is

```shell
Password:
Login succeeded
```

### login to a registry, and enter the account and password interactively

```shell
$ kpm login <oci_registry>
kpm login <oci_registry>
```

The output is

```shell
Username: <account_name>
Password:
Login succeeded
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/xlang-api/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ x1 = Person {

Execute the following command and get the output:

```bash
```shell
$ python3 -m kclvm hello.k
name: kcl
age: 1
Expand All @@ -162,7 +162,7 @@ print(planner.plan(kclvm_exec.Run(["hello.k"]).filter_by_path_selector()))

Execute the following command and get the output:

```bash
```shell
$ python3 main.py
name: kcl
age: 1
Expand Down
10 changes: 5 additions & 5 deletions docs/tools/cli/kcl/vet.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ schema Data:

Execute the following command:

```bash
$ kcl-vet data.json schema.k
```shell
kcl-vet data.json schema.k
```

## Specify the schema for validation

When multiple schema definitions exist in the KCL file, by default, the KCL Validation tool will use the first schema to check. If you need to specify a schema for verification, you can use the `-d|--schema` parameter

```bash
$ kcl-vet data.json schema.k -d User
```shell
kcl-vet data.json schema.k -d User
```

## Args

```bash
```shell
$ kcl-vet -h
USAGE:
kcl-vet [OPTIONS] [ARGS]
Expand Down
15 changes: 13 additions & 2 deletions docs/user_docs/getting-started/kcl-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ Set the `hello` attribute to the `"KCL"` string. Then save the code to the `hell
How to execute this program depends on the specific development environment, we first assume that the local macOS or Linux system has installed the `kcl` command (or enter the **Docker** environment test by `docker run --rm -it kcllang/kcl`) and then run the following command:

```shell
$ kcl hello.k
kcl hello.k
```

The output is


```yaml
hello: KCL
```
Expand Down Expand Up @@ -123,7 +129,12 @@ database = DatabaseConfig {
When executed, an error similar to the following will be generated (the displayed file path depends on the local environment):

```shell
$ kcl server.k
kcl server.k
```

The output is

```shell
error[E2G22]: TypeError
--> /path/to/server.k:8:5
|
Expand Down
Loading

0 comments on commit 4b587fa

Please sign in to comment.