Skip to content

Commit e6cd3f7

Browse files
authored
Merge pull request #3 from iolave/staging
More lxc features
2 parents 1b460c2 + 027f59a commit e6cd3f7

29 files changed

+1696
-233
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ bin
66
cover*
77
site/
88
docs/go-client/pkg/*
9+
docs/**/swag*
10+
docs/**/docs.go

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
## [v0.6.0]
11+
### PVE API wrapper
12+
#### Added
13+
- `GET /custom-api/v1/lxc/{id}/ip` endpoint.
14+
- `POST /custom-api/v1/lxc/{id}/exec` endpoint.
15+
16+
#### Fixed
17+
- pve api wrapper host option is now `--host`.
18+
- pve api wrapper port option is now `--port`.
19+
20+
### PVE API client
21+
#### Added
22+
- `GET /access/permissions` implementation as `PVE.Access.GetPermissions`.
23+
- `GET /cluster/resources` implementation as `PVE.Cluster.GetVMIDs`, `PVE.Cluster.GetRandomVMID` and `PVE.Cluster.IsVMIDAvailable`.
24+
- `GET /nodes/{node}/firewall/rules` implementation as `PVE.Node.Firewall.GetRule`.
25+
- `POST /nodes/{node}/firewall/rules` implementation as `PVE.Node.Firewall.NewRule`.
26+
- `DELETE /nodes/{node}/firewall/rules/{pos}` implementation as `PVE.Node.Firewall.DeleteRule` and `PVE.Node.Firewall.DeleteRuleByPos`.
27+
- `GET /nodes/{node}/lxc/{id}/interfaces` implementation as `PVE.LXC.GetInterfaces` and `PVE.LXC.GetInterface` .
28+
- `GET /nodes/{node}/lxc/{id}/status/current` implementation as `PVE.LXC.GetStatus`.
29+
- `POST /nodes/{node}/lxc/{id}/status/reboot` implementation as `PVE.LXC.Reboot`.
30+
- `POST /nodes/{node}/lxc/{id}/status/resume` implementation as `PVE.LXC.Resume`.
31+
- `POST /nodes/{node}/lxc/{id}/status/shutdown` implementation as `PVE.LXC.Shutdown`.
32+
- `POST /nodes/{node}/lxc/{id}/status/start` implementation as `PVE.LXC.Start`.
33+
- `POST /nodes/{node}/lxc/{id}/status/stop` implementation as `PVE.LXC.Stop`.
34+
- `POST /custom-api/v1/lxc/{id}/exec` implementation as `PVE.LXC.Exec`.
35+
36+
#### Fixed
37+
- `PVE.LXC.Create` hostname assignment.
38+
- `PVE.LXC.Create` net assignment.
39+
- `PVE.LXC.Create` multiple networks support.
40+
41+
#### Changed
42+
- `PVE.LXC.Create` request's `Features` property is now a struct.
43+
1044
## [v0.5.0]
1145
### PVE API wrapper
1246
#### Added
@@ -83,7 +117,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
83117
- Proxmox api token credentials support.
84118
- Proxmox api version endpoint.
85119

86-
[unreleased]: https://github.com/iolave/go-proxmox/compare/v0.5.0...HEAD
120+
[unreleased]: https://github.com/iolave/go-proxmox/compare/v0.6.0...staging
121+
[v0.6.0]: https://github.com/iolave/go-proxmox/releases/tag/v0.6.0
122+
[v0.5.1]: https://github.com/iolave/go-proxmox/releases/tag/v0.5.1
87123
[v0.5.0]: https://github.com/iolave/go-proxmox/releases/tag/v0.5.0
88124
[v0.4.0]: https://github.com/iolave/go-proxmox/releases/tag/v0.4.0
89125
[v0.3.0]: https://github.com/iolave/go-proxmox/releases/tag/v0.3.0

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ install-go-test-coverage:
88
install-docs-dependencies:
99
./scripts/install-docs-deps.sh
1010

11+
install-dependencies: install-docs-dependencies
12+
go mod tidy
13+
14+
1115
.PHONY: coverage-check
1216
coverage-check: install-go-test-coverage
1317
go test -v ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
@@ -22,17 +26,12 @@ coverage:
2226
; exit $$rc
2327

2428
generate-docs: install-docs-dependencies
25-
source /tmp/venv/go-proxmox/bin/activate; \
26-
rm -rf ./docs/go-client/pkg; \
27-
mkdir -p ./docs/go-client/pkg/; \
28-
go run ./cmd/gomarkdoc/main.go; \
29-
mkdocs build
29+
bash ./scripts/generate-docs.sh
3030

31-
preview-docs: install-docs-dependencies
32-
source /tmp/venv/go-proxmox/bin/activate; \
33-
mkdocs serve
31+
preview-docs: install-docs-dependencies generate-docs
32+
bash ./scripts/preview-docs.sh
3433

35-
build:
34+
build: install-dependencies
3635
$(eval $@GOOS = linux)
3736
$(eval $@GOARCH = amd64)
3837
GOOS=$($@GOOS) GOARCH=$($@GOARCH) go build -o "bin/pve-api-wrapper-$($@GOOS)-$($@GOARCH)" ./cmd/pve_api_wrapper/pve_api_wrapper.go

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# GO Proxmox
2-
Proxmox CLI for remote management and go api client
1+
# go-proxmox
32

43
> [!WARNING]
54
> All versions released prior to `v1.0.0` are to be considered [breaking changes](https://semver.org/#how-do-i-know-when-to-release-100)

cmd/pve_api_wrapper/pve_api_wrapper.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,23 @@ import (
66
"os"
77

88
"github.com/alexflint/go-arg"
9+
_ "github.com/iolave/go-proxmox/docs/api-wrapper"
910
"github.com/iolave/go-proxmox/internal/server"
1011
)
1112

13+
// @title Proxmox API Wrapper
14+
// @version 1.0
15+
// @description Proxmox api wrapper that provides custom features.
16+
//
17+
// @contact.name Ignacio Olave
18+
// @contact.url http://www.github.com/iolave/go-proxmox/issues
19+
// @contact.email contact@iolave.com
20+
// @license.name Apache 2.0
21+
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
22+
// @host localhost:8443
23+
// @BasePath /custom-api/v1
24+
// @externalDocs.description go-promox docs
25+
// @externalDocs.url https://go-proxmox.iolave.com
1226
func main() {
1327
var app server.App
1428

docs/api-wrapper.md renamed to docs/api-wrapper/index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
The pve api wrapper is an http server ment to be installed on the proxmox host server () that wraps the proxmox api and adds missing features to it.
1+
The pve api wrapper is an http server ment to be installed on the proxmox host server that wraps the proxmox api and adds missing features to it.
22

3-
_pve-api-wrapper can definitely be installed somewhere else but some functionalities might not work._
3+
4+
> [!NOTE]
5+
> pve-api-wrapper can definitely be installed somewhere else by pointing to the corresponding pve host & port, but some functionalities might not work.
46
57
## Features
68
- Proper error responses on failed requests,
7-
- lxc exec command endpoint (not available yet).
9+
- custom endpoints (for a full list see the [reference])
810

911
## Installation
1012
### Latest release
1113
The installation script installs the `pve-api-wrapper` binary into `/usr/local/bin`.
1214

1315
```bash
14-
curl https://raw.githubusercontent.com/iolave/go-proxmox/refs/heads/master/scripts/install.sh | bash
16+
curl https://raw.githubusercontent.com/iolave/go-proxmox/refs/tags/latest/scripts/install.sh | bash
1517
```
1618

1719
_Inspect the installation script code [here]._
@@ -29,7 +31,7 @@ make build
2931

3032
## Usage
3133
```bash
32-
pve-api-wrapper [--version] [--pve-host PVE-HOST] [--pve-port PVE-PORT] [--pve-host PVE-HOST] [--pve-port PVE-PORT] [--crt CRT] [--key KEY]
34+
pve-api-wrapper [--version] [--pve-host PVE-HOST] [--pve-port PVE-PORT] [--host HOST] [--port PORT] [--crt CRT] [--key KEY]
3335
```
3436
### Options
3537
- `--version` displays the program version.
@@ -40,7 +42,8 @@ pve-api-wrapper [--version] [--pve-host PVE-HOST] [--pve-port PVE-PORT] [--pve-h
4042
- `--crt` api wrapper tls crt path (default:`/etc/pve/local/pve-ssl.pem`).
4143
- `--key` api wrapper tls key path (default:`/etc/pve/local/pve-ssl.key`).
4244

43-
[here]: https://github.com/iolave/go-proxmox/blob/master/scripts/install.sh
45+
[here]: https://github.com/iolave/go-proxmox/blob/latest/scripts/install.sh
46+
[reference]: https://go-proxmox.iolave.com/api-wrapper/reference/
4447
<!--
4548
TODO: host the shell script within the docs https://github.com/squidfunk/mkdocs-material/discussions/3458
4649
-->

docs/api-wrapper/reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Reference
2+
!!swagger swagger.json!!

docs/go-client/implemented-endpoints.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This is a development-purposed list to keep track of the implemented proxmox [en
1616
|-------------------------------------------------------------|:------------------:|:--------------:|:-----:|:-:|
1717
| `/access/acl` |:material-close:||:material-close:|
1818
| `/access/password` |||:material-close:|
19-
| `/access/permissions` |:material-close:|
19+
| `/access/permissions` |:material-check-all:|
2020
| `/access/ticket` |:material-close:|:material-close:|
2121

2222
### Users
@@ -69,7 +69,7 @@ This is a development-purposed list to keep track of the implemented proxmox [en
6969
| `/cluster/log` |:material-close:|
7070
| `/cluster/nextid` |:material-check-all:|
7171
| `/cluster/options` |:material-close:||:material-close:|
72-
| `/cluster/resources` |:material-close:|
72+
| `/cluster/resources` |:material-check:|
7373
| `/cluster/status` |:material-close:|
7474
| `/cluster/tasks` |:material-close:|
7575

@@ -340,8 +340,8 @@ This is a development-purposed list to keep track of the implemented proxmox [en
340340
| Path | GET | POST | PUT | DELETE |
341341
|-------------------------------------------------------------|:------------------:|:--------------:|:-----:|:-:|
342342
| `/nodes/:node/firewall` |:material-close:|
343-
| `/nodes/:node/firewall/rules` |:material-check-all:|:material-close:|
344-
| `/nodes/:node/firewall/rules/:pos` |:material-check-all:||:material-close:|:material-close:|
343+
| `/nodes/:node/firewall/rules` |:material-check-all:|:material-check-all:|
344+
| `/nodes/:node/firewall/rules/:pos` |:material-check-all:||:material-close:|:material-check:|
345345
| `/nodes/:node/firewall/log` |:material-check:|
346346
| `/nodes/:node/firewall/options` |:material-close:||:material-close:|
347347

@@ -374,17 +374,17 @@ This is a development-purposed list to keep track of the implemented proxmox [en
374374
| `/nodes/:node/lxc/:vmid/snapshot/:name/config` |:material-close:||:material-close:|
375375
| `/nodes/:node/lxc/:vmid/snapshot/:name/rollback` ||:material-close:|
376376
| `/nodes/:node/lxc/:vmid/status` |:material-close:|
377-
| `/nodes/:node/lxc/:vmid/status/current` |:material-close:|
378-
| `/nodes/:node/lxc/:vmid/status/reboot` ||:material-close:|
379-
| `/nodes/:node/lxc/:vmid/status/resume` ||:material-close:|
380-
| `/nodes/:node/lxc/:vmid/status/shutdown` ||:material-close:|
381-
| `/nodes/:node/lxc/:vmid/status/start` ||:material-close:|
382-
| `/nodes/:node/lxc/:vmid/status/stop` ||:material-close:|
383-
| `/nodes/:node/lxc/:vmid/status/suspend` ||:material-close:|
377+
| `/nodes/:node/lxc/:vmid/status/current` |:material-check-all:|
378+
| `/nodes/:node/lxc/:vmid/status/reboot` ||:material-check-all:|
379+
| `/nodes/:node/lxc/:vmid/status/resume` ||:material-check-all:|
380+
| `/nodes/:check-all/lxc/:vmid/status/shutdown` ||:material-check-all:|
381+
| `/nodes/:node/lxc/:vmid/status/start` ||:material-check-all:|
382+
| `/nodes/:check-all/lxc/:vmid/status/stop` ||:material-check-all:|
383+
| `/nodes/:node/lxc/:vmid/status/suspend` ||:material-check-all:|
384384
| `/nodes/:node/lxc/:vmid/clone` ||:material-close:|
385385
| `/nodes/:node/lxc/:vmid/config` |:material-close:||:material-close:|
386386
| `/nodes/:node/lxc/:vmid/feature` |:material-close:|
387-
| `/nodes/:node/lxc/:vmid/interfaces` |:material-close:|
387+
| `/nodes/:node/lxc/:vmid/interfaces` |:material-check-all:|
388388
| `/nodes/:node/lxc/:vmid/migrate` ||:material-close:|
389389
| `/nodes/:node/lxc/:vmid/move_volume` ||:material-close:|
390390
| `/nodes/:node/lxc/:vmid/mtunnel` ||:material-close:|

go.mod

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,37 @@ go 1.22.2
44

55
require (
66
github.com/alexflint/go-arg v1.5.1
7+
github.com/ggicci/httpin v0.19.0
8+
github.com/google/uuid v1.6.0
79
github.com/princjef/gomarkdoc v1.1.0
10+
github.com/swaggo/swag v1.16.4
811
)
912

1013
require (
14+
github.com/KyleBanks/depth v1.2.1 // indirect
1115
github.com/Microsoft/go-winio v0.5.0 // indirect
16+
github.com/PuerkitoBio/purell v1.1.1 // indirect
17+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
1218
github.com/VividCortex/ewma v1.2.0 // indirect
1319
github.com/alexflint/go-scalar v1.2.0 // indirect
1420
github.com/cheggaaa/pb/v3 v3.0.8 // indirect
1521
github.com/emirpasic/gods v1.12.0 // indirect
1622
github.com/fatih/color v1.11.0 // indirect
23+
github.com/ggicci/owl v0.8.2 // indirect
1724
github.com/go-git/gcfg v1.5.0 // indirect
1825
github.com/go-git/go-billy/v5 v5.3.1 // indirect
1926
github.com/go-git/go-git/v5 v5.3.0 // indirect
27+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
28+
github.com/go-openapi/jsonreference v0.19.6 // indirect
29+
github.com/go-openapi/spec v0.20.4 // indirect
30+
github.com/go-openapi/swag v0.19.15 // indirect
2031
github.com/imdario/mergo v0.3.12 // indirect
2132
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
33+
github.com/josharian/intern v1.0.0 // indirect
2234
github.com/kevinburke/ssh_config v1.1.0 // indirect
23-
github.com/mattn/go-colorable v0.1.8 // indirect
24-
github.com/mattn/go-isatty v0.0.12 // indirect
35+
github.com/mailru/easyjson v0.7.6 // indirect
36+
github.com/mattn/go-colorable v0.1.13 // indirect
37+
github.com/mattn/go-isatty v0.0.20 // indirect
2538
github.com/mattn/go-runewidth v0.0.12 // indirect
2639
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
2740
github.com/mitchellh/go-homedir v1.1.0 // indirect
@@ -33,11 +46,14 @@ require (
3346
github.com/sirupsen/logrus v1.8.1 // indirect
3447
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
3548
github.com/xanzy/ssh-agent v0.3.0 // indirect
36-
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
37-
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
38-
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
39-
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
49+
golang.org/x/crypto v0.22.0 // indirect
50+
golang.org/x/net v0.24.0 // indirect
51+
golang.org/x/sys v0.19.0 // indirect
52+
golang.org/x/term v0.19.0 // indirect
53+
golang.org/x/text v0.14.0 // indirect
54+
golang.org/x/tools v0.7.0 // indirect
4055
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
4156
gopkg.in/warnings.v0 v0.1.2 // indirect
57+
gopkg.in/yaml.v2 v2.4.0 // indirect
4258
mvdan.cc/xurls/v2 v2.2.0 // indirect
4359
)

0 commit comments

Comments
 (0)