Skip to content

Commit 2cecb28

Browse files
authored
Merge pull request #454 from zong-zhe/refactor-kpm-doc
refactor: refactored the documentation for kpm's interaction with Oci…
2 parents d51de9f + be1a185 commit 2cecb28

File tree

30 files changed

+719
-757
lines changed

30 files changed

+719
-757
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Use an Git-based repository
2+
3+
KCL package management tool supports saving and sharing KCL modules through the OCI registry and Git repository. This section will introduce how to integrate the KCL package management tool with the Git repository.
4+
5+
kpm does not provide the interaction between login/logout/push/pull and Git repository because users can use Git command line tools to login, logout, push, pull and other functions during interaction with Git repository. kpm only provides the ability to add a Git repository as a dependency to the a KCL package.
6+
7+
## Private Git Repository
8+
9+
KCL package management tool depends on the Git tool in the local environment to interact with the Git repository. Therefore, before using the KCL package management tool, ensure the Git tool is installed in the local environment and the Git command can be found in the environment variable $PATH.
10+
11+
More Details - [How to Install Git Tool](https://git-scm.com/downloads)
12+
13+
KCL package management tool shares the same login credentials with the Git tool in the local environment. When you use the KCL package management tool to interact with a private Git repository, you need to check whether the Git tool can interact with the private Git repository normally. If you can successfully download the private Git repository using the `git clone` command, you can directly use the KCL package management tool without any login operation.
14+
15+
More Details - [Download Private Repository Using Git](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
16+
17+
## Add a Git Repository as a Dependency
18+
19+
You can use `kcl mod add` to add a Git repository as a dependency to the KCL package.
20+
21+
Take `https://github.com/kcl-lang/konfig` as an example. The command is as follows:
22+
23+
```shell
24+
kcl mod add git://github.com/kcl-lang/konfig --tag v0.4.0 # Add a Git repository with a tag
25+
kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git repository with a commit
26+
kcl mod add git://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch
27+
```
28+
29+
The way shown above is to add a Git repository as a dependency with Https protocol.
30+
You can also use the `ssh` protocol or some other protocols to add a Git repository as a dependency as follows:
31+
32+
```shell
33+
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0 # Add a Git repository with a tag and Https protocol
34+
kcl mod add --git https://github.com/kcl-lang/konfig --branch main # Add a Git repository with a branch and Https protocol
35+
kcl mod add --git ssh://github.com/kcl-lang/konfig --commit 78ba6e9 # Add a Git repository with a commit and ssh protocol
36+
```
37+
38+

docs/user_docs/guides/package-management/4-how-to/10-private_mod_repo.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

docs/user_docs/guides/package-management/4-how-to/9-kpm_oci.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Support for OCI Registries
1+
# Use an OCI-based registry
22

33
KCL package management tool supports saving and sharing KCL packages through OCI Registries.
44

@@ -25,15 +25,13 @@ You can adjust the registry and repository name of the OCI registry by the follo
2525

2626
### By environment variable
2727

28-
You can adjust the configuration of OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`, and `OCI_REG_PLAIN_HTTP`.
28+
You can adjust the configuration of OCI Registry by setting the three environment variables `KPM_REG`, `KPM_REGO`.
2929

3030
```shell
3131
# set default registry
3232
export KPM_REG="ghcr.io"
3333
# set default repository
3434
export KPM_REPO="kcl-lang"
35-
# set support for 'http'
36-
export OCI_REG_PLAIN_HTTP=off
3735
```
3836

3937
### By configuration file
@@ -46,7 +44,6 @@ The default content of the configuration file is as follows:
4644
{
4745
"DefaultOciRegistry": "ghcr.io",
4846
"DefaultOciRepo": "kcl-lang",
49-
"DefaultOciPlainHttp": true
5047
}
5148
```
5249

@@ -184,6 +181,32 @@ For the example, the command is as follows:
184181
kcl mod pull oci://localhost:5001/test/MyPkg --tag v0.1.0
185182
```
186183

184+
### `kcl mod add` to add a KCL package from OCI registry as a dependency
185+
186+
You can use `kcl mod add` to add a KCL package from the default OCI registry. KPM will automatically search for the kcl package from the OCI registry in `kpm.json`.
187+
188+
```shell
189+
kcl mod add <package_name>:<package_version>
190+
```
191+
192+
For the example, the command is as follows:
193+
194+
```shell
195+
kcl mod add MyPkg:v0.1.0
196+
```
197+
198+
Or, you can download a kcl package from the specified OCI registry url.
199+
200+
```shell
201+
kcl mod add <oci_url>
202+
```
203+
204+
For the example, the command is as follows:
205+
206+
```shell
207+
kcl mod add oci://localhost:5001/test/MyPkg --tag v0.1.0
208+
```
209+
187210
### `kcl run` to compile a KCL package
188211

189212
KCL package management tool can directly compile a kcl package through the url of OCI.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 使用 Git 仓库
2+
3+
KCL 包管理工具支持通过 OCI registry 和 Git 仓库保存和分享 KCL 包。本文将介绍如何使用 KCL 包管理工具与私有 OCI registry 和 Git 仓库集成。由于 Git 命令行工具提供了登录/push/pull等功能,因此,KCL 包管理工具将不再提供同样的功能,KCL 包管理工具仅支持通过 `kcl mod add` 命令将 git 仓库添加为当前 KCL 包的三方库。
4+
5+
## 私有 Git 仓库
6+
7+
KCL 包管理工具依赖本地环境中的 Git 工具完成与 Git 仓库的交互。因此,在使用 KCL 包管理工具之前,确保本地环境中完成了 Git 工具的安装,并且在环境变量 $PATH 中能够找到 Git 命令。
8+
9+
更多信息 - [如何安装 Git 工具](https://git-scm.com/downloads)
10+
11+
KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,当您使用 KCL 包管理工具与私有 Git 仓库交互时,您需要先检查 Git 工具能否正常与私有 Git 仓库交互。如果您使用 `git clone` 命令能够成功下载私有 Git 仓库,您可以直接使用 KCL 包管理工具而不需要进行任何登录操作。
12+
13+
更多信息 - [使用 Git 下载私有仓库](https://docs.github.com/zh/repositories/creating-and-managing-repositories/cloning-a-repository)
14+
15+
## 添加 Git 仓库作为一个三方库依赖
16+
17+
你可以使用 `kcl mod add` 命令将 Git 仓库添加为当前 KCL 包的三方库依赖。
18+
19+
`https://github.com/kcl-lang/konfig` 为例,命令如下:
20+
21+
```shell
22+
kcl mod add git://github.com/kcl-lang/konfig --tag v0.4.0 # 添加一个带有 tag 的 Git 仓库
23+
kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # 添加一个带有 commit 的 Git 仓库
24+
kcl mod add git://github.com/kcl-lang/konfig --branch main # 添加一个带有 branch 的 Git 仓库
25+
```
26+
27+
如上所示的方式是使用 Https 协议将 Git 仓库添加为一个依赖。你也可以使用 `ssh` 协议或其他协议将 Git 仓库添加为一个依赖,如下所示:
28+
29+
```shell
30+
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0 # 添加一个带有 tag 的 Git 仓库和 Https 协议
31+
kcl mod add --git https://github.com/kcl-lang/konfig --branch main # 添加一个带有 branch 的 Git 仓库和 Https 协议
32+
kcl mod add --git ssh://github.com/kcl-lang/konfig --commit 78ba6e9 # 添加一个带有 commit 的 Git 仓库和 ssh 协议
33+
```

i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/10-mod_private_repo.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/guides/package-management/4-how-to/9-kpm_oci.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 支持 OCI Registries
1+
# 使用 OCI Registries
22

33
KCL 包管理工具支持通过 OCI Registries 保存和分享 KCL 包。
44

@@ -25,15 +25,13 @@ KCL 包管理工具默认使用 ghcr.io 保存 KCL 包。
2525

2626
### 通过环境变量
2727

28-
你可以通过设置三个环境变量 KPM_REG、KPM_REGO 和 OCI_REG_PLAIN_HTTP 来调整配置。
28+
你可以通过设置三个环境变量 KPM_REG、KPM_REGO 来调整配置。
2929

3030
```shell
3131
# 设置默认仓库地址
3232
export KPM_REG="ghcr.io"
3333
# 设置默认仓库
3434
export KPM_REPO="kcl-lang"
35-
# 设置支持 'http'
36-
export OCI_REG_PLAIN_HTTP=off
3735
```
3836

3937
### 通过配置文件
@@ -46,7 +44,6 @@ KCL 包管理工具的配置文件位于 `$KCL_PKG_PATH/.kpm/config/kpm.json`,
4644
{
4745
"DefaultOciRegistry": "ghcr.io",
4846
"DefaultOciRepo": "kcl-lang",
49-
"DefaultOciPlainHttp": true
5047
}
5148
```
5249

@@ -185,6 +182,32 @@ kcl mod pull <oci_url>
185182
kcl mod pull oci://localhost:5001/test/MyPkg --tag v0.1.0
186183
```
187184

185+
### kcl mod add
186+
187+
你可以使用 `kcl mod add` 从默认的 OCI registry 中添加一个 kcl 包作为当前 kcl 包的三方依赖。kpm 会自动从 `kpm.json` 中的 OCI registry 中寻找 kcl 包。
188+
189+
```shell
190+
kcl mod add <package_name>:<package_version>
191+
```
192+
193+
对于示例来说,命令如下:
194+
195+
```shell
196+
kcl mod add MyPkg:v0.1.0
197+
```
198+
199+
或者,你也可以从指定的 OCI registry url 中下载一个 kcl 包。
200+
201+
```shell
202+
kcl mod add <oci_url>
203+
```
204+
205+
对于示例来说,命令如下:
206+
207+
```shell
208+
kcl mod add oci://localhost:5001/test/MyPkg --tag v0.1.0
209+
```
210+
188211
### kcl run
189212

190213
KCL 可以直接通过 OCI 的 url 编译 kcl 包。
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 使用 Git 仓库
2+
3+
KCL 包管理工具支持通过 OCI registry 和 Git 仓库保存和分享 KCL 包。本文将介绍如何使用 KCL 包管理工具与私有 OCI registry 和 Git 仓库集成。由于 Git 命令行工具提供了登录/push/pull等功能,因此,KCL 包管理工具将不再提供同样的功能,KCL 包管理工具仅支持通过 `kcl mod add` 命令将 git 仓库添加为当前 KCL 包的三方库。
4+
5+
## 私有 Git 仓库
6+
7+
KCL 包管理工具依赖本地环境中的 Git 工具完成与 Git 仓库的交互。因此,在使用 KCL 包管理工具之前,确保本地环境中完成了 Git 工具的安装,并且在环境变量 $PATH 中能够找到 Git 命令。
8+
9+
更多信息 - [如何安装 Git 工具](https://git-scm.com/downloads)
10+
11+
KCL 包管理工具与本地环境中的 Git 工具公用一份登录凭证,当您使用 KCL 包管理工具与私有 Git 仓库交互时,您需要先检查 Git 工具能否正常与私有 Git 仓库交互。如果您使用 `git clone` 命令能够成功下载私有 Git 仓库,您可以直接使用 KCL 包管理工具而不需要进行任何登录操作。
12+
13+
更多信息 - [使用 Git 下载私有仓库](https://docs.github.com/zh/repositories/creating-and-managing-repositories/cloning-a-repository)
14+
15+
## 添加 Git 仓库作为一个三方库依赖
16+
17+
你可以使用 `kcl mod add` 命令将 Git 仓库添加为当前 KCL 包的三方库依赖。
18+
19+
`https://github.com/kcl-lang/konfig` 为例,命令如下:
20+
21+
```shell
22+
kcl mod add git://github.com/kcl-lang/konfig --tag v0.4.0 # 添加一个带有 tag 的 Git 仓库
23+
kcl mod add git://github.com/kcl-lang/konfig --commit 78ba6e9 # 添加一个带有 commit 的 Git 仓库
24+
kcl mod add git://github.com/kcl-lang/konfig --branch main # 添加一个带有 branch 的 Git 仓库
25+
```
26+
27+
如上所示的方式是使用 Https 协议将 Git 仓库添加为一个依赖。你也可以使用 `ssh` 协议或其他协议将 Git 仓库添加为一个依赖,如下所示:
28+
29+
```shell
30+
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0 # 添加一个带有 tag 的 Git 仓库和 Https 协议
31+
kcl mod add --git https://github.com/kcl-lang/konfig --branch main # 添加一个带有 branch 的 Git 仓库和 Https 协议
32+
kcl mod add --git ssh://github.com/kcl-lang/konfig --commit 78ba6e9 # 添加一个带有 commit 的 Git 仓库和 ssh 协议
33+
```

0 commit comments

Comments
 (0)