-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jakezhu9 <[email protected]>
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# kpm import | ||
|
||
将其它格式的文件转换为 kcl 文件。 | ||
|
||
## 使用 | ||
|
||
```shell | ||
kpm import [options] <file> | ||
``` | ||
|
||
## 介绍 | ||
|
||
`kpm import` 会从指定的文件中读取内容,并将其转换为 kcl 文件。 | ||
|
||
## 选项 | ||
|
||
### --mode, -m | ||
|
||
指定转换模式,默认值为 `auto`,以下是支持的模式: | ||
|
||
- `json`: 将 json 数据转换为 kcl 数据。 | ||
- `yaml`: 将 yaml 数据转换为 kcl 数据。 | ||
- `gostruct`: 将 go 结构体转换为 kcl schema。 | ||
- `jsonschema`: 将 json schema 转换为 kcl schema。 | ||
- `terraformschema`: 将 terraform provider schema 转换为 kcl schema。关于如何获取 terraform provider schema 文件,请参考 [terraform schema](https://developer.hashicorp.com/terraform/cli/commands/providers/schema)。 | ||
- `auto`: 自动检测文件类型,并使用对应的转换模式。 | ||
|
||
### --output, -o | ||
|
||
指定输出文件名,默认值为 `generated.k`。 | ||
|
||
### --force, -f | ||
|
||
强制覆盖输出文件。 | ||
|
||
### --help, -h | ||
|
||
展示 `kpm import` 命令的帮助信息。 | ||
|
||
## 示例 | ||
|
||
使用 `kpm import` 将 yaml 数据转换为 kcl 数据。 | ||
|
||
``` | ||
$ cat <<EOF > foo.yaml | ||
kind: Service | ||
name: kcl | ||
EOF | ||
$ kpm import foo.yaml | ||
$ cat generated.k | ||
""" | ||
This file was generated by the KCL auto-gen tool. DO NOT EDIT. | ||
Editing this file might prove futile when you re-run the KCL auto-gen generate command. | ||
""" | ||
kind = "Service" | ||
name = "kcl" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# kpm import | ||
|
||
Convert files in other formats to kcl files. | ||
|
||
## Usage | ||
|
||
```shell | ||
kpm import [options] <file> | ||
``` | ||
|
||
## Description | ||
|
||
`kpm import` reads content from the specified file and converts it into a kcl file. | ||
|
||
## Options | ||
|
||
### --mode, -m | ||
|
||
Specify the conversion mode. Default value is `auto`. The following modes are supported: | ||
|
||
- `json`: Convert json data to kcl data. | ||
- `yaml`: Convert yaml data to kcl data. | ||
- `gostruct`: Convert go structures to kcl schema. | ||
- `jsonschema`: Convert json schema to kcl schema. | ||
- `terraformschema`: Convert terraform provider schema to kcl schema. For how to obtain terraform provider schema files, refer to [terraform schema](https://developer.hashicorp.com/terraform/cli/commands/providers/schema). | ||
- `auto`: Automatically detect the file type and use the corresponding conversion mode. | ||
|
||
### --output, -o | ||
|
||
Specify the output file name. Default value is `generated.k`. | ||
|
||
### --force, -f | ||
|
||
Force overwrite of the output file. | ||
|
||
### --help, -h | ||
|
||
Display help information for the `kpm import` command. | ||
|
||
## Examples | ||
|
||
Use `kpm import` to convert yaml data to kcl data. | ||
|
||
``` | ||
$ cat <<EOF > foo.yaml | ||
kind: Service | ||
name: kcl | ||
EOF | ||
$ kpm import foo.yaml | ||
$ cat generated.k | ||
""" | ||
This file was generated by the KCL auto-gen tool. DO NOT EDIT. | ||
Editing this file might prove futile when you re-run the KCL auto-gen generate command. | ||
""" | ||
kind = "Service" | ||
name = "kcl" | ||
``` |