
# oscctl工具使用
oscctl是一款用于生成华为云OSC服务包脚手架或者将开源Helm或Operator服务包转换为OSC服务包的命令行工具。
#### 工具安装
下载链接：<https://oscctl.obs.cn-east-3.myhuaweicloud.com/oscctl-22.6.23.tar.gz>
将下载后的oscctl工具安装包解压至本地后，将二进制文件oscctl复制到系统PATH路径下，使用下面的命令获取帮助信息：
```
$ oscctl --help
oscctl is a command-line tool that facilitates working with OSC packages, it can be used to
create a new OSC package scaffold from scratch or convert preexisting Helm or Operator package to OSC package.
Usage:
  oscctl [command]
Available Commands:
  convert     Converts a preexisting Helm or Operator package to an OSC package
  create      Creates a new OSC package scaffold from scratch
  help        Help about any command
Flags:
  -h, --help   help for oscctl
Use "oscctl [command] --help" for more information about a command.
```
#### 创建服务包模板
在oscctl命令后添加子命令create用以创建华为云OSC服务包脚手架文件，使用--help可查看其支持的flag选项。
```
$ oscctl create --help
Creates a new OSC package scaffold from scratch, the scaffold will have a file structure and content
that satisfies OSC service package specification. Developers can modify the file content of the scaffold
to construct a package that's ready to use.
Usage:
  oscctl create [flags]
Flags:
  -h, --help            help for create
  -o, --output string   specify path to store the created or converted OSC package along with the package name
```
示例：
```
$ oscctl create --output "./NewOSCPackage"
```
此命令将在工作目录下创建文件夹NewOSCPackage，其中包含OSC服务包必要的文件。
 #### 服务包转换
在oscctl命令后添加子命令convert用以将开源helm或operator服务包，使用--help可查看其支持的flag选项。
```
$ oscctl convert --help
Converts a preexisting Helm or Operator package to an OSC package, oscctl is able to distinguish helm and
operator package by detecting a Chart.yaml file in Helm package or a file with .package.yaml suffix in Operator package
Usage:
  oscctl convert [flags]
Flags:
  -h, --help            help for convert
  -i, --input string    specify path of the original package.
  -o, --output string   specify path to store the created or converted OSC package along with the package name
```
示例：
```
$ oscctl convert --input "./KafkaPackage.tgz" --output "./OSCPackage"
$ oscctl convert --input "./KafkaPackage" --output "./OSCPackage.zip"
$ oscctl convert --input "./KafkaPackage.tgz" --output "./OSCPackage.tgz"
```
上述命令将helm包KafkaPackage转换为OSC服务包，--input和--output均可为输入目录或者压缩包，oscctl会根据参数是否存在文件扩展名及扩展名类型自动判断并进行转换。现支持tgz和zip类型的压缩包输入和输出。
![](https://support.huaweicloud.com/devg-osc/public_sys-resources/note_3.0-zh-cn.png)
oscctl转换工具，可以帮助已经拥有helm或者operator-framework类型的服务包，快速转换为OSC格式，从而对接运维和表单控件能力，对接能力参考[对接运维能力(可选)](https://support.huaweicloud.com/devg-osc/osc_ss_0036.html)和[配置表单控件](https://support.huaweicloud.com/devg-osc/osc_ss_0043.html)。如无此诉求，可直接将原生服务包上传验证即可。
