├── .eslintrc
├── .github
├── dependabot.yml
└── workflows
│ ├── codeql.yml
│ └── node.js.yml
├── .gitignore
├── ChangeLog.md
├── LICENSE
├── README.md
├── README_CN.md
├── bin
├── arc-ack.js
├── arc-cs.js
├── arc-display.js
├── arc-tool.js
└── arc.js
├── cmds
├── arc-tool.js
├── arc-tool
│ ├── completion.js
│ ├── config.js
│ ├── config
│ │ ├── delete.js
│ │ ├── get.js
│ │ ├── list.js
│ │ └── set.js
│ ├── serve.js
│ └── version.js
├── arc.js
├── arc
│ ├── cs.js
│ ├── cs
│ │ ├── addon.js
│ │ ├── addon
│ │ │ ├── get-upgrade-status.js
│ │ │ ├── get.js
│ │ │ ├── install.js
│ │ │ ├── list.js
│ │ │ └── uninstall.js
│ │ ├── cluster.js
│ │ ├── cluster
│ │ │ ├── cancel-upgrade.js
│ │ │ ├── create-ask.js
│ │ │ ├── create-edge.js
│ │ │ ├── create-kubernetes.js
│ │ │ ├── create-managed.js
│ │ │ ├── delete.js
│ │ │ ├── get-agent.js
│ │ │ ├── get-kubeconfig.js
│ │ │ ├── get-log.js
│ │ │ ├── get-update-status.js
│ │ │ ├── get-userquota.js
│ │ │ ├── get.js
│ │ │ ├── list-resource.js
│ │ │ ├── list-tags.js
│ │ │ ├── list.js
│ │ │ ├── pause-upgrade.js
│ │ │ ├── restart-upgrade.js
│ │ │ ├── scaleout.js
│ │ │ ├── update-tag.js
│ │ │ ├── update.js
│ │ │ └── upgrade.js
│ │ ├── node.js
│ │ ├── node
│ │ │ ├── attach-edge.js
│ │ │ ├── attach.js
│ │ │ ├── delete.js
│ │ │ ├── get-attach-script.js
│ │ │ └── list.js
│ │ ├── nodepool.js
│ │ └── nodepool
│ │ │ ├── create.js
│ │ │ ├── delete.js
│ │ │ ├── get.js
│ │ │ ├── list.js
│ │ │ ├── scaleout.js
│ │ │ └── update.js
│ ├── ecs.js
│ └── ecs
│ │ ├── instance.js
│ │ ├── instance
│ │ └── run.js
│ │ └── region.js
└── meta.js
├── front
├── README.md
├── config
│ ├── env.js
│ ├── getHttpsConfig.js
│ ├── jest
│ │ ├── cssTransform.js
│ │ └── fileTransform.js
│ ├── modules.js
│ ├── paths.js
│ ├── pnpTs.js
│ ├── webpack.config.js
│ └── webpackDevServer.config.js
├── package-lock.json
├── package.json
├── public
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ └── robots.txt
├── scripts
│ ├── build.js
│ ├── start.js
│ └── test.js
├── src
│ ├── App.css
│ ├── App.tsx
│ ├── component
│ │ ├── content
│ │ │ ├── index.scss
│ │ │ └── index.tsx
│ │ └── sublist
│ │ │ ├── index.scss
│ │ │ └── index.tsx
│ ├── index.css
│ ├── index.tsx
│ ├── model
│ │ ├── _types.ts
│ │ └── api.tsx
│ ├── pages
│ │ ├── index.scss
│ │ └── index.tsx
│ ├── react-app-env.d.ts
│ ├── serviceWorker.js
│ └── setupTests.js
└── tsconfig.json
├── lib
├── action.js
├── args.js
├── command.js
├── config.js
├── context.js
├── display.js
├── helper.js
├── i18n.js
├── json_filter.js
├── parser.js
└── runtime.js
├── package-lock.json
├── package.json
└── test
├── action.test.js
├── arc-cs
├── cs.test.js
└── cs_cluster.test.js
├── arc.test.js
├── args.test.js
├── config.test.js
├── context.test.js
├── display.test.js
├── fixtures
└── arc.json
├── helper.test.js
├── json_filter.test.js
├── spawn.js
└── test_cmd
├── test.js
└── test
└── test.js
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "indent": [
4 | 2,
5 | 2
6 | ],
7 | "quotes": [
8 | 2,
9 | "single",
10 | {
11 | "avoidEscape": true,
12 | "allowTemplateLiterals": true
13 | }
14 | ],
15 | "linebreak-style": [
16 | 2,
17 | "unix"
18 | ],
19 | "semi": [
20 | 2,
21 | "always"
22 | ],
23 | "strict": [
24 | 2,
25 | "global"
26 | ],
27 | "curly": 2,
28 | "eqeqeq": 2,
29 | "no-eval": 2,
30 | "guard-for-in": 2,
31 | "no-caller": 2,
32 | "no-else-return": 2,
33 | "no-eq-null": 2,
34 | "no-extend-native": 2,
35 | "no-extra-bind": 2,
36 | "no-floating-decimal": 2,
37 | "no-implied-eval": 2,
38 | "no-labels": 2,
39 | "no-with": 2,
40 | "no-loop-func": 1,
41 | "no-native-reassign": 2,
42 | "no-redeclare": [
43 | 2,
44 | {
45 | "builtinGlobals": true
46 | }
47 | ],
48 | "no-delete-var": 2,
49 | "no-shadow-restricted-names": 2,
50 | "no-undef-init": 2,
51 | "no-use-before-define": 2,
52 | "no-unused-vars": [
53 | 2,
54 | {
55 | "args": "none"
56 | }
57 | ],
58 | "no-undef": 2,
59 | "callback-return": [
60 | 2,
61 | [
62 | "callback",
63 | "cb",
64 | "next"
65 | ]
66 | ],
67 | "global-require": 0,
68 | "no-console": 0,
69 | "require-yield": 0,
70 | "prefer-const": "error",
71 | "no-trailing-spaces": "error",
72 | "no-multiple-empty-lines": "error",
73 | "no-mixed-spaces-and-tabs": "error"
74 | },
75 | "env": {
76 | "es6": true,
77 | "node": true,
78 | "browser": true
79 | },
80 | "globals": {
81 | "describe": true,
82 | "xdescribe": true,
83 | "it": true,
84 | "before": true,
85 | "after": true,
86 | "beforeEach": true
87 | },
88 | "parserOptions": {
89 | "ecmaVersion": 2018,
90 | "sourceType": "script",
91 | "ecmaFeatures": {
92 | "jsx": true
93 | }
94 | },
95 | "extends": "eslint:recommended"
96 | }
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "npm" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "daily"
12 | - package-ecosystem: "npm"
13 | directory: "/front"
14 | schedule:
15 | interval: "daily"
16 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 | schedule:
9 | - cron: "7 16 * * 0"
10 |
11 | jobs:
12 | analyze:
13 | name: Analyze
14 | runs-on: ubuntu-latest
15 | permissions:
16 | actions: read
17 | contents: read
18 | security-events: write
19 |
20 | strategy:
21 | fail-fast: false
22 | matrix:
23 | language: [ javascript ]
24 |
25 | steps:
26 | - name: Checkout
27 | uses: actions/checkout@v3
28 |
29 | - name: Initialize CodeQL
30 | uses: github/codeql-action/init@v2
31 | with:
32 | languages: ${{ matrix.language }}
33 | queries: +security-and-quality
34 |
35 | - name: Autobuild
36 | uses: github/codeql-action/autobuild@v2
37 |
38 | - name: Perform CodeQL Analysis
39 | uses: github/codeql-action/analyze@v2
40 | with:
41 | category: "/language:${{ matrix.language }}"
42 |
--------------------------------------------------------------------------------
/.github/workflows/node.js.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3 |
4 | name: Node.js CI
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | strategy:
18 | matrix:
19 | node-version: [12.x, 14.x, 16.x, 18.x]
20 |
21 | steps:
22 | - uses: actions/checkout@v2
23 | - name: Use Node.js ${{ matrix.node-version }}
24 | uses: actions/setup-node@v1
25 | with:
26 | node-version: ${{ matrix.node-version }}
27 | - run: |
28 | npm install
29 | npm run ci
30 | env:
31 | ALIBABACLOUD_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
32 | ALIBABACLOUD_ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
33 | - run: |
34 | CI=false npm run build-ui
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 | node_modules
106 | front/build
107 | .DS_Store
--------------------------------------------------------------------------------
/ChangeLog.md:
--------------------------------------------------------------------------------
1 | ### 2021-01-05 Version 0.1.5
2 | * Upgrade CS20151215 SDK version to 2.2.1
3 | * Add attribute type `noInclude`
--------------------------------------------------------------------------------
/README_CN.md:
--------------------------------------------------------------------------------
1 | # AlibabaCloud Resourcify CLI(ARC)
2 |
3 | [![NPM version][npm-image]][npm-url]
4 | [](https://github.com/aliyun/alibabacloud-resourcify-cli/actions/workflows/node.js.yml)
5 | [![codecov][cov-image]][cov-url]
6 |
7 | [npm-image]: https://img.shields.io/npm/v/@alicloud/arc.svg?style=flat-square
8 | [npm-url]: https://npmjs.org/package/@alicloud/arc
9 | [cov-image]: https://codecov.io/gh/aliyun/alibabacloud-resourcify-cli/branch/master/graph/badge.svg
10 | [cov-url]: https://codecov.io/gh/aliyun/alibabacloud-resourcify-cli
11 |
12 | ARC 是面向资源化的全新阿里云 CLI 环境,是多个命令行工具的合集。
13 |
14 | ## 安装
15 |
16 | > 安装前请确认具有 Node.js 开发环境,您可以从 下载
17 |
18 | 使用以下命令安装 ARC :
19 |
20 | ```sh
21 | npm i @alicloud/arc -g
22 | ```
23 |
24 | 现有包含的命令行工具如下:
25 |
26 | 1. `arc`: 调用 ARC 支持的所有阿里云资源命令
27 | `arc [options]`
28 | 2. `arc-tool`: 调用 ARC 本身相关命令
29 | `arc-tool [subCommand] [options]`
30 | 3. `arc-cs`: 调用 CS 相关资源命令
31 | `arc-cs [options]`
32 | 4. `arc-display`: 支持 jmespath 查询结果和自定义输出格式
33 | `arc-display --query --format `
34 |
35 | ## 全局选项
36 |
37 | 1. `profile`: 指定当前使用配置名
38 | 2. `interaction`: 使用交互模式填充命令
39 | 3. `region`: 指定阿里云区域
40 |
41 | ## ARC 配置
42 |
43 | 在使用 ARC 操作阿里云资源前,需要配置 ARC 相关环境。
44 |
45 | ARC 配置文件默认路径为: `$HOME/.aliyun/arc.json`。
46 |
47 | ### 配置凭证
48 |
49 | ARC目前支持AK,StsToken凭证,各类型对应字段如下:
50 |
51 | 1. AK凭证:
52 | `access_key_id`: 凭证 ID
53 | `access_key_secret`: 凭证 secret
54 |
55 | 2. StsToken 凭证:
56 | `access_key_id`: 凭证 ID
57 | `access_key_secret`: 凭证 secret
58 | `sts_token`: 凭证 token
59 |
60 | 快速配置 AK 凭证:
61 |
62 | ```sh
63 | arc-tool config --access-key-id accessKeyId --access-key-secret accessKeySecret --region region
64 | ```
65 |
66 | ARC 默认配置 AK 凭证,如需要其他凭证,请使用 `config` 的子命令对 ARC 配置进行操作以增删必要字段。如将默认配置变更为StsToken凭证:
67 |
68 | ```sh
69 | arc-tool config set access_key_id
70 | arc-tool config set access_key_secret
71 | arc-tool config set sts_token
72 | ```
73 |
74 | 更多配置相关命令请使用配置帮助命令:`arc-tool config help`。
75 |
76 | ## 使用帮助信息
77 |
78 | ARC 内置了所有命令及其参数的帮助信息,您可以在命令后面加上 `help` 命令以获取相关命令的帮助信息,例如:
79 |
80 | 1. 获取ARC支持的CS产品可操作资源信息:
81 | `arc cs help` 或者 `arc-cs help`
82 | 2. 获取ARC支持的CS产品下 cluster 资源的相关操作:
83 | `arc cs cluster help` 或者 `arc-cs cluster help`
84 | 3. 获取ARC支持的配置相关操作:
85 | `arc-tool help`
86 |
87 | ## 使用交互模式
88 |
89 | ARC 的工具都可以使用`交互模式`来进行命令参数的填充。
90 |
91 | ### 启用
92 |
93 | 在任意命令后面加入`-i`或者`--interaction`以启用交互模式。并在配置结束时,打印完整的相关命令,便于用户后期继续使用。最后用户可以选择是否直接运行刚刚填充的命令。
94 |
95 | 使用交互式输入配置 test 配置:
96 |
97 | ```sh
98 | $ arc-tool config -i --profile test
99 | ? 凭证ID
100 | access-key-id
101 | ? 凭证密钥
102 | access-key-secret
103 | ? 阿里云区域
104 | region cn-hangzhou
105 | ? CLI语言
106 | language zh
107 | ? 是否执行 Yes
108 | arc-tool config --access-key-id accessKeyId --access-key-secret accessKeySecret --region cn-hangzhou --language zh
109 | ```
110 |
111 | ## 优势
112 |
113 | ARC针对复杂命令参数具有强大优势,可从多方面辅助用户输入:
114 |
115 | *以下示例均截选自同一条命令:`arc-cs cluster create -i`*
116 |
117 | *尖括号表示用户输入*
118 |
119 | 1. 提示参数输入并辅以参数说明,用户无需记忆:
120 |
121 | ```sh
122 | ? key_pair名称
123 | key-pair
124 | ```
125 |
126 | 2. 对冲突参数进行提示
127 |
128 | ```sh
129 | ? 以下选项具有冲突,请选择其中一项 (Use arrow keys)
130 | ❯ login-password
131 | key-pair
132 | ```
133 |
134 | 3. 基本参数类型检查
135 |
136 | ```sh
137 | ? Worker节点系统盘大小,单位为GiB
138 | worker-system-disk-size
139 | >> 值不为Number类型
140 | ```
141 |
142 | 4. 参数值具有可选范围,使用箭头便于用户选择
143 |
144 | ```sh
145 | ? 数据盘类型
146 | category (Use arrow keys)
147 | ❯ cloud
148 | cloud_efficiency
149 | cloud_ssd
150 | [UNSET]
151 | ```
152 |
153 | 5. 可选项选择,减少用户输入时间
154 |
155 | ```sh
156 | ? 请选择可选配置或结束配置
157 | region [string] 集群所在地域ID
158 | cluster-type [string] 集群类型
159 | name [string] 集群名称, 集群名称可以使用大小写英文字母、中文、数字、中划线。
160 | ❯ cloud-monitor-flags [boolean] 是否安装云监控插件
161 | disable-rollback [boolean] 失败是否回滚
162 | endpoint-public-access [boolean] 是否开启公网API Server
163 | proxy-mode [string] kube-proxy代理模式,默认为iptables
164 | security-group-id [string] 指定集群ECS实例所属于的安全组ID
165 | service-cidr [string] Service网络的网段,不能和VPC网段及Pod网络网段冲突。当选择系统自动创建VPC时,默认使用172.19.0.0/20网段
166 | timeout-mins [number] 集群资源栈创建超时时间,以分钟为单位,默认值 60
167 | (Move up and down to reveal more choices)
168 | ```
169 |
170 | 6. 提示用户选项生效前置条件
171 |
172 | ```sh
173 | ? 请选择可选配置或结束配置 worker-data-disks
174 | worker-data-disks
175 | 该参数需满足以下条件方可生效
176 | 当 worker-data-disk 的值等于 true
177 | ```
178 |
179 | 7. 针对复杂参数值结构进行提示输入
180 |
181 | ```sh
182 | # map型参数值
183 | ? 请选择可选配置或结束配置 runtime
184 | runtime
185 | 容器运行时,一般为docker,包括2个信息:name和version?
186 | 容器运行时名称
187 | runtime.name
188 | ? 容器运行时版本
189 | runtime.version
190 |
191 | # 针对数组型参数值,提示当前输入元素位置
192 | ? 请选择可选配置或结束配置 pod-vswitch-idspod-vswitch-ids
193 | Pod的虚拟交换机列表,在ENI多网卡模式下,需要传额外的vswitchid给addon。当创建terway网络类型的集群时,该字段为必填。
194 | ? Pod的虚拟交换机列表,在ENI多网卡模式下,需要传额外的vswitchid给addon。当创建terway网络类型的集群时,该字段为必填。
195 | pod-vswitch-ids.0
196 | ? 是否继续配置第 2 个 pod-vswitch-ids
197 | ? Pod的虚拟交换机列表,在ENI多网卡模式下,需要传额外的vswitchid给addon。当创建terway网络类型的集群时,该字段为必填。
198 | pod-vswitch-ids.1
199 | ```
200 |
201 | # 开源许可证
202 |
203 | 采用 Apache License 2.0. 参见 [Apache-2.0](/LICENSE)
204 |
205 | Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
206 |
--------------------------------------------------------------------------------
/bin/arc-ack.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | // AlibabaCloud Resourcify CLI for ACK
6 |
7 | const ACK = require('../cmds/arc/cs');
8 |
9 | const ack = new ACK('arc-ack');
10 | ack.handle(process.argv.slice(2)).then(() => {
11 | process.exit(0);
12 | }, (err) => {
13 | console.error(err.stack);
14 | process.exit(-1);
15 | });
16 |
--------------------------------------------------------------------------------
/bin/arc-cs.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | // AlibabaCloud Resourcify CLI for ACK
6 |
7 | const ACK = require('../cmds/arc/cs');
8 |
9 | const ack = new ACK('arc-cs');
10 | ack.handle(process.argv.slice(2)).then(() => {
11 | process.exit(0);
12 | }, (err) => {
13 | console.error(err.stack);
14 | process.exit(-1);
15 | });
16 |
--------------------------------------------------------------------------------
/bin/arc-display.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // AlibabaCloud Resourcify CLI for CS
4 | 'use strict';
5 |
6 | const program = require('commander');
7 |
8 | const { display } = require('../lib/display');
9 |
10 | process.stdin.resume();
11 | // parse options
12 | program
13 | .option('--query [query]', '结果筛选,语法参考 jmespath')
14 | .option('--format [format]', '输出格式,支持 json, yaml, csv, table')
15 | .parse(process.argv);
16 |
17 | const buffers = [];
18 |
19 | process.stdin.on('data', function(data) {
20 | buffers.push(data);
21 | });
22 |
23 | process.stdin.on('end', function () {
24 | const input = Buffer.concat(buffers);
25 | try {
26 | const output = display(input, program.query, program.format);
27 | // output
28 | console.log(output);
29 | } catch (ex) {
30 | console.log(`display result failed, caused by:\n` + ex.stack);
31 | process.exit(-1);
32 | }
33 | });
34 |
--------------------------------------------------------------------------------
/bin/arc-tool.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // AlibabaCloud Resourcify CLI
4 |
5 | 'use strict';
6 |
7 | const ARCTool = require('../cmds/arc-tool');
8 |
9 | const c = new ARCTool('arc-tool');
10 | c.handle(process.argv.slice(2)).then(() => {
11 | process.exit(0);
12 | }, (err) => {
13 | console.error(err.stack);
14 | process.exit(-1);
15 | });
16 |
--------------------------------------------------------------------------------
/bin/arc.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | // AlibabaCloud Resourcify CLI
6 |
7 | const ARC = require('../cmds/arc');
8 |
9 | const arc = new ARC('arc');
10 | arc.handle(process.argv.slice(2)).then(() => {
11 | process.exit(0);
12 | }, (err) => {
13 | console.error(err.stack);
14 | process.exit(-1);
15 | });
16 |
--------------------------------------------------------------------------------
/cmds/arc-tool.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../lib/command');
4 |
5 | const ConfigCommand = require('./arc-tool/config');
6 | const ServeCommand = require('./arc-tool/serve');
7 | const CompletionCommand = require('./arc-tool/completion');
8 | const VersionCommand = require('./arc-tool/version');
9 |
10 | module.exports = class extends Command {
11 | constructor(name) {
12 | super(name, {
13 | desc: {
14 | zh: '阿里云资源化命令行工具,用于配置、自动补全等辅助设置',
15 | en: 'Alibaba Cloud Resourcify CLI, used for settings, such as configuation, autocomplation, etc'
16 | }
17 | });
18 |
19 | this.registerCommand(new ConfigCommand('config'));
20 | this.registerCommand(new CompletionCommand('completion'));
21 | this.registerCommand(new ServeCommand('serve'));
22 | this.registerCommand(new VersionCommand('version'));
23 | }
24 |
25 | async run(args) {
26 | await this.help();
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/cmds/arc-tool/completion.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../lib/command');
4 | const { loadContext } = require('../../lib/context');
5 |
6 | function getBashCompletionScript() {
7 | const packageInfo = require('../../package.json');
8 | const bins = Object.keys(packageInfo.bin);
9 | let script = '';
10 | for (const bin of bins) {
11 | script += `complete -C ${bin} ${bin}\n`;
12 | }
13 | script = `
14 | # Installation: arc completion >> ~/.bashrc
15 | # or arc completion >> ~/.bash_profile on OSX.
16 | ${script}
17 | # end of arc completion
18 | `;
19 | return script;
20 | }
21 |
22 | function getZshCompletionScript() {
23 | const packageInfo = require('../../../package.json');
24 | const bins = Object.keys(packageInfo.bin);
25 | let script = '';
26 | for (const bin of bins) {
27 | script += `compdef "_arc_completion ${bin}" ${bin}\n`;
28 | }
29 | script = `
30 | # Installation: arc completion >> ~/.zshrc
31 | # or arc completion >> ~/.zsh_profile on OSX.
32 | _arc_completion()
33 | {
34 | local reply
35 | local si=$IFS
36 | IFS=$'
37 | ' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" $1))
38 | IFS=$si
39 | _describe 'values' reply
40 | }
41 | ${script}
42 | # end of arc completion
43 | `;
44 | return script;
45 | }
46 |
47 | module.exports = class extends Command {
48 | constructor(name) {
49 | super(name, {
50 | desc: {
51 | zh: '自动补全',
52 | en: `Autocomplete`
53 | },
54 | args: [
55 | {
56 | name: 'terminalType',
57 | required: true,
58 | choices: [
59 | 'bash',
60 | 'zsh'
61 | ]
62 | }
63 | ]
64 | });
65 | }
66 |
67 | async run(args) {
68 | const ctx = loadContext(args);
69 | let script;
70 | if (ctx.argv[0] === 'bash') {
71 | script = getBashCompletionScript();
72 | } else {
73 | script = getZshCompletionScript();
74 | }
75 | console.log(script);
76 | }
77 | };
78 |
--------------------------------------------------------------------------------
/cmds/arc-tool/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Config = require('../../lib/config.js');
4 | const i18n = require('../../lib/i18n.js');
5 |
6 | const Command = require('../../lib/command');
7 |
8 | const ListCommand = require('./config/list');
9 | const GetCommand = require('./config/get');
10 | const DeleteCommand = require('./config/delete');
11 | const SetCommand = require('./config/set');
12 |
13 | const { loadContext } = require('../../lib/context');
14 | const inquirer = require('inquirer');
15 |
16 | function confusePwd(pwd) {
17 | if (!pwd) {
18 | return;
19 | }
20 |
21 | return pwd.substr(0, 3) + '****' + pwd.substr(-4);
22 | }
23 |
24 | async function ask(options) {
25 | const {name, message, required, language} = options;
26 | const question = {
27 | type: 'input',
28 | name: name,
29 | message: message + '\n' + name,
30 | default: options.default,
31 | filter: options.filter
32 | };
33 |
34 | if (required) {
35 | question['validate'] = function (val) {
36 | if (val === '') {
37 | return i18n.emptyValueErr[language];
38 | }
39 | return true;
40 | };
41 | }
42 |
43 | const answers = await inquirer.prompt([question]);
44 | return answers[name];
45 | }
46 |
47 | module.exports = class extends Command {
48 | constructor(name) {
49 | super(name, {
50 | short: {
51 | zh: '配置CLI',
52 | en: 'Configure the CLI'
53 | },
54 | desc: {
55 | zh: '交互式配置CLI,根据提示输入参数值,完成后自动将现有配置作为默认配置',
56 | en: `Configure the CLI interactively, enter parameter values according to the prompts, and automatically use the existing configuration as the default configuration after completion`
57 | },
58 | options: {
59 | 'access-key-id': {
60 | required: true,
61 | desc: {
62 | zh: '凭证ID',
63 | en: `Access Key ID`
64 | }
65 | },
66 | 'access-key-secret': {
67 | required: true,
68 | desc: {
69 | zh: '凭证密钥',
70 | en: `Access Key Secret`
71 | }
72 | },
73 | 'region': {
74 | desc: {
75 | zh: '阿里云区域',
76 | en: `the ID of the region`
77 | }
78 | },
79 | 'language': {
80 | desc: {
81 | zh: 'CLI语言',
82 | en: `the language of CLI`
83 | },
84 | choices: [
85 | 'zh',
86 | 'en'
87 | ]
88 | }
89 | }
90 | });
91 | this.registerCommand(new ListCommand('list'));
92 | this.registerCommand(new GetCommand('get'));
93 | this.registerCommand(new DeleteCommand('delete'));
94 | this.registerCommand(new SetCommand('set'));
95 | }
96 |
97 | async run(args) {
98 | const ctx = loadContext(args, this.def.options);
99 | const profile = ctx.profile;
100 | const language = profile.language || 'zh';
101 |
102 | if (ctx.parsed.has('interaction')) {
103 | profile['access_key_id'] = await ask({
104 | name: 'access-key-id',
105 | message: this.def.options['access-key-id'].desc[language],
106 | required: true,
107 | default: profile.access_key_id,
108 | language
109 | });
110 | profile['access_key_secret'] = await ask({
111 | name: 'access-key-secret',
112 | message: this.def.options['access-key-secret'].desc[language],
113 | default: confusePwd(profile.access_key_secret),
114 | required: true,
115 | language,
116 | filter: function (val) {
117 | if (val === confusePwd(profile.access_key_secret)) {
118 | return profile.access_key_secret;
119 | }
120 | return val;
121 | }
122 | });
123 | profile['region'] = await ask({
124 | name: 'region',
125 | message: this.def.options['region'].desc[language],
126 | required: true,
127 | default: profile.region,
128 | language
129 | });
130 | profile['language'] = await ask({
131 | name: 'language',
132 | message: this.def.options['language'].desc[language],
133 | required: true,
134 | default: profile.language,
135 | language
136 | });
137 | } else {
138 | this.validateOptions(ctx.parsed);
139 | profile['access_key_id'] = ctx.parsed.get('access-key-id');
140 | profile['access_key_secret'] = ctx.parsed.get('access-key-secret');
141 | profile['region'] = ctx.parsed.get('region') || ctx.profile.region;
142 | profile['language'] = ctx.parsed.get('language') || ctx.profile.language;
143 | }
144 |
145 | const config = new Config();
146 | config.updateProfile(ctx.profileName, profile);
147 | }
148 | };
149 |
--------------------------------------------------------------------------------
/cmds/arc-tool/config/delete.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command.js');
4 | const Config = require('../../../lib/config.js');
5 | const { loadContext } = require('../../../lib/context.js');
6 |
7 | module.exports = class extends Command {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '删除配置',
12 | en: `remove profile`
13 | },
14 | args: [
15 | {
16 | name: 'profileName',
17 | required: true
18 | }
19 | ]
20 | });
21 | }
22 |
23 | async run(args) {
24 | const ctx = loadContext(args);
25 | this.validateOptions(ctx.parsed);
26 | const [ profileName ] = ctx.argv;
27 | if (!profileName) {
28 | console.error(`the profileName is required`);
29 | process.exit(1);
30 | }
31 |
32 | const config = new Config();
33 | config.delete(ctx.argv[0]);
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/cmds/arc-tool/config/get.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command');
4 | const { loadContext } = require('../../../lib/context');
5 |
6 | module.exports = class extends Command {
7 | constructor(name) {
8 | super(name, {
9 | usage: [
10 | 'arc config get [--profile profileName]'
11 | ],
12 | desc: {
13 | zh: '获取指定配置信息',
14 | en: `Get the specified profile information`
15 | }
16 | });
17 | }
18 |
19 | async run(args) {
20 | const ctx = loadContext(args);
21 | const data = JSON.stringify(ctx.profile, null, 2);
22 | console.log(data);
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/cmds/arc-tool/config/list.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Config = require('../../../lib/config.js');
4 | const Command = require('../../../lib/command');
5 |
6 | module.exports = class extends Command {
7 | constructor(name) {
8 | super(name, {
9 | desc: {
10 | zh: '列举指定配置所有信息,未指定则返回默认',
11 | en: `List all the information of the specified configuration, return to the default if not specified`
12 | }
13 | });
14 | }
15 |
16 | async run(args) {
17 | const config = new Config();
18 | const conf = config.getConfig();
19 | if (!conf) {
20 | console.error('No configuration currently exists');
21 | return;
22 | }
23 |
24 | console.log(JSON.stringify(conf, null, 2));
25 | }
26 | };
27 |
--------------------------------------------------------------------------------
/cmds/arc-tool/config/set.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command.js');
4 | const Config = require('../../../lib/config.js');
5 | const { loadContext } = require('../../../lib/context.js');
6 |
7 | module.exports = class extends Command {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '设置配置中的字段,当字段不存在时添加;当value为空时,代表删除指定字段;若只是指定profile,则表示更改默认配置',
12 | en: `Set the field in the configuration, add it when the field does not exist; when the value is empty, it means delete the specified field; if only specify the profile, it means change the default configuration`
13 | },
14 | usage: [
15 | 'arc config set [ ] [--profile profileName]'
16 | ],
17 | args: [
18 | {
19 | name: 'key',
20 | },
21 | {
22 | name: 'value',
23 | }
24 | ]
25 | });
26 | }
27 |
28 | async run(args) {
29 | const ctx = loadContext(args);
30 | const [key, value] = ctx.argv;
31 | if (typeof value === 'undefined') {
32 | delete ctx.profile[key];
33 | } else {
34 | ctx.profile[key] = value;
35 | }
36 | const config = new Config();
37 | config.updateProfile(ctx.profileName, ctx.profile);
38 | }
39 | };
40 |
--------------------------------------------------------------------------------
/cmds/arc-tool/version.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../lib/command');
4 |
5 | module.exports = class extends Command {
6 | constructor(name) {
7 | super(name, {
8 | desc: {
9 | zh: '获取当前程序版本',
10 | en: `Get the current program version`
11 | }
12 | });
13 | }
14 |
15 | async run(args) {
16 | const info = require('../../package.json');
17 | console.log(info.version);
18 | }
19 | };
20 |
--------------------------------------------------------------------------------
/cmds/arc.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../lib/command');
4 | const CSCommand = require('./arc/cs');
5 |
6 | module.exports = class extends Command {
7 | constructor(name) {
8 | super(name, {
9 | desc: {
10 | zh: '阿里云资源化命令行工具,用于云服务资源操作',
11 | en: `Alibaba Cloud Resourcify CLI, used for operate resources of cloud service`
12 | },
13 | options: {
14 | profile: {
15 | desc: {
16 | zh: '指定要使用的配置文件',
17 | en: `Specify the profile name to be used`
18 | }
19 | },
20 | region: {
21 | desc: {
22 | zh: '指定阿里云区域',
23 | en: `Region ID`
24 | }
25 | },
26 | interaction: {
27 | vtype: 'boolean',
28 | alias: 'i',
29 | desc: {
30 | zh: '交互式填充参数',
31 | en: `Interactive fill parameter`
32 | }
33 | }
34 | }
35 | });
36 |
37 | this.registerCommand(new CSCommand('cs'));
38 | }
39 |
40 | async run(args) {
41 | await this.help();
42 | }
43 | };
44 |
--------------------------------------------------------------------------------
/cmds/arc/cs.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../lib/command');
4 |
5 | const ClusterCommand = require('./cs/cluster');
6 | const NodeCommand = require('./cs/node');
7 | const AddonCommand = require('./cs/addon');
8 | const NodePoolCommand = require('./cs/nodepool');
9 |
10 | module.exports = class extends Command {
11 | constructor(name) {
12 | super(name, {
13 | desc: {
14 | zh: '容器服务K8S版',
15 | en: `Container Service for Kubernetes`
16 | }
17 | });
18 |
19 | this.registerCommand(new ClusterCommand('cluster'));
20 | this.registerCommand(new NodeCommand('node'));
21 | this.registerCommand(new AddonCommand('addon'));
22 | this.registerCommand(new NodePoolCommand('nodepool'));
23 | }
24 |
25 | async run(args) {
26 | await this.help();
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/cmds/arc/cs/addon.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command');
4 |
5 | const ListCommand = require('./addon/list');
6 | const GetCommand = require('./addon/get');
7 | const GetUpgradeStatusCommand = require('./addon/get-upgrade-status');
8 | const InstallCommand = require('./addon/install');
9 | const UninstallCommand = require('./addon/uninstall');
10 |
11 | module.exports = class extends Command {
12 | constructor(name) {
13 | super(name, {
14 | desc: {
15 | zh: '集群插件操作',
16 | en: `Action of container service cluster addon-on`
17 | }
18 | });
19 |
20 | this.registerCommand(new ListCommand('list'));
21 | this.registerCommand(new GetCommand('get'));
22 | this.registerCommand(new GetUpgradeStatusCommand('get-upgrade-status'));
23 | this.registerCommand(new InstallCommand('install'));
24 | this.registerCommand(new UninstallCommand('uninstall'));
25 | }
26 |
27 | async run(args) {
28 | await this.help();
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/cmds/arc/cs/addon/get-upgrade-status.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '查询集群Addons升级状态',
12 | en: `query the upgrade status of a cluster add-on.`
13 | },
14 | options: {
15 | 'component-ids': {
16 | required: true,
17 | mapping: 'DescribeClusterAddonsUpgradeStatusRequest.componentIds',
18 | vtype: 'array',
19 | subType: 'string',
20 | desc: {
21 | zh: '组件名称',
22 | en: ''
23 | }
24 | }
25 | },
26 | args: [
27 | {
28 | name: 'clusterId',
29 | required: true
30 | }
31 | ]
32 | });
33 | }
34 |
35 | async run(ctx) {
36 | const profile = await runtime.getConfigOption(ctx.profile);
37 | const { Config } = require('@alicloud/openapi-client');
38 | const config = new Config({
39 | accessKeyId: profile.access_key_id,
40 | accessKeySecret: profile.access_key_secret,
41 | securityToken: profile.sts_token,
42 | regionId: profile.region,
43 | type: profile.type
44 | });
45 |
46 | const DescribeClusterAddonsUpgradeStatusRequest = require(`@alicloud/cs20151215`).DescribeClusterAddonsUpgradeStatusRequest;
47 | const request = new DescribeClusterAddonsUpgradeStatusRequest(ctx.mappingValue.DescribeClusterAddonsUpgradeStatusRequest);
48 |
49 | const client = new Client(config);
50 | let result = await client.describeClusterAddonsUpgradeStatusWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
51 | if (result) {
52 | result = result.body;
53 | }
54 | const data = JSON.stringify(result, null, 2);
55 | console.log(data);
56 | }
57 | };
58 |
--------------------------------------------------------------------------------
/cmds/arc/cs/addon/get.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '集群安装的Addons详情',
12 | en: ` query details about the add-ons that are supported by a specified cluster type.`
13 | },
14 | options: {
15 | 'region': {
16 | mapping: 'DescribeAddonsRequest.region',
17 | vtype: 'string',
18 | desc: {
19 | zh: '阿里云区域',
20 | en: `The ID of the region to query.`
21 | }
22 | },
23 | 'cluster-type': {
24 | mapping: 'DescribeAddonsRequest.clusterType',
25 | desc: {
26 | zh: '集群类型,默认为kubernetes',
27 | en: `The type of the cluster. Default value: kubernetes.`
28 | }
29 | }
30 | }
31 | });
32 | }
33 |
34 | async run(ctx) {
35 | const profile = await runtime.getConfigOption(ctx.profile);
36 | const { Config } = require('@alicloud/openapi-client');
37 | const config = new Config({
38 | accessKeyId: profile.access_key_id,
39 | accessKeySecret: profile.access_key_secret,
40 | securityToken: profile.sts_token,
41 | regionId: profile.region,
42 | type: profile.type
43 | });
44 | const DescribeAddonsRequest = require(`@alicloud/cs20151215`).DescribeAddonsRequest;
45 | const request = new DescribeAddonsRequest(ctx.mappingValue.DescribeAddonsRequest);
46 |
47 | const client = new Client(config);
48 | let result = await client.describeAddonsWithOptions(request, {}, runtime.getRuntimeOption());
49 | if (result) {
50 | result = result.body;
51 | }
52 | const data = JSON.stringify(result, null, 2);
53 | console.log(data);
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/cmds/arc/cs/addon/install.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '安装集群插件',
12 | en: `install an add-on for a cluster.`
13 | },
14 | options: {
15 | 'body': {
16 | mapping: 'InstallClusterAddonsRequest.body',
17 | vtype: 'array',
18 | subType: 'map',
19 | desc: {
20 | zh: 'Addon列表',
21 | en: `the list of add-on`
22 | },
23 | options: {
24 | 'name': {
25 | mapping: 'name',
26 | vtype: 'string',
27 | desc: {
28 | zh: 'addon名称',
29 | en: `The name of the add-on.`
30 | }
31 | },
32 | 'version': {
33 | mapping: 'version',
34 | vtype: 'string',
35 | desc: {
36 | zh: '插件版本',
37 | en: `The version of the add-on.`
38 | }
39 | },
40 | 'config': {
41 | mapping: 'config',
42 | vtype: 'string',
43 | desc: {
44 | zh: '配置信息',
45 | en: 'The configurations of the add-on.'
46 | }
47 | }
48 | }
49 | }
50 | },
51 | args: [
52 | {
53 | name: 'clusterId',
54 | required: true
55 | }
56 | ]
57 | });
58 | }
59 |
60 | async run(ctx) {
61 | const profile = await runtime.getConfigOption(ctx.profile);
62 | const { Config } = require('@alicloud/openapi-client');
63 | const config = new Config({
64 | accessKeyId: profile.access_key_id,
65 | accessKeySecret: profile.access_key_secret,
66 | securityToken: profile.sts_token,
67 | regionId: profile.region,
68 | type: profile.type
69 | });
70 | const InstallClusterAddonsRequest = require(`@alicloud/cs20151215`).InstallClusterAddonsRequest;
71 | const request = new InstallClusterAddonsRequest(ctx.mappingValue.InstallClusterAddonsRequest);
72 | const client = new Client(config);
73 |
74 | await client.installClusterAddonsWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
75 | }
76 | };
--------------------------------------------------------------------------------
/cmds/arc/cs/addon/list.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '查询指定集群安装的所有Addons的信息',
12 | en: `query the details of all add-ons that are installed for a cluster.`
13 | },
14 | args: [
15 | {
16 | name: 'clusterId',
17 | required: true
18 | }
19 | ]
20 | });
21 | }
22 |
23 | async run(ctx) {
24 | const profile = await runtime.getConfigOption(ctx.profile);
25 | const { Config } = require('@alicloud/openapi-client');
26 | const config = new Config({
27 | accessKeyId: profile.access_key_id,
28 | accessKeySecret: profile.access_key_secret,
29 | securityToken: profile.sts_token,
30 | regionId: profile.region,
31 | type: profile.type
32 | });
33 |
34 | const client = new Client(config);
35 | let result = await client.describeClusterAddonsVersionWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
36 | if (result) {
37 | result = result.body;
38 | }
39 | const data = JSON.stringify(result, null, 2);
40 | console.log(data);
41 | }
42 | };
43 |
--------------------------------------------------------------------------------
/cmds/arc/cs/addon/uninstall.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '卸载集群插件',
12 | en: `uninstall an add-on from a cluster.`
13 | },
14 | options: {
15 | 'addons': {
16 | mapping: 'UnInstallClusterAddonsRequest.addons',
17 | vtype: 'array',
18 | subType: 'map',
19 | desc: {
20 | zh: 'Addon列表',
21 | en: `the list of add-on`
22 | },
23 | options: {
24 | 'name': {
25 | mapping:'name',
26 | required: true,
27 | desc: {
28 | zh: '集群名称',
29 | en: `The name of the cluster.`
30 | }
31 | }
32 | }
33 | }
34 | },
35 | args: [
36 | {
37 | name: 'clusterId',
38 | required: true
39 | }
40 | ]
41 | });
42 | }
43 |
44 | async run(ctx) {
45 | const profile = await runtime.getConfigOption(ctx.profile);
46 | const { Config } = require('@alicloud/openapi-client');
47 | const config = new Config({
48 | accessKeyId: profile.access_key_id,
49 | accessKeySecret: profile.access_key_secret,
50 | securityToken: profile.sts_token,
51 | regionId: profile.region,
52 | type: profile.type
53 | });
54 | const UnInstallClusterAddonsRequest = require(`@alicloud/cs20151215`).UnInstallClusterAddonsRequest;
55 | const request = new UnInstallClusterAddonsRequest(ctx.mappingValue.UnInstallClusterAddonsRequest);
56 |
57 | const client = new Client(config);
58 |
59 | await client.unInstallClusterAddonsWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
60 | }
61 | };
62 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command');
4 |
5 | const CreateKubernetesCommand = require('./cluster/create-kubernetes');
6 | const CreateManagedCommand = require('./cluster/create-managed');
7 | const CreateASKCommand = require('./cluster/create-ask');
8 | const CreateEdgeCommand = require('./cluster/create-edge');
9 | const DeleteCommand = require('./cluster/delete');
10 | const GetCommand = require('./cluster/get');
11 | const GetUserQuotaCommand = require('./cluster/get-userquota');
12 | const ListCommand = require('./cluster/list');
13 | const UpdateCommand = require('./cluster/update');
14 | const GetAgentCommand = require('./cluster/get-agent');
15 | const GetKubeconfigCommand = require('./cluster/get-kubeconfig');
16 | const GetLogCommand = require('./cluster/get-log');
17 | const ListResourceCommand = require('./cluster/list-resource');
18 | const ListTagsCommand = require('./cluster/list-tags');
19 | const ScaleoutCommand = require('./cluster/scaleout');
20 | const UpdateTagCommand = require('./cluster/update-tag');
21 | const GetUpdateStatusCommand = require('./cluster/get-update-status');
22 | const UpgradeCommand = require('./cluster/upgrade');
23 | const CancelUpgradeCommand = require('./cluster/cancel-upgrade');
24 | const PauseUpgradeCommand = require('./cluster/pause-upgrade');
25 | const RestartUpgradeCommand = require('./cluster/restart-upgrade');
26 |
27 | module.exports = class extends Command {
28 | constructor(name) {
29 | super(name, {
30 | desc: {
31 | zh: '集群相关操作',
32 | en: `Action of container service cluster`
33 | }
34 | });
35 |
36 | this.registerCommand(new CreateKubernetesCommand('create-kubernetes'));
37 | this.registerCommand(new CreateManagedCommand('create-managed'));
38 | this.registerCommand(new CreateASKCommand('create-ask'));
39 | this.registerCommand(new CreateEdgeCommand('create-edge'));
40 | this.registerCommand(new DeleteCommand('delete'));
41 | this.registerCommand(new GetCommand('get'));
42 | this.registerCommand(new GetUserQuotaCommand('get-userquota'));
43 | this.registerCommand(new ListCommand('list'));
44 | this.registerCommand(new UpdateCommand('update'));
45 | this.registerCommand(new GetAgentCommand('get-agent'));
46 | this.registerCommand(new GetKubeconfigCommand('get-kubeconfig'));
47 | this.registerCommand(new GetLogCommand('get-log'));
48 | this.registerCommand(new ListResourceCommand('list-resource'));
49 | this.registerCommand(new ListTagsCommand('list-tags'));
50 | this.registerCommand(new ScaleoutCommand('scaleout'));
51 | this.registerCommand(new UpdateTagCommand('update-tag'));
52 | this.registerCommand(new GetUpdateStatusCommand('get-update-status'));
53 | this.registerCommand(new UpgradeCommand('upgrade'));
54 | this.registerCommand(new CancelUpgradeCommand('cancel-upgrade'));
55 | this.registerCommand(new PauseUpgradeCommand('pause-upgrade'));
56 | this.registerCommand(new RestartUpgradeCommand('restart-upgrade'));
57 | }
58 |
59 | async run(args) {
60 | await this.help();
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/cancel-upgrade.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '取消集群升级',
12 | en: `cancel the upgrade of a cluster.`
13 | },
14 | args: [
15 | {
16 | name: 'clusterId',
17 | required: true,
18 | }
19 | ]
20 | });
21 | }
22 |
23 | async run(ctx) {
24 | const profile = await runtime.getConfigOption(ctx.profile);
25 | const { Config } = require('@alicloud/openapi-client');
26 | const config = new Config({
27 | accessKeyId: profile.access_key_id,
28 | accessKeySecret: profile.access_key_secret,
29 | securityToken: profile.sts_token,
30 | regionId: profile.region,
31 | type: profile.type
32 | });
33 | const client = new Client(config);
34 | await client.cancelClusterUpgradeWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
35 | }
36 | };
37 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/delete.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | short: {
12 | zh: '删除集群',
13 | en: 'remove cluster'
14 | },
15 | desc: {
16 | zh: '根据集群ID删除集群',
17 | en: `delete the cluster of a specified ID and release all nodes in the cluster.`
18 | },
19 | options: {
20 | 'retain-resources': {
21 | mapping: 'DeleteClusterRequest.retainResources',
22 | vtype: 'array',
23 | subType: 'string',
24 | desc: {
25 | zh: '资源名称',
26 | en: `Resoure name`
27 | },
28 | attributes: {
29 | show: [
30 | {
31 | 'retain-all-resources': {
32 | type: 'equal',
33 | value: false
34 | }
35 | }
36 | ]
37 | }
38 | },
39 | 'keep-slb': {
40 | mapping: 'DeleteClusterRequest.keepSlb',
41 | vtype: 'boolean',
42 | default: false,
43 | desc: {
44 | zh: '是否保留SLB',
45 | en: 'Whether to keep SLB'
46 | }
47 | },
48 | 'retain-all-resources': {
49 | mapping: 'DeleteClusterRequest.retainAllResources',
50 | vtype: 'boolean',
51 | default: false,
52 | desc: {
53 | zh: '是否保留所有资源',
54 | en: 'Whether to keep all resources'
55 | }
56 | }
57 | },
58 | args: [
59 | {
60 | name: 'clusterId',
61 | required: true
62 | }
63 | ]
64 | });
65 | }
66 |
67 | async run(ctx) {
68 |
69 | const profile = await runtime.getConfigOption(ctx.profile);
70 | const { Config } = require('@alicloud/openapi-client');
71 | const config = new Config({
72 | accessKeyId: profile.access_key_id,
73 | accessKeySecret: profile.access_key_secret,
74 | securityToken: profile.sts_token,
75 | regionId: profile.region,
76 | type: profile.type
77 | });
78 | const DeleteClusterRequest = require(`@alicloud/cs20151215`).DeleteClusterRequest;
79 | const request = new DeleteClusterRequest(ctx.mappingValue.DeleteClusterRequest);
80 | const client = new Client(config);
81 | try {
82 | await client.deleteClusterWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
83 | } catch (e) {
84 | console.error(e);
85 | }
86 | }
87 | };
88 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get-agent.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '获取注册集群的代理配置以访问API Server',
13 | en: `obtain an agent to access the API server.`
14 | },
15 | options: {
16 | 'private-ip-address': {
17 | mapping: 'DescribeExternalAgentRequest.privateIpAddress',
18 | vtype: 'string',
19 | default: 'false',
20 | desc: {
21 | zh: '是否获取内网访问凭据',
22 | en: `Whether to obtain internal network access credentials`
23 | },
24 | choices: [
25 | 'false',
26 | 'true'
27 | ]
28 | }
29 | },
30 | args: [
31 | {
32 | name: 'clusterId',
33 | required: true
34 | }
35 | ]
36 | });
37 | }
38 |
39 | async run(ctx) {
40 |
41 |
42 | const profile = await runtime.getConfigOption(ctx.profile);
43 | const { Config } = require('@alicloud/openapi-client');
44 | const config = new Config({
45 | accessKeyId: profile.access_key_id,
46 | accessKeySecret: profile.access_key_secret,
47 | securityToken: profile.sts_token,
48 | regionId: profile.region,
49 | type: profile.type
50 | });
51 |
52 | const client = new Client(config);
53 | const DescribeExternalAgentRequest = require(`@alicloud/cs20151215`).DescribeExternalAgentRequest;
54 | const request = new DescribeExternalAgentRequest(ctx.mappingValue.DescribeExternalAgentRequest);
55 | let result = await client.describeExternalAgentWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
56 | if (result) {
57 | result = result.body;
58 | }
59 | const data = JSON.stringify(result, null, 2);
60 | console.log(data);
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get-kubeconfig.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '获取当前用户的kubeconfig',
13 | en: `Return to the Kubernetes cluster containing the identity information of the currently logged in user to access kubeconfig`
14 | },
15 | options: {
16 | 'private-ip-address': {
17 | mapping: 'DescribeClusterUserKubeconfigRequest.privateIpAddress',
18 | vtype: 'boolean',
19 | desc: {
20 | zh: '当前用户对应的集群访问kubeconfig',
21 | en: `The cluster corresponding to the current user accesses kubeconfig`
22 | }
23 | }
24 | },
25 | args: [
26 | {
27 | name: 'clusterId',
28 | required: true
29 | }
30 | ]
31 | });
32 | }
33 |
34 | async run(ctx) {
35 |
36 | const profile = await runtime.getConfigOption(ctx.profile);
37 | const { Config } = require('@alicloud/openapi-client');
38 | const config = new Config({
39 | accessKeyId: profile.access_key_id,
40 | accessKeySecret: profile.access_key_secret,
41 | securityToken: profile.sts_token,
42 | regionId: profile.region,
43 | type: profile.type
44 | });
45 | const DescribeClusterUserKubeconfigRequest = require(`@alicloud/cs20151215`).DescribeClusterUserKubeconfigRequest;
46 | const request = new DescribeClusterUserKubeconfigRequest(ctx.mappingValue.DescribeClusterUserKubeconfigRequest);
47 | const client = new Client(config);
48 |
49 | let result = await client.describeClusterUserKubeconfigWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
50 | if (result) {
51 | result = result.body;
52 | }
53 | const data = JSON.stringify(result, null, 2);
54 | console.log(data);
55 | }
56 | };
57 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get-log.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '查询指定集群日志',
13 | en: `query the logs of a cluster.`
14 | },
15 | args: [
16 | {
17 | name: 'clusterId',
18 | required: true
19 | }
20 | ]
21 | });
22 | }
23 |
24 | async run(ctx) {
25 |
26 | const profile = await runtime.getConfigOption(ctx.profile);
27 | const { Config } = require('@alicloud/openapi-client');
28 | const config = new Config({
29 | accessKeyId: profile.access_key_id,
30 | accessKeySecret: profile.access_key_secret,
31 | securityToken: profile.sts_token,
32 | regionId: profile.region,
33 | type: profile.type
34 | });
35 |
36 | const client = new Client(config);
37 | let result = await client.describeClusterLogsWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
38 | if (result) {
39 | result = result.body;
40 | }
41 | const data = JSON.stringify(result, null, 2);
42 | console.log(data);
43 | }
44 | };
45 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get-update-status.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '查询集群升级状态',
13 | en: ` query the upgrade status of a cluster.`
14 | },
15 | args: [
16 | {
17 | name: 'clusterId',
18 | required: true,
19 | }
20 | ]
21 | });
22 | }
23 |
24 | async run(ctx) {
25 |
26 | const profile = await runtime.getConfigOption(ctx.profile);
27 | const { Config } = require('@alicloud/openapi-client');
28 | const config = new Config({
29 | accessKeyId: profile.access_key_id,
30 | accessKeySecret: profile.access_key_secret,
31 | securityToken: profile.sts_token,
32 | regionId: profile.region,
33 | type: profile.type
34 | });
35 |
36 | const client = new Client(config);
37 | let result = await client.getUpgradeStatusWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
38 |
39 | if (result) {
40 | result = result.body;
41 | }
42 | const data = JSON.stringify(result, null, 2);
43 | console.log(data);
44 | }
45 | };
46 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get-userquota.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '获取用户配额',
13 | en: `query resource quotas`
14 | }
15 | });
16 | }
17 |
18 | async run(ctx) {
19 |
20 | const profile = await runtime.getConfigOption(ctx.profile);
21 | const { Config } = require('@alicloud/openapi-client');
22 | const config = new Config({
23 | accessKeyId: profile.access_key_id,
24 | accessKeySecret: profile.access_key_secret,
25 | securityToken: profile.sts_token,
26 | regionId: profile.region,
27 | type: profile.type
28 | });
29 |
30 | const client = new Client(config);
31 | let result = await client.describeUserQuotaWithOptions({}, runtime.getRuntimeOption());
32 | if (result) {
33 | result = result.body;
34 | }
35 | const data = JSON.stringify(result, null, 2);
36 | console.log(data);
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/get.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | short: {
12 | zh: '根据集群ID获取集群信息',
13 | en: 'view the details of a cluster by id'
14 | },
15 | desc: {
16 | zh: '根据集群ID,查看集群的详细信息',
17 | en: `view the details of a cluster based on the cluster ID.`
18 | },
19 | args: [
20 | {
21 | name: 'clusterId',
22 | required: true,
23 | }
24 | ]
25 | });
26 | }
27 |
28 | async run(ctx) {
29 | const profile = await runtime.getConfigOption(ctx.profile);
30 | const { Config } = require('@alicloud/openapi-client');
31 | const config = new Config({
32 | accessKeyId: profile.access_key_id,
33 | accessKeySecret: profile.access_key_secret,
34 | securityToken: profile.sts_token,
35 | regionId: profile.region,
36 | type: profile.type
37 | });
38 | const client = new Client(config);
39 | let result = await client.describeClusterDetailWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
40 |
41 | if (result) {
42 | result = result.body;
43 | }
44 | const data = JSON.stringify(result, null, 2);
45 | console.log(data);
46 | }
47 | };
48 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/list-resource.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '查询指定集群的所有资源',
13 | en: `query all resources in a cluster.`
14 | },
15 | args: [
16 | {
17 | name: 'clusterId',
18 | required: true
19 | }
20 | ]
21 | });
22 | }
23 |
24 | async run(ctx) {
25 |
26 |
27 | const profile = await runtime.getConfigOption(ctx.profile);
28 | const { Config } = require('@alicloud/openapi-client');
29 | const config = new Config({
30 | accessKeyId: profile.access_key_id,
31 | accessKeySecret: profile.access_key_secret,
32 | securityToken: profile.sts_token,
33 | regionId: profile.region,
34 | type: profile.type
35 | });
36 |
37 | const client = new Client(config);
38 | let result = await client.describeClusterResourcesWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
39 | if (result) {
40 | result = result.body;
41 | }
42 | const data = JSON.stringify(result, null, 2);
43 | console.log(data);
44 | }
45 | };
46 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/list-tags.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '查询可见的资源标签关系',
13 | en: `query tags that are attached to resources.`
14 | },
15 | options: {
16 | 'next-token': {
17 | mapping: 'ListTagResourcesRequest.nextToken',
18 | desc: {
19 | zh: '下一个查询开始的Token',
20 | en: `The token used to start the next query.`
21 | }
22 | },
23 | 'resource-ids': {
24 | mapping: 'ListTagResourcesRequest.resourceIds',
25 | vtype: 'array',
26 | subType: 'string',
27 | desc: {
28 | zh: '要查询的集群ID列表',
29 | en: `The IDs of the resources to query.`
30 | }
31 | },
32 | tags: {
33 | mapping: 'ListTagResourcesRequest.tags',
34 | vtype: 'array',
35 | subType: 'map',
36 | desc: {
37 | zh: '给集群打tag标签:key:标签名称;value:标签值',
38 | en: `The list of tags to query. This list is a JSON string that contains a maximum of 20 key-value pairs.`
39 | },
40 | options: {
41 | key: {
42 | mapping: 'key',
43 | desc: {
44 | zh: '标签名称',
45 | en: `the name of the tag.`
46 | }
47 | },
48 | value: {
49 | mapping: 'value',
50 | desc: {
51 | zh: '标签值',
52 | en: `the value of the tag.`
53 | }
54 | }
55 | }
56 | },
57 | }
58 | });
59 | }
60 |
61 | async run(ctx) {
62 |
63 | const profile = await runtime.getConfigOption(ctx.profile);
64 | const { Config } = require('@alicloud/openapi-client');
65 | const config = new Config({
66 | accessKeyId: profile.access_key_id,
67 | accessKeySecret: profile.access_key_secret,
68 | securityToken: profile.sts_token,
69 | regionId: profile.region,
70 | type: profile.type
71 | });
72 | const ListTagResourcesRequest = require(`@alicloud/cs20151215`).ListTagResourcesRequest;
73 | const request = new ListTagResourcesRequest(ctx.mappingValue.ListTagResourcesRequest);
74 |
75 | const client = new Client(config);
76 | const result = await client.listTagResourcesWithOptions(request, {}, runtime.getRuntimeOption());
77 | const data = JSON.stringify(result, null, 2);
78 | console.log(data);
79 | }
80 | };
81 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/list.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const runtime = require('../../../../lib/runtime.js');
5 |
6 | const Action = require('../../../../lib/action');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | short: {
12 | zh: '根据模糊查询获取集群信息',
13 | en: 'View all clusters'
14 | },
15 | desc: {
16 | zh: '查看您在容器服务中创建的所有集群(包括Swarm和Kubernetes集群)',
17 | en: `View all the clusters you created in the container service (including Swarm and Kubernetes clusters)`
18 | },
19 | options: {
20 | name: {
21 | mapping: 'DescribeClustersRequest.name',
22 | vtype: 'string',
23 | desc: {
24 | zh: '根据集群Name进行模糊匹配查询',
25 | en: `Fuzzy matching query based on cluster name`
26 | }
27 | },
28 | 'cluster-type': {
29 | mapping: 'DescribeClustersRequest.clusterType',
30 | vtype: 'string',
31 | desc: {
32 | zh: '集群类型',
33 | en: `Cluster type`
34 | }
35 | },
36 | 'page-size': {
37 | mapping: 'DescribeClustersRequest.pageSize',
38 | vtype: 'number',
39 | desc: {
40 | zh: '每页显示的记录数',
41 | en: `page size`
42 | }
43 | },
44 | 'page-number': {
45 | mapping: 'DescribeClustersRequest.pageNumber',
46 | vtype: 'number',
47 | desc: {
48 | zh: '总页数',
49 | en: `page number`
50 | }
51 | }
52 | }
53 | });
54 | }
55 |
56 | async run(ctx) {
57 | const profile = await runtime.getConfigOption(ctx.profile);
58 | const { Config } = require('@alicloud/openapi-client');
59 | const config = new Config({
60 | accessKeyId: profile.access_key_id,
61 | accessKeySecret: profile.access_key_secret,
62 | securityToken: profile.sts_token,
63 | regionId: profile.region,
64 | type: profile.type
65 | });
66 |
67 | const DescribeClustersV1Request = require(`@alicloud/cs20151215`).DescribeClustersV1Request;
68 | const request = new DescribeClustersV1Request(ctx.mappingValue.DescribeClustersRequest);
69 |
70 | const client = new Client(config);
71 | let result = await client.describeClustersV1WithOptions(request, {}, runtime.getRuntimeOption());
72 | if (result) {
73 | result = result.body;
74 | }
75 | const data = JSON.stringify(result, null, 2);
76 | console.log(data);
77 | }
78 | };
79 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/pause-upgrade.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '暂停集群升级',
13 | en: `suspend the upgrade of a cluster.`
14 | },
15 | args: [
16 | {
17 | name: 'clusterId',
18 | required: true,
19 | }
20 | ]
21 | });
22 | }
23 |
24 | async run(ctx) {
25 |
26 | const profile = await runtime.getConfigOption(ctx.profile);
27 | const { Config } = require('@alicloud/openapi-client');
28 | const config = new Config({
29 | accessKeyId: profile.access_key_id,
30 | accessKeySecret: profile.access_key_secret,
31 | securityToken: profile.sts_token,
32 | regionId: profile.region,
33 | type: profile.type
34 | });
35 |
36 | const client = new Client(config);
37 |
38 | await client.pauseClusterUpgradeWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/restart-upgrade.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '重新开始集群升级',
13 | en: `resume the upgrade of a cluster.`
14 | },
15 | args: [
16 | {
17 | name: 'clusterId',
18 | required: true,
19 | }
20 | ]
21 | });
22 | }
23 |
24 | async run(ctx) {
25 |
26 | const profile = await runtime.getConfigOption(ctx.profile);
27 | const { Config } = require('@alicloud/openapi-client');
28 | const config = new Config({
29 | accessKeyId: profile.access_key_id,
30 | accessKeySecret: profile.access_key_secret,
31 | securityToken: profile.sts_token,
32 | regionId: profile.region,
33 | type: profile.type
34 | });
35 |
36 | const client = new Client(config);
37 |
38 | await client.resumeUpgradeClusterWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/update-tag.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '修改集群tag信息',
13 | en: `modify the tags of a cluster.`
14 | },
15 | options: {
16 | 'body': {
17 | mapping: 'ModifyClusterTagsRequest.body',
18 | vtype: 'array',
19 | subType: 'map',
20 | desc: {
21 | zh: '集群标签列表',
22 | en: 'Cluster tag list'
23 | },
24 | options: {
25 | key: {
26 | required: true,
27 | mapping: 'key',
28 | desc: {
29 | zh: '标签名称',
30 | en: `The name of the tag to be modified.`
31 | }
32 | },
33 | value: {
34 | required: true,
35 | mapping: 'value',
36 | desc: {
37 | zh: '标签值',
38 | en: `The value of the tag to be modified.`
39 | }
40 | }
41 | }
42 | }
43 | },
44 | args: [
45 | {
46 | name: 'clusterId',
47 | required: true
48 | }
49 | ]
50 | });
51 | }
52 |
53 | async run(ctx) {
54 |
55 | const profile = await runtime.getConfigOption(ctx.profile);
56 | const { Config } = require('@alicloud/openapi-client');
57 | const config = new Config({
58 | accessKeyId: profile.access_key_id,
59 | accessKeySecret: profile.access_key_secret,
60 | securityToken: profile.sts_token,
61 | regionId: profile.region,
62 | type: profile.type
63 | });
64 | const ModifyClusterTagsRequest = require(`@alicloud/cs20151215`).ModifyClusterTagsRequest;
65 | const request = new ModifyClusterTagsRequest(ctx.mappingValue.ModifyClusterTagsRequest);
66 |
67 | const client = new Client(config);
68 | await client.modifyClusterTagsWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
69 | }
70 | };
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/update.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '修改集群',
13 | en: `modify the configurations of a cluster.`
14 | },
15 | options: {
16 | 'api-server-eip': {
17 | mapping: 'ModifyClusterRequest.apiServerEip',
18 | vtype: 'boolean',
19 | desc: {
20 | zh: '集群是否开启EIP',
21 | en: `Specifies whether to assign an elastic IP address to the API server of the cluster.`
22 | }
23 | },
24 | 'api-server-eip-id': {
25 | mapping: 'ModifyClusterRequest.apiServerEipId',
26 | desc: {
27 | zh: 'Kubernetes集群的apiServer的弹性IP(EIP)ID',
28 | en: `The ID of the elastic IP address that is assigned to the API server of the cluster.`
29 | },
30 | attributes: {
31 | show: [
32 | {
33 | 'api-server-eip': {
34 | type: 'equal',
35 | value: true
36 | }
37 | }
38 | ],
39 | required: [
40 | {
41 | 'api-server-eip': {
42 | type: 'equal',
43 | value: true
44 | }
45 | }
46 | ]
47 | }
48 | },
49 | 'deletion-protection': {
50 | mapping: 'ModifyClusterRequest.deletionProtection',
51 | vtype: 'boolean',
52 | desc: {
53 | zh: '是否开启集群删除保护',
54 | en: `Specifies whether to enable deletion protection for the cluster.`
55 | }
56 | },
57 | 'instance-deletion-protection': {
58 | mapping: 'ModifyClusterRequest.instanceDeletionProtection',
59 | vtype: 'boolean',
60 | desc: {
61 | zh: '实例删除保护,防止通过控制台或API误删除释放节点',
62 | // TODO
63 | en: ''
64 | }
65 | },
66 | 'ingress-domain-rebinding': {
67 | mapping: 'ModifyClusterRequest.ingressDomainRebinding',
68 | vtype: 'boolean',
69 | desc: {
70 | zh: '是否重新绑定域名到ingress的SLB地址',
71 | en: `Specifies whether to rebind the default domain name of the cluster to the public IP address of the SLB instance associated with the ingresses of the cluster.`
72 | }
73 | },
74 | 'ingress-loadbalancer-id': {
75 | mapping: 'ModifyClusterRequest.ingressLoadbalancerId',
76 | vtype: 'string',
77 | desc: {
78 | zh: 'Kubernetes集群的ingress loadbalancer的ID',
79 | en: `The ID of the Server Load Balancer (SLB) instance associated with the ingresses of the cluster.`
80 | }
81 | },
82 | 'resource-group-id': {
83 | mapping: 'ModifyClusterRequest.resourceGroupId',
84 | vtype: 'string',
85 | desc: {
86 | zh: 'Kubernetes集群资源组ID',
87 | en: 'The ID of the resource group to which the cluster belongs.'
88 | }
89 | },
90 | 'maintenance-window': {
91 | mapping: 'ModifyClusterRequest.maintenanceWindow',
92 | vtype: 'map',
93 | options: {
94 | 'enable': {
95 | mapping: 'enable',
96 | vtype: 'boolean',
97 | desc: {
98 | zh: '是否开启维护窗口',
99 | //TODO
100 | en: ''
101 | },
102 | default: false
103 | },
104 | 'maintenance-time': {
105 | mapping: 'maintenanceTime',
106 | vtype: 'string',
107 | desc: {
108 | zh: '维护起始时间。Golang标准时间格式"15:04:05Z"',
109 | //TODO
110 | en: ''
111 | }
112 | },
113 | 'duration': {
114 | mapping: 'duration',
115 | vtype: 'string',
116 | desc: {
117 | zh: '维护时长。取值范围1~24,单位为小时,默认值:3h',
118 | //TODO
119 | en: ''
120 | },
121 | default: '3h'
122 | },
123 | 'weekly-period': {
124 | mapping: 'weeklyPeriod',
125 | vtype: 'string',
126 | desc: {
127 | zh: '维护周期。取值范围为:Monday~Sunday,多个值用逗号分隔',
128 | //TODO
129 | en: ''
130 | },
131 | default: 'Thursday'
132 | }
133 | },
134 | desc: {
135 | // TODO
136 | zh: '',
137 | en: ''
138 | }
139 | }
140 | },
141 | args: [
142 | {
143 | name: 'clusterId',
144 | required: true
145 | }
146 | ]
147 | });
148 | }
149 |
150 | async run(ctx) {
151 |
152 | const profile = await runtime.getConfigOption(ctx.profile);
153 | const { Config } = require('@alicloud/openapi-client');
154 | const config = new Config({
155 | accessKeyId: profile.access_key_id,
156 | accessKeySecret: profile.access_key_secret,
157 | securityToken: profile.sts_token,
158 | regionId: profile.region,
159 | type: profile.type
160 | });
161 | const ModifyClusterRequest = require(`@alicloud/cs20151215`).ModifyClusterRequest;
162 | const request = new ModifyClusterRequest(ctx.mappingValue.ModifyClusterRequest);
163 |
164 | const client = new Client(config);
165 | let result = await client.modifyClusterWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
166 | if (result) {
167 | result = result.body;
168 | }
169 | const data = JSON.stringify(result, null, 2);
170 | console.log(data);
171 | }
172 | };
173 |
--------------------------------------------------------------------------------
/cmds/arc/cs/cluster/upgrade.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | zh: '升级用户集群版本',
13 | en: `upgrade a cluster.`
14 | },
15 | options: {
16 | 'component-name': {
17 | mapping: 'UpgradeClusterRequest.componentName',
18 | vtype: 'string',
19 | desc: {
20 | zh: '组件名称,升级集群时取值:k8s',
21 | en: `Component name, value when upgrading the cluster: k8s.`
22 | }
23 | },
24 | 'version': {
25 | mapping: 'UpgradeClusterRequest.version',
26 | vtype: 'string',
27 | desc: {
28 | zh: '集群当前版本',
29 | en: `Current version of the cluster`
30 | }
31 | },
32 | 'next-version': {
33 | mapping: 'UpgradeClusterRequest.nextVersion',
34 | vtype: 'string',
35 | desc: {
36 | zh: '集群可升级版本',
37 | en: `The target version of the upgrade.`
38 | }
39 | }
40 | },
41 | args: [
42 | {
43 | name: 'clusterId',
44 | required: true
45 | }
46 | ]
47 | });
48 | }
49 |
50 | async run(ctx) {
51 |
52 | const profile = await runtime.getConfigOption(ctx.profile);
53 | const { Config } = require('@alicloud/openapi-client');
54 | const config = new Config({
55 | accessKeyId: profile.access_key_id,
56 | accessKeySecret: profile.access_key_secret,
57 | securityToken: profile.sts_token,
58 | regionId: profile.region,
59 | type: profile.type
60 | });
61 | const UpgradeClusterRequest = require(`@alicloud/cs20151215`).UpgradeClusterRequest;
62 | const request = new UpgradeClusterRequest(ctx.mappingValue.UpgradeClusterRequest);
63 |
64 | const client = new Client(config);
65 | await client.upgradeClusterWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
66 | }
67 | };
68 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command');
4 |
5 | const ListCommand = require('./node/list');
6 | const DeleteCommand = require('./node/delete');
7 | const AttachCommand = require('./node/attach');
8 | const AttachEdgeCommand = require('./node/attach-edge');
9 | const GetAttachScriptCommand = require('./node/get-attach-script');
10 |
11 | module.exports = class extends Command {
12 | constructor(name) {
13 | super(name, {
14 | desc: {
15 | zh: '集群节点操作',
16 | en: `Action of container service node`
17 | }
18 | });
19 |
20 | this.registerCommand(new ListCommand('list'));
21 | this.registerCommand(new DeleteCommand('delete'));
22 | this.registerCommand(new AttachCommand('attach'));
23 | this.registerCommand(new AttachEdgeCommand('attach-edge'));
24 | this.registerCommand(new GetAttachScriptCommand('get-attach-script'));
25 | }
26 |
27 | async run(args) {
28 | await this.help();
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node/attach-edge.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '添加已有ENS节点至边缘托管集群',
12 | en: `add existing Edge Node Service (ENS) instances to a managed edge cluster.`
13 | },
14 | options: {
15 | 'is_edge_worker': {
16 | vtype: 'boolean',
17 | required: true,
18 | mapping: 'AttachInstancesRequest.isEdgeWorker',
19 | desc: {
20 | zh: `是否为边缘节点。接入ENS节点时需要配置为true`,
21 | en: `Specifies whether to configure the worker node as an edge node. Set the value to true.`
22 | }
23 | },
24 | 'instances': {
25 | mapping: 'AttachInstancesRequest.instances',
26 | required: true,
27 | vtype: 'array',
28 | subType: 'string',
29 | desc: {
30 | zh: '实例列表',
31 | en: `A list of the ECS instances.`
32 | },
33 | },
34 | 'rds-instances': {
35 | mapping: 'AttachInstancesRequest.rdsInstances',
36 | vtype: 'array',
37 | subType: 'string',
38 | desc: {
39 | zh: 'RDS实例列表',
40 | en: `A list of the RDS instances.`
41 | }
42 | },
43 | 'keep-instance-name': {
44 | mapping: 'AttachInstancesRequest.keepInstanceName',
45 | vtype: 'boolean',
46 | desc: {
47 | zh: '是否保留实例名称',
48 | en: `Specifies whether to retain the names of the ECS instances.`
49 | }
50 | },
51 | 'format-disk': {
52 | mapping: 'AttachInstancesRequest.formatDisk',
53 | vtype: 'boolean',
54 | desc: {
55 | zh: '是否格式化数据盘',
56 | en: `Specifies whether to format the data disks of the ECS instances.`
57 | }
58 | }
59 | },
60 | args: [
61 | {
62 | name: 'clusterId',
63 | required: true
64 | }
65 | ]
66 | });
67 | }
68 |
69 | async run(ctx) {
70 | const profile = await runtime.getConfigOption(ctx.profile);
71 | const { Config } = require('@alicloud/openapi-client');
72 | const config = new Config({
73 | accessKeyId: profile.access_key_id,
74 | accessKeySecret: profile.access_key_secret,
75 | securityToken: profile.sts_token,
76 | regionId: profile.region,
77 | type: profile.type
78 | });
79 | const AttachInstancesRequest = require(`@alicloud/cs20151215`).AttachInstancesRequest;
80 | const request = new AttachInstancesRequest(ctx.mappingValue.AttachInstancesRequest);
81 |
82 | const client = new Client(config);
83 | let result = await client.attachInstancesWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
84 | if (result) {
85 | result = result.body;
86 | }
87 | const data = JSON.stringify(result, null, 2);
88 | console.log(data);
89 | }
90 | };
91 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node/attach.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '添加已有ECS节点到Kubernetes集群',
12 | en: `existing Elastic Compute Service (ECS) instances to a cluster.`
13 | },
14 | options: {
15 | 'key-pair': {
16 | mapping: 'AttachInstancesRequest.keyPair',
17 | desc: {
18 | zh: 'key-pair名称',
19 | en: `The name of the key pair. You must set key_pair or password.`
20 | },
21 | },
22 | 'password': {
23 | mapping: 'AttachInstancesRequest.password',
24 | desc: {
25 | zh: '扩容的worker节点密码。密码规则为8~30 个字符,且同时包含三项(大、小写字母,数字和特殊符号)',
26 | en: `The password of the worker nodes to be added. The password must be 8 to 30 characters in length and contain three of the following character types: uppercase letters, lowercase letters, digits, and special characters. You must set key_pair or password.`
27 | },
28 | conflicts: [
29 | 'key-pair'
30 | ]
31 | },
32 | 'format-disk': {
33 | mapping: 'AttachInstancesRequest.formatDisk',
34 | vtype: 'boolean',
35 | desc: {
36 | zh: '是否格式化数据盘',
37 | en: `Specifies whether to format the data disks of the ECS instances.`
38 | }
39 | },
40 | 'keep-instance-name': {
41 | mapping: 'AttachInstancesRequest.keepInstanceName',
42 | vtype: 'boolean',
43 | desc: {
44 | zh: '是否保留实例名称',
45 | en: `Specifies whether to retain the names of the ECS instances.`
46 | }
47 | },
48 | 'cpu-policy': {
49 | mapping: 'AttachInstancesRequest.cpuPolicy',
50 | desc: {
51 | zh: 'CPU策略。Kubernetes集群版本为1.12.6及以上版本支持static和none两种策略,默认为none。',
52 | en: `The CPU policy. For Kubernetes 1.12.6 and later, valid values of cpu_policy include static and none. Default value: none.`
53 | }
54 | },
55 | 'instances': {
56 | mapping: 'AttachInstancesRequest.instances',
57 | required: true,
58 | vtype: 'array',
59 | subType: 'string',
60 | desc: {
61 | zh: '实例列表',
62 | en: `A list of the ECS instances.`
63 | },
64 | },
65 | tags: {
66 | mapping: 'AttachInstancesRequest.tags',
67 | vtype: 'array',
68 | subType: 'map',
69 | mappingType: require('@alicloud/cs20151215').AttachInstancesRequestTags,
70 | desc: {
71 | zh: '自定义节点标签',
72 | en: `The tags of the ECS instances.`
73 | },
74 | example: `key=tier,value=backend`,
75 | options: {
76 | key: {
77 | mapping: 'key',
78 | desc: {
79 | zh: '标签名称',
80 | en: `the name of tag`
81 | }
82 | },
83 | value: {
84 | mapping: 'value',
85 | desc: {
86 | zh: '标签值',
87 | en: `the value of tag`
88 | }
89 | }
90 | }
91 | },
92 | 'runtime': {
93 | mapping: 'AttachInstancesRequest.runtime',
94 | vtype: 'map',
95 | desc: {
96 | zh: '容器运行时,一般为docker,包括2个信息:name和version',
97 | en: `The runtime of containers. Default value: docker. Specify the runtime name and version.`
98 | },
99 | example: `name=docker,version=19.03.5`,
100 | options: {
101 | name: {
102 | mapping: 'name',
103 | desc: {
104 | zh: '容器运行时名称',
105 | en: `runtime name `
106 | }
107 | },
108 | version: {
109 | mapping: 'version',
110 | desc: {
111 | zh: '容器运行时版本',
112 | en: `runtime version `
113 | }
114 | }
115 | }
116 | },
117 | 'image-id': {
118 | mapping: 'AttachInstancesRequest.imageId',
119 | desc: {
120 | zh: '自定义镜像,默认使用系统镜像。当选择自定义镜像时,将取代默认系统镜像。',
121 | en: `Custom image, system image is used by default. When selecting a custom image, it will replace the default system image.`
122 | }
123 | },
124 | 'user-data': {
125 | mapping: 'AttachInstancesRequest.userData',
126 | desc: {
127 | zh: 'RDS实例列表,将该ECS加入到选择的RDS实例的白名单中。',
128 | en: `RDS instance list, add the ECS to the whitelist of the selected RDS instance.`
129 | }
130 | },
131 | 'nodepool-id': {
132 | mapping: 'AttachInstancesRequest.nodepoolId',
133 | desc: {
134 | zh: `节点池ID。`,
135 | en: `Node pool ID.`
136 | }
137 | },
138 | 'rds-instances': {
139 | mapping: 'AttachInstancesRequest.rdsInstances',
140 | vtype: 'array',
141 | subType: 'string',
142 | desc: {
143 | zh: 'RDS实例列表',
144 | en: `A list of the RDS instances.`
145 | }
146 | },
147 | },
148 | conflicts: [
149 | {
150 | optNames: ['key-pair', 'password'],
151 | required: true
152 | }
153 | ],
154 | args: [
155 | {
156 | name: 'clusterId',
157 | required: true
158 | }
159 | ]
160 | });
161 | }
162 |
163 | async run(ctx) {
164 | const profile = await runtime.getConfigOption(ctx.profile);
165 | const { Config } = require('@alicloud/openapi-client');
166 | const config = new Config({
167 | accessKeyId: profile.access_key_id,
168 | accessKeySecret: profile.access_key_secret,
169 | securityToken: profile.sts_token,
170 | regionId: profile.region,
171 | type: profile.type
172 | });
173 | const AttachInstancesRequest = require(`@alicloud/cs20151215`).AttachInstancesRequest;
174 | const request = new AttachInstancesRequest(ctx.mappingValue.AttachInstancesRequest);
175 |
176 | const client = new Client(config);
177 | let result = await client.attachInstancesWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
178 | if (result) {
179 | result = result.body;
180 | }
181 | const data = JSON.stringify(result, null, 2);
182 | console.log(data);
183 | }
184 | };
185 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node/delete.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '移除集群节点',
12 | en: `remove nodes from a cluster.`
13 | },
14 | options: {
15 | 'release-node': {
16 | mapping: 'DeleteClusterNodesRequest.releaseNode',
17 | vtype: 'boolean',
18 | desc: {
19 | zh: '是否同时释放ECS',
20 | en: `Specifies whether to release the Elastic Compute Service (ECS) instances when they are removed from the cluster.`
21 | }
22 | },
23 | 'drain-node': {
24 | mapping: 'DeleteClusterNodesRequest.drainNode',
25 | vtype: 'boolean',
26 | desc: {
27 | zh: '是否排空节点上的Pod',
28 | en: `Specifies whether to remove all pods from the nodes that you want to remove.`
29 | }
30 | },
31 | nodes: {
32 | mapping: 'DeleteClusterNodesRequest.nodes',
33 | vtype: 'array',
34 | subType: 'string',
35 | desc: {
36 | zh: '要移除的node_name数组',
37 | en: `A list of the nodes that you want to remove.`
38 | }
39 | },
40 | },
41 | args: [
42 | {
43 | name: 'clusterId',
44 | required: true
45 | }
46 | ]
47 | });
48 | }
49 |
50 | async run(ctx) {
51 | const profile = await runtime.getConfigOption(ctx.profile);
52 | const { Config } = require('@alicloud/openapi-client');
53 | const config = new Config({
54 | accessKeyId: profile.access_key_id,
55 | accessKeySecret: profile.access_key_secret,
56 | securityToken: profile.sts_token,
57 | regionId: profile.region,
58 | type: profile.type
59 | });
60 | const DeleteClusterNodesRequest = require(`@alicloud/cs20151215`).DeleteClusterNodesRequest;
61 | const request = new DeleteClusterNodesRequest(ctx.mappingValue.DeleteClusterNodesRequest);
62 |
63 | const client = new Client(config);
64 | await client.deleteClusterNodesWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
65 | }
66 | };
67 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node/get-attach-script.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | short: {
11 | zh: '生成Kubernetes边缘托管版集群的节点接入脚本',
12 | en: 'Generate Kubernetes edge managed cluster node endpoint script'
13 | },
14 | desc: {
15 | zh: `生成Kubernetes边缘托管版集群的节点接入脚本
16 | 该API返回唯一的可执行脚本。您获取脚本后,在已有节点上执行该脚本即可完成节点的接入。`,
17 | en: `The API returns the only executable script. After you obtain the script, execute the script on the existing node to complete the node access.`
18 | },
19 | options: {
20 | arch: {
21 | mapping: 'DescribeClusterAttachScriptsRequest.arch',
22 | vtype: 'string',
23 | desc: {
24 | zh: '节点CPU架构。支持的CPU架构包括:amd64、arm、arm64。默认amd64。当集群类型为边缘托管版时必填',
25 | en: `Node CPU architecture. Supported CPU architectures include: amd64, arm, arm64. The default is amd64. Required when the cluster type is edge hosting version.`
26 | },
27 | choices: [
28 | 'amd64',
29 | 'arm',
30 | 'arm64'
31 | ]
32 | },
33 | 'nodepool-id': {
34 | mapping: 'DescribeClusterAttachScriptsRequest.nodepoolId',
35 | vtype: 'string',
36 | desc: {
37 | zh: '节点池ID',
38 | en: `nodepool Id`
39 | }
40 | },
41 | 'format-disk': {
42 | mapping: 'DescribeClusterAttachScriptsRequest.formatDisk',
43 | vtype: 'boolean',
44 | desc: {
45 | zh: '数据盘挂载',
46 | // TODO
47 | en: ``
48 | }
49 | },
50 | 'keep-instance-name': {
51 | mapping: 'DescribeClusterAttachScriptsRequest.keepInstanceName',
52 | vtype: 'boolean',
53 | desc: {
54 | zh: '保留实例名称',
55 | en: `Keep instance name`
56 | }
57 | },
58 | 'rds-instances': {
59 | mapping: 'DescribeClusterAttachScriptsRequest.rdsInstances',
60 | vtype: 'array',
61 | subType: 'string',
62 | desc: {
63 | zh: 'RDS白名单',
64 | // TODO
65 | en: ``
66 | }
67 | },
68 | 'option': {
69 | mapping: 'DescribeClusterAttachScriptsRequest.options',
70 | vtype: 'string',
71 | desc: {
72 | zh: '边缘托管版集群节点的接入配置',
73 | en: `Node access configuration parameters`
74 | }
75 | }
76 | },
77 | args: [
78 | {
79 | name: 'clusterId',
80 | required: true
81 | }
82 | ]
83 | });
84 | }
85 |
86 | async run(ctx) {
87 | const profile = await runtime.getConfigOption(ctx.profile);
88 | const { Config } = require('@alicloud/openapi-client');
89 | const config = new Config({
90 | accessKeyId: profile.access_key_id,
91 | accessKeySecret: profile.access_key_secret,
92 | securityToken: profile.sts_token,
93 | regionId: profile.region,
94 | type: profile.type
95 | });
96 | const DescribeClusterAttachScriptsRequest = require(`@alicloud/cs20151215`).DescribeClusterAttachScriptsRequest;
97 | const request = new DescribeClusterAttachScriptsRequest(ctx.mappingValue.DescribeClusterAttachScriptsRequest);
98 |
99 | const client = new Client(config);
100 | let result = await client.describeClusterAttachScriptsWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
101 |
102 | if (result) {
103 | result = result.body;
104 | }
105 | const data = JSON.stringify(result, null, 2);
106 | console.log(data);
107 | }
108 | };
109 |
--------------------------------------------------------------------------------
/cmds/arc/cs/node/list.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 | const runtime = require('../../../../lib/runtime.js');
6 |
7 | module.exports = class extends Action {
8 | constructor(name) {
9 | super(name, {
10 | desc: {
11 | zh: '查询集群节点',
12 | en: `query nodes in a cluster.`
13 | },
14 | options: {
15 | 'instance-ids': {
16 | mapping: 'DescribeClusterNodesRequest.instanceIds',
17 | vtype: 'array',
18 | subType: 'string',
19 | desc: {
20 | zh: '节点实例ID,按照实例ID进行过滤',
21 | // TODO
22 | en: ``
23 | },
24 | attributes: {
25 | show: [
26 | {
27 | 'nodepool-id': {
28 | type: 'equal',
29 | value: undefined
30 | }
31 | }
32 | ]
33 | }
34 | },
35 | 'page-size': {
36 | mapping: 'DescribeClusterNodesRequest.pageSize',
37 | desc: {
38 | zh: '分页大小',
39 | en: `The number of entries to return on each page.`
40 | }
41 | },
42 | 'page-number': {
43 | mapping: 'DescribeClusterNodesRequest.pageNumber',
44 | desc: {
45 | zh: '共计展示多少页',
46 | en: `The total number of pages to return.`
47 | }
48 | },
49 | 'nodepool-id': {
50 | mapping: 'DescribeClusterNodesRequest.nodepoolId',
51 | vtype: 'string',
52 | desc: {
53 | zh: '节点池ID',
54 | en: `The ID of the node pool.`
55 | }
56 | },
57 | 'state': {
58 | mapping: 'DescribeClusterNodesRequest.state',
59 | desc: {
60 | zh: '状态信息',
61 | en: `The status of the cluster.`
62 | }
63 | }
64 | },
65 | args: [
66 | {
67 | name: 'clusterId',
68 | required: true
69 | }
70 | ]
71 | });
72 | }
73 |
74 | async run(ctx) {
75 | const profile = await runtime.getConfigOption(ctx.profile);
76 | const { Config } = require('@alicloud/openapi-client');
77 | const config = new Config({
78 | accessKeyId: profile.access_key_id,
79 | accessKeySecret: profile.access_key_secret,
80 | securityToken: profile.sts_token,
81 | regionId: profile.region,
82 | type: profile.type
83 | });
84 | const DescribeClusterNodesRequest = require(`@alicloud/cs20151215`).DescribeClusterNodesRequest;
85 | const request = new DescribeClusterNodesRequest(ctx.mappingValue.DescribeClusterNodesRequest);
86 |
87 | const client = new Client(config);
88 | let result = await client.describeClusterNodesWithOptions(ctx.argv[0], request, {}, runtime.getRuntimeOption());
89 |
90 | if (result) {
91 | result = result.body;
92 | }
93 | const data = JSON.stringify(result, null, 2);
94 | console.log(data);
95 | }
96 | };
97 |
--------------------------------------------------------------------------------
/cmds/arc/cs/nodepool.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const Command = require('../../../lib/command');
4 |
5 | const CreateCommand = require('./nodepool/create');
6 | const DeleteCommand = require('./nodepool/delete');
7 | const GetCommand = require('./nodepool/get');
8 | const ListCommand = require('./nodepool/list');
9 | const ScaleoutCommand = require('./nodepool/scaleout');
10 | const UpdateCommand = require('./nodepool/update');
11 |
12 | module.exports = class extends Command {
13 | constructor(name) {
14 | super(name, {
15 | desc: {
16 | zh: '集群节点池操作',
17 | en: `cluster node pool operations`
18 | }
19 | });
20 |
21 | this.registerCommand(new CreateCommand('create'));
22 | this.registerCommand(new DeleteCommand('delete'));
23 | this.registerCommand(new GetCommand('get'));
24 | this.registerCommand(new ListCommand('list'));
25 | this.registerCommand(new ScaleoutCommand('scaleout'));
26 | this.registerCommand(new UpdateCommand('update'));
27 | }
28 |
29 | async run(args) {
30 | await this.help();
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/cmds/arc/cs/nodepool/delete.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | en: 'Delete the cluster node pool',
13 | zh: '删除节点池'
14 | },
15 | options: {
16 |
17 | },
18 | args: [
19 | {
20 | name: 'clusterId',
21 | required: true,
22 | vtype: 'string',
23 | desc: {
24 | zh: '容器实例Id',
25 | en: ''
26 | }
27 | },
28 | {
29 | name: 'nodepoolId',
30 | required: true,
31 | vtype: 'string',
32 | desc: {
33 | zh: '节点池Id',
34 | en: ''
35 | }
36 | }
37 | ]
38 | });
39 | }
40 |
41 | async run(ctx) {
42 |
43 | const profile = await runtime.getConfigOption(ctx.profile);
44 | const { Config } = require('@alicloud/openapi-client');
45 | const config = new Config({
46 | accessKeyId: profile.access_key_id,
47 | accessKeySecret: profile.access_key_secret,
48 | securityToken: profile.sts_token,
49 | regionId: profile.region,
50 | type: profile.type
51 | });
52 |
53 | const client = new Client(config);
54 | let result = await client.deleteClusterNodepoolWithOptions(ctx.argv[0], ctx.argv[1], {}, runtime.getRuntimeOption());
55 |
56 | if (result) {
57 | result = result.body;
58 | }
59 | const data = JSON.stringify(result, null, 2);
60 | console.log(data);
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/cmds/arc/cs/nodepool/get.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | en: 'Describe the cluster node pool',
13 | zh: '查询集群指定节点池详情'
14 | },
15 | options: {
16 |
17 | },
18 | args: [
19 | {
20 | name: 'clusterId',
21 | required: true,
22 | vtype: 'string',
23 | desc: {
24 | zh: '容器实例Id',
25 | en: ''
26 | }
27 | },
28 | {
29 | name: 'nodepoolId',
30 | required: true,
31 | vtype: 'string',
32 | desc: {
33 | zh: '节点池Id',
34 | en: ''
35 | }
36 | }
37 | ]
38 | });
39 | }
40 |
41 | async run(ctx) {
42 |
43 | const profile = await runtime.getConfigOption(ctx.profile);
44 | const { Config } = require('@alicloud/openapi-client');
45 | const config = new Config({
46 | accessKeyId: profile.access_key_id,
47 | accessKeySecret: profile.access_key_secret,
48 | securityToken: profile.sts_token,
49 | regionId: profile.region,
50 | type: profile.type
51 | });
52 |
53 | const client = new Client(config);
54 | let result = await client.describeClusterNodePoolDetailWithOptions(ctx.argv[0], ctx.argv[1], {}, runtime.getRuntimeOption());
55 |
56 | if (result) {
57 | result = result.body;
58 | }
59 | const data = JSON.stringify(result, null, 2);
60 | console.log(data);
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/cmds/arc/cs/nodepool/list.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | en: 'Describe a cluster node pools',
13 | zh: '查询集群内所有节点池详情'
14 | },
15 | options: {},
16 | args: [
17 | {
18 | name: 'clusterId',
19 | required: true,
20 | vtype: 'string',
21 | desc: {
22 | zh: '容器实例Id',
23 | en: ''
24 | }
25 | }
26 | ]
27 | });
28 | }
29 |
30 | async run(ctx) {
31 | const profile = await runtime.getConfigOption(ctx.profile);
32 | const { Config } = require('@alicloud/openapi-client');
33 | const config = new Config({
34 | accessKeyId: profile.access_key_id,
35 | accessKeySecret: profile.access_key_secret,
36 | securityToken: profile.sts_token,
37 | regionId: profile.region,
38 | type: profile.type
39 | });
40 |
41 | const client = new Client(config);
42 | let result = await client.describeClusterNodePoolsWithOptions(ctx.argv[0], {}, runtime.getRuntimeOption());
43 |
44 | if (result) {
45 | result = result.body;
46 | }
47 | const data = JSON.stringify(result, null, 2);
48 | console.log(data);
49 | }
50 | };
51 |
--------------------------------------------------------------------------------
/cmds/arc/cs/nodepool/scaleout.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { default: Client } = require(`@alicloud/cs20151215`);
4 | const Action = require('../../../../lib/action.js');
5 |
6 | const runtime = require('../../../../lib/runtime.js');
7 |
8 | module.exports = class extends Action {
9 | constructor(name) {
10 | super(name, {
11 | desc: {
12 | en: 'Scaleout node pools',
13 | zh: '扩容节点池节点'
14 | },
15 | options: {
16 | 'count': {
17 | mapping: 'ScaleClusterNodePoolRequest.count',
18 | vtype: 'number',
19 | desc: {
20 | en: '',
21 | zh: '扩容节点数量。受当前集群节点配额限制,单次操作最多扩容500个节点'
22 | }
23 | }
24 | },
25 | args: [
26 | {
27 | name: 'clusterId',
28 | required: true,
29 | vtype: 'string',
30 | desc: {
31 | zh: '容器实例Id',
32 | en: ''
33 | }
34 | },
35 | {
36 | name: 'nodepoolId',
37 | required: true,
38 | vtype: 'string',
39 | desc: {
40 | zh: '节点池Id',
41 | en: ''
42 | }
43 | }
44 | ]
45 | });
46 | }
47 |
48 | async run(ctx) {
49 |
50 | const profile = await runtime.getConfigOption(ctx.profile);
51 | const { Config } = require('@alicloud/openapi-client');
52 | const config = new Config({
53 | accessKeyId: profile.access_key_id,
54 | accessKeySecret: profile.access_key_secret,
55 | securityToken: profile.sts_token,
56 | regionId: profile.region,
57 | type: profile.type
58 | });
59 | const ScaleClusterNodePoolRequest = require(`@alicloud/cs20151215`).ScaleClusterNodePoolRequest;
60 | const request = new ScaleClusterNodePoolRequest(ctx.mappingValue.ScaleClusterNodePoolRequest);
61 | const client = new Client(config);
62 | let result = await client.scaleClusterNodePoolWithOptions(ctx.argv[0], ctx.argv[1], request, {}, runtime.getRuntimeOption());
63 | if (result) {
64 | result = result.body;
65 | }
66 | const data = JSON.stringify(result, null, 2);
67 | console.log(data);
68 | }
69 | };
70 |
--------------------------------------------------------------------------------
/cmds/arc/ecs.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | exports.cmdObj = {
4 | use: 'arc ecs',
5 | desc: {
6 | zh: '云服务器'
7 | },
8 | sub: {
9 | instance: {
10 | zh: '云服务器实例相关操作'
11 | },
12 | }
13 | };
--------------------------------------------------------------------------------
/cmds/arc/ecs/instance.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | exports.cmdObj = {
4 | desc: {
5 | zh: '实例相关操作'
6 | },
7 | sub: {
8 | }
9 | };
--------------------------------------------------------------------------------
/cmds/arc/ecs/instance/run.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | exports.cmdObj={
4 | use:'arc ecs instane run',
5 | desc:{
6 | zh:'创建一台或多台按量付费或者包年包月ECS实例'
7 | },
8 | options:{
9 | region:{
10 | required:true,
11 | mapping:'regionId',
12 | desc:{
13 | zh:'实例所属的地域ID'
14 | }
15 | },
16 | 'image-id':{
17 | mapping:'imageId',
18 | desc:{
19 | zh:`镜像ID,启动实例时选择的镜像资源
20 | 如果您不指定launch-template-id或launch-template-name以确定启动模板,也不通过指定image-family选用镜像族系最新可用的自定义镜像,则该选项为必选。`
21 | },
22 | sufficient:function(val){
23 | const optList={};
24 | if (!val){
25 | optList['ImageFamily']=false;
26 | }
27 | }
28 | },
29 | 'image-family':{
30 | mapping:'imageFamily',
31 | desc:{
32 | zh:`镜像族系名称,通过设置该参数来获取当前镜像族系内最新可用的自定义镜像来创建实例
33 | 1. 设置了参数ImageId,则不能设置该参数。
34 | 2. 未设置参数ImageId,但指定的LaunchTemplateId或LaunchTemplateName对应的启动模板设置了ImageId,则不能设置该参数。
35 | 3. 未设置ImageId,且指定的LaunchTemplateId或LaunchTemplateName对应的启动模板未设置ImageId,则可以设置该参数。
36 | 4. 未设置ImageId,且未设置LaunchTemplateId、LaunchTemplateName参数,则可以设置该参数。`
37 | }
38 | },
39 | 'instance-type':{
40 | mapping:'instanceType',
41 | desc:{
42 | zh:'实例的资源规格。如果您不指定LaunchTemplateId或LaunchTemplateName以确定启动模板,InstanceType为必选参数'
43 | }
44 | },
45 | 'security-group-id':{
46 | mapping:'securityGroupId',
47 | desc:{
48 | zh:`指定新创建实例所属于的安全组ID。
49 | 1. SecurityGroupId决定了实例的网络类型,例如,如果指定安全组的网络类型为专有网络VPC,实例则为VPC类型,并同时需要指定参数VSwitchId。
50 | 2. 如果您不指定LaunchTemplateId或LaunchTemplateName以确定启动模板,SecurityGroupId为必选参数。`
51 | },
52 | conflicts:[
53 | 'security-group-ids'
54 | ]
55 | },
56 | 'security-group-ids':{
57 | mapping:'securityGroupIds',
58 | vtype:'array',
59 | subType:'string',
60 | desc:{
61 | zh: `将实例同时加入多个安全组,数量与实例能够加入安全组配额有关`
62 | },
63 | options:{
64 | element: {
65 | desc: {
66 | zh: '安全组ID'
67 | }
68 | }
69 | },
70 | conflicts:[
71 | 'security-group-id',
72 | ]
73 | },
74 | 'vswitch-id':{
75 | mapping:'VSwitchId',
76 | desc:{
77 | zh:'虚拟交换机ID。如果您创建的是VPC类型ECS实例,必须指定虚拟交换机ID,且安全组和虚拟交换机在同一个专有网络VPC中'
78 | }
79 | },
80 | 'instance-name':{
81 | mapping:'instanceName',
82 | desc:{
83 | zh:`实例名称。
84 | 1. 长度为2~128个字符,必须以大小字母或中文开头,不能以http://和https://开头。
85 | 2. 可以包含中文、英文、数字、半角冒号(:)、下划线(_)、点号(.)或者连字符(-)。
86 | 3. 默认值为实例的InstanceId。
87 | 4. 创建多台ECS实例时,您可以使用UniqueSuffix为这些实例设置不同的实例名称。您也可以使用name_prefix[begin_number,bits]name_suffix的命名格式设置有序的实例名称,例如,设置InstanceName取值为k8s-node-[1,4]-alibabacloud,则第一台ECS实例的实例名称为k8s-node-0001-alibabacloud`
88 | }
89 | },
90 | 'description':{
91 | mapping:'description',
92 | desc:{
93 | zh:'实例的描述。长度为2~256个英文或中文字符,不能以http://和https://开头'
94 | }
95 | }
96 | }
97 | };
--------------------------------------------------------------------------------
/cmds/arc/ecs/region.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | 'use strict';
4 | const Core = require('@alicloud/pop-core');
5 |
6 | module.exports = {
7 | async list() {
8 | var client = new Core({
9 | accessKeyId: process.env.ACCESS_KEY_ID,
10 | accessKeySecret: process.env.ACCESS_KEY_SECRET,
11 | endpoint: 'https://ecs.aliyuncs.com',
12 | apiVersion: '2014-05-26'
13 | });
14 |
15 | var requestOption = {
16 | method: 'POST'
17 | };
18 | return await client.request('DescribeRegions', {}, requestOption);
19 | }
20 | };
21 |
--------------------------------------------------------------------------------
/cmds/meta.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | exports.cmdObj = {
4 | desc: {
5 | zh: 'Alibaba Cloud CLI'
6 | },
7 | sub: {
8 | 'arc-tool': {
9 | zh: 'ARC 工具'
10 | },
11 | products: {
12 | zh: '阿里云产品相关命令'
13 | }
14 | },
15 | options: {
16 | profile: {
17 | desc: {
18 | zh: '指定要使用的配置文件',
19 | en: `Specify the profile name to be used`
20 | }
21 | },
22 | region: {
23 | desc: {
24 | zh: '指定阿里云区域',
25 | en: `Region ID`
26 | }
27 | },
28 | interaction: {
29 | vtype: 'boolean',
30 | alias: 'i',
31 | desc: {
32 | zh: '交互式填充参数',
33 | en: `Interactive fill parameter`
34 | }
35 | }
36 | }
37 | };
--------------------------------------------------------------------------------
/front/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/front/config/env.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const paths = require('./paths');
6 |
7 | // Make sure that including paths.js after env.js will read .env variables.
8 | delete require.cache[require.resolve('./paths')];
9 |
10 | const NODE_ENV = process.env.NODE_ENV;
11 | if (!NODE_ENV) {
12 | throw new Error(
13 | 'The NODE_ENV environment variable is required but was not specified.'
14 | );
15 | }
16 |
17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18 | const dotenvFiles = [
19 | `${paths.dotenv}.${NODE_ENV}.local`,
20 | // Don't include `.env.local` for `test` environment
21 | // since normally you expect tests to produce the same
22 | // results for everyone
23 | NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24 | `${paths.dotenv}.${NODE_ENV}`,
25 | paths.dotenv,
26 | ].filter(Boolean);
27 |
28 | // Load environment variables from .env* files. Suppress warnings using silent
29 | // if this file is missing. dotenv will never modify any environment variables
30 | // that have already been set. Variable expansion is supported in .env files.
31 | // https://github.com/motdotla/dotenv
32 | // https://github.com/motdotla/dotenv-expand
33 | dotenvFiles.forEach(dotenvFile => {
34 | if (fs.existsSync(dotenvFile)) {
35 | require('dotenv-expand')(
36 | require('dotenv').config({
37 | path: dotenvFile,
38 | })
39 | );
40 | }
41 | });
42 |
43 | // We support resolving modules according to `NODE_PATH`.
44 | // This lets you use absolute paths in imports inside large monorepos:
45 | // https://github.com/facebook/create-react-app/issues/253.
46 | // It works similar to `NODE_PATH` in Node itself:
47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49 | // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50 | // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51 | // We also resolve them to make sure all tools using them work consistently.
52 | const appDirectory = fs.realpathSync(process.cwd());
53 | process.env.NODE_PATH = (process.env.NODE_PATH || '')
54 | .split(path.delimiter)
55 | .filter(folder => folder && !path.isAbsolute(folder))
56 | .map(folder => path.resolve(appDirectory, folder))
57 | .join(path.delimiter);
58 |
59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60 | // injected into the application via DefinePlugin in webpack configuration.
61 | const REACT_APP = /^REACT_APP_/i;
62 |
63 | function getClientEnvironment(publicUrl) {
64 | const raw = Object.keys(process.env)
65 | .filter(key => REACT_APP.test(key))
66 | .reduce(
67 | (env, key) => {
68 | env[key] = process.env[key];
69 | return env;
70 | },
71 | {
72 | // Useful for determining whether we’re running in production mode.
73 | // Most importantly, it switches React into the correct mode.
74 | NODE_ENV: process.env.NODE_ENV || 'development',
75 | // Useful for resolving the correct path to static assets in `public`.
76 | // For example,
.
77 | // This should only be used as an escape hatch. Normally you would put
78 | // images into the `src` and `import` them in code to get their paths.
79 | PUBLIC_URL: publicUrl,
80 | // We support configuring the sockjs pathname during development.
81 | // These settings let a developer run multiple simultaneous projects.
82 | // They are used as the connection `hostname`, `pathname` and `port`
83 | // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84 | // and `sockPort` options in webpack-dev-server.
85 | WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86 | WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87 | WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88 | // Whether or not react-refresh is enabled.
89 | // react-refresh is not 100% stable at this time,
90 | // which is why it's disabled by default.
91 | // It is defined here so it is available in the webpackHotDevClient.
92 | FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
93 | }
94 | );
95 | // Stringify all values so we can feed into webpack DefinePlugin
96 | const stringified = {
97 | 'process.env': Object.keys(raw).reduce((env, key) => {
98 | env[key] = JSON.stringify(raw[key]);
99 | return env;
100 | }, {}),
101 | };
102 |
103 | return { raw, stringified };
104 | }
105 |
106 | module.exports = getClientEnvironment;
107 |
--------------------------------------------------------------------------------
/front/config/getHttpsConfig.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const crypto = require('crypto');
6 | const chalk = require('react-dev-utils/chalk');
7 | const paths = require('./paths');
8 |
9 | // Ensure the certificate and key provided are valid and if not
10 | // throw an easy to debug error
11 | function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12 | let encrypted;
13 | try {
14 | // publicEncrypt will throw an error with an invalid cert
15 | encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16 | } catch (err) {
17 | throw new Error(
18 | `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19 | );
20 | }
21 |
22 | try {
23 | // privateDecrypt will throw an error with an invalid key
24 | crypto.privateDecrypt(key, encrypted);
25 | } catch (err) {
26 | throw new Error(
27 | `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28 | err.message
29 | }`
30 | );
31 | }
32 | }
33 |
34 | // Read file and throw an error if it doesn't exist
35 | function readEnvFile(file, type) {
36 | if (!fs.existsSync(file)) {
37 | throw new Error(
38 | `You specified ${chalk.cyan(
39 | type
40 | )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41 | );
42 | }
43 | return fs.readFileSync(file);
44 | }
45 |
46 | // Get the https config
47 | // Return cert files if provided in env, otherwise just true or false
48 | function getHttpsConfig() {
49 | const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50 | const isHttps = HTTPS === 'true';
51 |
52 | if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53 | const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54 | const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55 | const config = {
56 | cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57 | key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58 | };
59 |
60 | validateKeyAndCerts({ ...config, keyFile, crtFile });
61 | return config;
62 | }
63 | return isHttps;
64 | }
65 |
66 | module.exports = getHttpsConfig;
67 |
--------------------------------------------------------------------------------
/front/config/jest/cssTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // This is a custom Jest transformer turning style imports into empty objects.
4 | // http://facebook.github.io/jest/docs/en/webpack.html
5 |
6 | module.exports = {
7 | process() {
8 | return 'module.exports = {};';
9 | },
10 | getCacheKey() {
11 | // The output is always the same.
12 | return 'cssTransform';
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/front/config/jest/fileTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const camelcase = require('camelcase');
5 |
6 | // This is a custom Jest transformer turning file imports into filenames.
7 | // http://facebook.github.io/jest/docs/en/webpack.html
8 |
9 | module.exports = {
10 | process(src, filename) {
11 | const assetFilename = JSON.stringify(path.basename(filename));
12 |
13 | if (filename.match(/\.svg$/)) {
14 | // Based on how SVGR generates a component name:
15 | // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16 | const pascalCaseFilename = camelcase(path.parse(filename).name, {
17 | pascalCase: true,
18 | });
19 | const componentName = `Svg${pascalCaseFilename}`;
20 | return `const React = require('react');
21 | module.exports = {
22 | __esModule: true,
23 | default: ${assetFilename},
24 | ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25 | return {
26 | $$typeof: Symbol.for('react.element'),
27 | type: 'svg',
28 | ref: ref,
29 | key: null,
30 | props: Object.assign({}, props, {
31 | children: ${assetFilename}
32 | })
33 | };
34 | }),
35 | };`;
36 | }
37 |
38 | return `module.exports = ${assetFilename};`;
39 | },
40 | };
41 |
--------------------------------------------------------------------------------
/front/config/modules.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const paths = require('./paths');
6 | const chalk = require('react-dev-utils/chalk');
7 | const resolve = require('resolve');
8 |
9 | /**
10 | * Get additional module paths based on the baseUrl of a compilerOptions object.
11 | *
12 | * @param {Object} options
13 | */
14 | function getAdditionalModulePaths(options = {}) {
15 | const baseUrl = options.baseUrl;
16 |
17 | if (!baseUrl) {
18 | return '';
19 | }
20 |
21 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
22 |
23 | // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
24 | // the default behavior.
25 | if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
26 | return null;
27 | }
28 |
29 | // Allow the user set the `baseUrl` to `appSrc`.
30 | if (path.relative(paths.appSrc, baseUrlResolved) === '') {
31 | return [paths.appSrc];
32 | }
33 |
34 | // If the path is equal to the root directory we ignore it here.
35 | // We don't want to allow importing from the root directly as source files are
36 | // not transpiled outside of `src`. We do allow importing them with the
37 | // absolute path (e.g. `src/Components/Button.js`) but we set that up with
38 | // an alias.
39 | if (path.relative(paths.appPath, baseUrlResolved) === '') {
40 | return null;
41 | }
42 |
43 | // Otherwise, throw an error.
44 | throw new Error(
45 | chalk.red.bold(
46 | "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
47 | ' Create React App does not support other values at this time.'
48 | )
49 | );
50 | }
51 |
52 | /**
53 | * Get webpack aliases based on the baseUrl of a compilerOptions object.
54 | *
55 | * @param {*} options
56 | */
57 | function getWebpackAliases(options = {}) {
58 | const baseUrl = options.baseUrl;
59 |
60 | if (!baseUrl) {
61 | return {};
62 | }
63 |
64 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
65 |
66 | if (path.relative(paths.appPath, baseUrlResolved) === '') {
67 | return {
68 | src: paths.appSrc,
69 | };
70 | }
71 | }
72 |
73 | /**
74 | * Get jest aliases based on the baseUrl of a compilerOptions object.
75 | *
76 | * @param {*} options
77 | */
78 | function getJestAliases(options = {}) {
79 | const baseUrl = options.baseUrl;
80 |
81 | if (!baseUrl) {
82 | return {};
83 | }
84 |
85 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
86 |
87 | if (path.relative(paths.appPath, baseUrlResolved) === '') {
88 | return {
89 | '^src/(.*)$': '/src/$1',
90 | };
91 | }
92 | }
93 |
94 | function getModules() {
95 | // Check if TypeScript is setup
96 | const hasTsConfig = fs.existsSync(paths.appTsConfig);
97 | const hasJsConfig = fs.existsSync(paths.appJsConfig);
98 |
99 | if (hasTsConfig && hasJsConfig) {
100 | throw new Error(
101 | 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
102 | );
103 | }
104 |
105 | let config;
106 |
107 | // If there's a tsconfig.json we assume it's a
108 | // TypeScript project and set up the config
109 | // based on tsconfig.json
110 | if (hasTsConfig) {
111 | const ts = require(resolve.sync('typescript', {
112 | basedir: paths.appNodeModules,
113 | }));
114 | config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
115 | // Otherwise we'll check if there is jsconfig.json
116 | // for non TS projects.
117 | } else if (hasJsConfig) {
118 | config = require(paths.appJsConfig);
119 | }
120 |
121 | config = config || {};
122 | const options = config.compilerOptions || {};
123 |
124 | const additionalModulePaths = getAdditionalModulePaths(options);
125 |
126 | return {
127 | additionalModulePaths: additionalModulePaths,
128 | webpackAliases: getWebpackAliases(options),
129 | jestAliases: getJestAliases(options),
130 | hasTsConfig,
131 | };
132 | }
133 |
134 | module.exports = getModules();
135 |
--------------------------------------------------------------------------------
/front/config/paths.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
6 |
7 | // Make sure any symlinks in the project folder are resolved:
8 | // https://github.com/facebook/create-react-app/issues/637
9 | const appDirectory = fs.realpathSync(process.cwd());
10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
11 |
12 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
13 | // "public path" at which the app is served.
14 | // webpack needs to know it to put the right