|
5 | 5 | `upctl` provides a command-line interface to [UpCloud](https://upcloud.com/) services. It allows you |
6 | 6 | to control your resources from the command line or any compatible interface. |
7 | 7 |
|
8 | | -```txt |
9 | | -UpCloud command-line interface |
10 | | -
|
11 | | -`upctl` provides a command-line interface to UpCloud services. It allows you to |
12 | | -control your resources from the command line or any compatible interface. |
13 | | -
|
14 | | -To be able to manage your UpCloud resources, you need to configure credentials |
15 | | -for `upctl` and enable API access for these credentials. Define the credentials |
16 | | -by setting `UPCLOUD_USERNAME` and `UPCLOUD_PASSWORD` environment variables. API |
17 | | -access can be configured on the Account page of the UpCloud Hub. We recommend |
18 | | -you to set up a sub-account specifically for the API usage with its own username |
19 | | -and password, as it allows you to assign specific permissions for increased |
20 | | -security. |
21 | | -
|
22 | | -Usage: |
23 | | -upctl [command] |
24 | | -
|
25 | | -Available Commands: |
26 | | -account Manage accounts |
27 | | -completion Generate the autocompletion script for the specified shell |
28 | | -database Manage databases |
29 | | -help Help about any command |
30 | | -ip-address Manage IP addresses |
31 | | -kubernetes Manage Kubernetes clusters |
32 | | -loadbalancer Manage load balancers |
33 | | -network Manage networks |
34 | | -router Manage routers |
35 | | -server Manage servers |
36 | | -servergroup Manage server groups |
37 | | -storage Manage storages |
38 | | -version Display software information |
39 | | -zone Display zone information |
40 | | -
|
41 | | -Options: |
42 | | - -t, --client-timeout duration Client timeout to use in API calls. |
43 | | - Default: 0s |
44 | | -
|
45 | | - --config string Configuration file path. |
46 | | -
|
47 | | - --debug bool Print out more verbose debug logs. |
48 | | - Default: false |
49 | | -
|
50 | | - --force-colours Force coloured output despite detected terminal support. |
51 | | -
|
52 | | - --no-colours Disable coloured output despite detected terminal support. Colours can also be disabled by setting |
53 | | - NO_COLOR environment variable. |
54 | | -
|
55 | | - -o, --output string Output format (supported: json, yaml and human) |
56 | | - Default: human |
57 | | -
|
58 | | -Use "upctl [command] --help" for more information about a command. |
59 | | -``` |
60 | | - |
61 | | -## Installation |
62 | | - |
63 | | -Install the latest with Go by running: |
64 | | - |
65 | | -```bash |
66 | | -go install github.com/UpCloudLtd/upcloud-cli/v3/...@latest |
67 | | -``` |
68 | | - |
69 | | -To use upctl as a binary, download it from the |
70 | | -[Releases](https://github.com/UpCloudLtd/upcloud-cli/releases) page. After downloading, verify that the client works. |
71 | | - |
72 | | -### macOS |
73 | | - |
74 | | -```bash |
75 | | -brew tap UpCloudLtd/tap |
76 | | -brew install upcloud-cli |
77 | | -upctl -h |
78 | | -``` |
79 | | - |
80 | | -Setting up bash completion requires a few commands more. |
| 8 | +## Getting started |
81 | 9 |
|
82 | | -First, install `bash-completion`, if it is not installed already. |
| 10 | +For instructions on how to install `upctl`, configure credentials, and run commands, see [Getting started](https://upcloudltd.github.io/upcloud-cli/) instructions in the documentation. |
83 | 11 |
|
84 | | -```bash |
85 | | -brew install bash-completion |
86 | | -echo '[ -f "$(brew --prefix)/etc/bash_completion" ] && . "$(brew --prefix)/etc/bash_completion"' >> ~/.bash_profile |
87 | | -``` |
| 12 | +## Install with go install |
88 | 13 |
|
89 | | -Then configure the shell completions for `upctl` by saving the output of `upctl completion bash` in `upctl` file under `/etc/bash_completion.d/`: |
| 14 | +Install the latest version of `upctl` with `go install` by running: |
90 | 15 |
|
91 | | -```bash |
92 | | -upctl completion bash > $(brew --prefix)/etc/bash_completion.d/upctl |
93 | | -. $(brew --prefix)/etc/bash_completion |
94 | | -``` |
95 | | - |
96 | | -### Linux |
97 | | - |
98 | | -#### AUR |
99 | | -``` |
100 | | -yay -S upcloud-cli |
101 | | -``` |
102 | | - |
103 | | -#### Other Linux distros |
104 | | - |
105 | | -Use the package corresponding to your distro (deb, rpm, apk) from the [releases page](https://github.com/UpCloudLtd/upcloud-cli/releases), example for Debian like: |
106 | | - |
107 | | -```bash |
108 | | -# Replace <VERSION> with the version you want to install |
109 | | -curl -Lo upcloud-cli.deb https://github.com/UpCloudLtd/upcloud-cli/releases/download/v<VERSION>/upcloud-cli-<VERSION>_amd64.deb |
110 | | -sudo dpkg -i upcloud-cli.deb |
111 | | -upctl -h |
112 | | -``` |
113 | | - |
114 | | -Bash completion can also be set up with some extra commands. You should adapt this for your package manager. |
115 | | - |
116 | | -First, install `bash-completion`, if it is not installed already. |
117 | | - |
118 | | -```bash |
119 | | -sudo apt install bash-completion |
120 | | -echo "[ -f /etc/bash_completion ] && . /etc/bash_completion" >> ~/.bashrc |
121 | | -``` |
122 | | - |
123 | | -Then configure the shell completions for `upctl` by either sourcing `upctl completion bash` output in your bash `.bashrc` or by saving the output of that command in `upctl` file under `/etc/bash_completion.d/`: |
124 | | - |
125 | | -```bash |
126 | | -# First alternative |
127 | | -echo 'source <(upctl completion bash)' >>~/.bashrc |
128 | | - |
129 | | -# Second alternative |
130 | | -upctl completion bash | sudo tee /etc/bash_completion.d/upctl > /dev/null |
131 | | -. /etc/bash_completion |
132 | | -``` |
133 | | - |
134 | | -### Windows |
135 | | -```bash |
136 | | -Invoke-WebRequest -Uri "https://github.com/UpCloudLtd/upcloud-cli/releases/download/v<VERSION>/upcloud-cli-<VERSION>_windows_x86_64.zip" -OutFile "upcloud-cli.zip" |
137 | | -Expand-Archive -Path upcloud-cli.zip -Destination 'C:\Program Files\Upcloud CLI' |
138 | | -[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Upcloud CLI", [System.EnvironmentVariableTarget]::Machine) |
139 | | -upctl.exe -h |
140 | | -``` |
141 | | - |
142 | | -## Quick Start |
143 | | - |
144 | | -Create a `upctl.yaml` config file with user credentials into your home |
145 | | -directory's .config dir ($HOME/.config/upctl.yaml). |
146 | | - |
147 | | -```yaml |
148 | | -username: your_upcloud_username |
149 | | -password: your_upcloud_password |
| 16 | +```sh |
| 17 | +go install github.com/UpCloudLtd/upcloud-cli/v3/...@latest |
150 | 18 | ``` |
151 | 19 |
|
152 | | -Credentials can also be stored at environment variables `UPCLOUD_USERNAME` and `UPCLOUD_PASSWORD`. If variables |
153 | | -are set, matching config file items are ignored. |
154 | | - |
155 | | -> NOTE: Make sure your account allows API connections. To do so, log into |
156 | | -> [UpCloud control panel](https://hub.upcloud.com/login) and go to **Account** |
157 | | -> -> **Permissions** -> **Allow API connections** checkbox. |
| 20 | +Run `upctl version` to verify that the tool was installed successfully and `upctl help` to print usage instructions. |
158 | 21 |
|
159 | | -Run something to test that the credentials are working. |
160 | | - |
161 | | -```bash |
162 | | -$ upctl server list |
163 | | - UUID Hostname Plan Zone State |
164 | | -────────────────────────────────────── ──────────────────── ─────────── ───────── ───────── |
165 | | - 00229ddf-0e46-45b5-a8f7-cad2c8d11f6a server1 2xCPU-4GB de-fra1 stopped |
166 | | - 003c9d77-0237-4ee7-b3a1-306efba456dc server2 1xCPU-2GB sg-sin1 started |
| 22 | +```sh |
| 23 | +upctl version |
| 24 | +upctl help |
167 | 25 | ``` |
168 | 26 |
|
169 | 27 | ## Exit codes |
@@ -214,24 +72,15 @@ If something is missing from there, add an issue or PR in that repository instea |
214 | 72 |
|
215 | 73 | ## Development |
216 | 74 |
|
217 | | -* upctl uses [UpCloud Go API SDK](https://github.com/UpCloudLtd/upcloud-go-api) |
218 | | -* upctl is built on [Cobra](https://cobra.dev) |
| 75 | +* `upctl` uses [UpCloud Go API SDK](https://github.com/UpCloudLtd/upcloud-go-api) |
| 76 | +* `upctl` is built on [Cobra](https://cobra.dev) |
219 | 77 |
|
220 | | -You need a Go version 1.18+ installed on your development machine. |
221 | | -Use `make` to build and test the CLI. Makefile help can be found: |
| 78 | +You need a Go version 1.20+ installed on your development machine. |
222 | 79 |
|
223 | | -``` |
224 | | -$ make help |
225 | | -build Build program binary for current os/arch |
226 | | -doc Generate documentation (markdown) |
227 | | -build-all Build all targets |
228 | | -build-linux Build program binary for linux x86_64 |
229 | | -build-darwin Build program binary for darwin x86_64 |
230 | | -build-windows Build program binary for windows x86_64 |
231 | | -build-freebsd Build program binary for freebsd x86_64 |
232 | | -test Run tests |
233 | | -fmt Run gofmt on all source files |
234 | | -clean Cleanup everything |
| 80 | +Use `make` to build and test the CLI. Makefile help can be found by running `make help`. |
| 81 | + |
| 82 | +```sh |
| 83 | +make help |
235 | 84 | ``` |
236 | 85 |
|
237 | 86 | ### Debugging |
|
0 commit comments