Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6ed7d36
chore: removed unused files
iolave Aug 11, 2025
54eaa27
chore: simplified docs generation
iolave Aug 11, 2025
cf5d068
docs: renamed install script to install-paw
iolave Aug 11, 2025
2db8bd1
chore: make build doesn't have any deps now
iolave Aug 11, 2025
ad1d9ad
refactor: moved api wrapper code into it's own internal dir
iolave Aug 11, 2025
5847cc6
refactor: added new core service and new http client
iolave Aug 11, 2025
fad8084
refactor: renamed PVE struct to Client
iolave Aug 11, 2025
d93dbfe
refactor: new api implementation now uses github.com/iolave/go-errors…
iolave Aug 12, 2025
9f2e87d
api client will now contain raw pve requests
iolave Aug 13, 2025
c17c6fc
chore: removed unused type def
iolave Aug 13, 2025
21c9a68
fix: api wrapper request to pve api now passthrough query params
iolave Aug 17, 2025
b25effb
refactor: internal api_client is now can be used importing /pkg/api
iolave Aug 18, 2025
5de38d6
feat: added /api2/json/cluster/tasks implementations
iolave Aug 18, 2025
d08a1a8
feat: added /api2/json/cluster/options implementations
iolave Aug 18, 2025
97b5edc
feat: added /api2/json/cluster/resources implementations
iolave Aug 18, 2025
329c078
feat: added /api2/json/cluster/status implementations
iolave Aug 18, 2025
a3314c5
feat: added /api2/json/cluster/nextid implementations
iolave Aug 18, 2025
e796e0b
feat: added /api2/json/cluster/log implementations
iolave Aug 18, 2025
3a8003b
docs: added missing cluster implementations docs
iolave Aug 18, 2025
1fd11f0
docs: added missing cluster required permissions
iolave Aug 19, 2025
832e0cf
feat: added /api2/json/cluster/acme implementations
iolave Aug 19, 2025
8f2af41
fix: requests with int props are now pointers
iolave Aug 20, 2025
0126bec
feat: added /api2/json/cluster/backup implementations
iolave Aug 20, 2025
7cb3e0b
feat: added /api2/json/cluster/backup-info implementations
iolave Aug 20, 2025
52b6805
feat: added /api2/json/cluster/ceph implementations
iolave Aug 20, 2025
d1b3987
feat: added /api2/json/cluster/config implementations
iolave Aug 20, 2025
b235f30
refactor: api cluster/* and cluster/acme/* root methods were condense…
iolave Aug 21, 2025
dc870c5
feat: added /api2/json/cluster/firewall implementations
iolave Aug 24, 2025
1e27f29
fix: update group rule method doesnt fails anymore when type is not s…
iolave Aug 26, 2025
0cad193
feat: added /api2/json/cluster/ha implementations
iolave Aug 26, 2025
096dab5
chore: added missing mkdocs pip dependency
iolave Aug 26, 2025
0d9f862
feat: added /api2/json/cluster/jobs implementations
iolave Aug 26, 2025
2f93558
feat: added /api2/json/cluster/mapping implementations
iolave Aug 27, 2025
b76222e
feat: added /api2/json/cluster/metrics implementations
iolave Sep 1, 2025
000716c
feat: added /api2/json/cluster/notifications implementations
iolave Sep 27, 2025
49794c4
feat: added /api2/json/cluster/notifications/endpoints implementations
iolave Sep 27, 2025
4961e93
feat: added /api2/json/cluster/replication implementations
iolave Oct 27, 2025
ded829a
rename
iolave Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install docs dependencies
run: make install-docs-dependencies
- name: Generate docs
run: make generate-docs
run: make docs
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
Expand Down
50 changes: 0 additions & 50 deletions .testcoverage.yml

This file was deleted.

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### PVE API wrapper

#### Fixed
- PVE original passthrough handler now properly includes the request query params (resolves [#4](https://github.com/iolave/go-proxmox/issues/4)).

### PVE API client
#### Added
- Added a Core Service to the client:
- Implements `GET /api2/json/version` as `GetVersion`.

#### Changed
- Renamed `pve.PVE` to `pve.Client`.

#### Removed
- Removed client `GetVersion` method.


## [v0.7.1]
### PVE API client
Expand Down
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
GOBIN ?= $$(go env GOPATH)/bin

.PHONY: install-docs-dependencies
install-docs-dependencies:
./scripts/install-docs-deps.sh

.phony: install-dependencies
install-dependencies: install-docs-dependencies
go mod tidy

.PHONY: test
test:
go test -v ./...
Expand All @@ -16,16 +8,16 @@ test:
coverage:
./scripts/coverage.sh

.PHONY: generate-docs
generate-docs: install-docs-dependencies
bash ./scripts/generate-docs.sh
.PHONY: docs
docs:
./scripts/generate-docs.sh

.PHONY: preview-docs
preview-docs: install-docs-dependencies generate-docs
bash ./scripts/preview-docs.sh
preview-docs:
./scripts/generate-docs.sh -p

.PHONY: build
build: install-dependencies
build:
$(eval $@GOOS = linux)
$(eval $@GOARCH = amd64)
CGO_ENABLED=0 GOOS=$($@GOOS) GOARCH=$($@GOARCH) go build -ldflags="-extldflags=-static" -o "bin/pve-api-wrapper-$($@GOOS)-$($@GOARCH)" ./cmd/pve_api_wrapper/pve_api_wrapper.go
Expand Down
2 changes: 1 addition & 1 deletion cmd/pve_api_wrapper/pve_api_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/alexflint/go-arg"
_ "github.com/iolave/go-proxmox/docs/api-wrapper"
"github.com/iolave/go-proxmox/internal/server"
"github.com/iolave/go-proxmox/internal/api_wrapper/server"
)

// @title Proxmox API Wrapper
Expand Down
6 changes: 3 additions & 3 deletions docs/api-wrapper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ The pve api wrapper is an http server ment to be installed on the proxmox host s

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

```bash
curl https://raw.githubusercontent.com/iolave/go-proxmox/refs/tags/latest/scripts/install.sh | bash
curl https://raw.githubusercontent.com/iolave/go-proxmox/refs/tags/latest/scripts/install-paw.sh | bash
```

_Inspect the installation script code [here]._
Expand Down Expand Up @@ -51,7 +51,7 @@ pve-api-wrapper [--version] [--pve-host PVE-HOST] [--pve-port PVE-PORT] [--host
sudo pve-api-wrapper service install
```

[here]: https://github.com/iolave/go-proxmox/blob/latest/scripts/install.sh
[here]: https://github.com/iolave/go-proxmox/blob/latest/scripts/install-paw.sh
[reference]: https://go-proxmox.iolave.com/api-wrapper/reference/
<!--
TODO: host the shell script within the docs https://github.com/squidfunk/mkdocs-material/discussions/3458
Expand Down
19 changes: 14 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module github.com/iolave/go-proxmox

go 1.22.2
go 1.24.4

toolchain go1.24.6

require (
github.com/alexflint/go-arg v1.5.1
github.com/ggicci/httpin v0.19.0
github.com/go-playground/validator/v10 v10.27.0
github.com/google/uuid v1.6.0
github.com/iolave/go-errors v1.0.0
github.com/princjef/gomarkdoc v1.1.0
github.com/swaggo/swag v1.16.4
modernc.org/sqlite v1.36.0
Expand All @@ -22,6 +26,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.11.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/ggicci/owl v0.8.2 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
Expand All @@ -30,10 +35,13 @@ require (
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.1.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -48,14 +56,15 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/theothertomelliott/acyclic v0.0.1 // indirect
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
36 changes: 26 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ github.com/fatih/color v1.11.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGE
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/ggicci/httpin v0.19.0 h1:p0B3SWLVgg770VirYiHB14M5wdRx3zR8mCTzM/TkTQ8=
github.com/ggicci/httpin v0.19.0/go.mod h1:hzsQHcbqLabmGOycf7WNw6AAzcVbsMeoOp46bWAbIWc=
github.com/ggicci/owl v0.8.2 h1:og+lhqpzSMPDdEB+NJfzoAJARP7qCG3f8uUC3xvGukA=
Expand All @@ -67,6 +69,14 @@ github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -76,6 +86,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/iolave/go-errors v1.0.0 h1:vf2qiJ7/pXlR6smI5pnTTXbvoaDru6SrBtkBYy+YGyY=
github.com/iolave/go-errors v1.0.0/go.mod h1:USFxuTyz44cf93421UWhDtSzeqo8YlkQ2fjJwm7/5kU=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
Expand All @@ -94,6 +106,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
Expand Down Expand Up @@ -163,25 +177,27 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A=
github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg=
github.com/theothertomelliott/acyclic v0.0.1 h1:MZ6AEpKS9owkvyNg2RKyD91eG0PVTmOTdE8lYOckWqg=
github.com/theothertomelliott/acyclic v0.0.1/go.mod h1:Lf1fgDzzzm31NWJNN1fjs0b0ozYFgalZM/lxm2AK+68=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo=
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -204,13 +220,13 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"net/http"

"github.com/iolave/go-proxmox/internal/models"
"github.com/iolave/go-proxmox/internal/api_wrapper/models"
)

type server struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (

func (s *server) sendPVERequest(sr *http.Request) (*http.Response, *errors.HTTPError) {
pveUrl, err := url.Parse(fmt.Sprintf(
"https://%s:%d%s",
"https://%s:%d%s?%s",
s.cfg.PVEHost,
s.cfg.PVEPort,
sr.URL.Path,
sr.URL.RawQuery,
))
b, err := io.ReadAll(sr.Body)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"net/http"
"strconv"

apidef "github.com/iolave/go-proxmox/internal/api_def"
"github.com/iolave/go-proxmox/internal/pve_utils"
apidef "github.com/iolave/go-proxmox/internal/api_wrapper/api_def"
"github.com/iolave/go-proxmox/internal/api_wrapper/pve_utils"
"github.com/iolave/go-proxmox/pkg/errors"
)

Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions internal/str_utils/format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package strutils

import (
"unicode"
)

// ToSnakeCase converts a string to snake case.
func ToSnakeCase(s string) string {
// rs is the string as an array of runes.
rs := []rune(s)

// res will be the result of the conversion.
res := []rune{}

for _, r := range rs {
switch {
case unicode.IsLetter(r):
if unicode.IsLower(r) {
res = append(res, r)
} else {
// append an underscore if the rune is uppercase
// only if the previous added rune is not an underscore.
if len(res) > 0 && res[len(res)-1] != '_' {
res = append(res, '_')
}

// append the lowercase rune
res = append(res, unicode.ToLower(r))
}

// if a digit is found, append an underscore only if
// the previous rune is not a digit.
case unicode.IsDigit(r):

if len(res) > 0 && res[len(res)-1] != '_' && !unicode.IsDigit(res[len(res)-1]) {
res = append(res, '_')
}

res = append(res, r)
// if an special rune is found, append an underscore only if
// the previous rune is not an underscore.
default:
// if no previous rune was added, to the result
// we add an underscore and continue iterating.
if len(res) == 0 {
res = append(res, '_')
continue
}

// checks if the previous rune is an underscore
// and if it is not, we append an underscore.
if len(res) > 0 && res[len(res)-1] != '_' {
res = append(res, '_')
}
}
}

return string(res)
}
Loading