From 6ed7d362848f9a69c939f5987b360ef2667e0c39 Mon Sep 17 00:00:00 2001 From: Ignacio Olave Date: Mon, 11 Aug 2025 11:40:39 -0400 Subject: [PATCH 01/38] chore: removed unused files --- .testcoverage.yml | 50 ----------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .testcoverage.yml diff --git a/.testcoverage.yml b/.testcoverage.yml deleted file mode 100644 index 015bdd9..0000000 --- a/.testcoverage.yml +++ /dev/null @@ -1,50 +0,0 @@ -# (mandatory) -# Path to coverprofile file (output of `go test -coverprofile` command). -# -# For cases where there are many coverage profiles, such as when running -# unit tests and integration tests separately, you can combine all those -# profiles into one. In this case, the profile should have a comma-separated list -# of profile files, e.g., 'cover_unit.out,cover_integration.out'. -profile: cover.out - -# (optional; but recommended to set) -# When specified reported file paths will not contain local prefix in the output -#local-prefix: "github.com/org/project" - -# Holds coverage thresholds percentages, values should be in range [0-100] -threshold: - # (optional; default 0) - # The minimum coverage that each file should have - #file: 70 - - # (optional; default 0) - # The minimum coverage that each package should have - #package: 80 - - # (optional; default 0) - # The minimum total coverage project should have - total: 85 - -# Holds regexp rules which will override thresholds for matched files or packages -# using their paths. -# -# First rule from this list that matches file or package is going to apply -# new threshold to it. If project has multiple rules that match same path, -# override rules should be listed in order from specific to more general rules. -#override: - # Increase coverage threshold to 100% for `foo` package - # (default is 80, as configured above in this example) -#- threshold: 100 -# path: ^pkg/lib/foo$ - -# Holds regexp rules which will exclude matched files or packages -# from coverage statistics -exclude: - # Exclude files or packages matching their paths - paths: - - \.pb\.go$ # excludes all protobuf generated files - # - ^pkg/bar # exclude package `pkg/bar` - -# NOTES: -# - symbol `/` in all path regexps will be replaced by current OS file path separator -# to properly work on Windows From 54eaa27475b35093c6bd6de05a85ba039ab68f74 Mon Sep 17 00:00:00 2001 From: Ignacio Olave Date: Mon, 11 Aug 2025 13:07:55 -0400 Subject: [PATCH 02/38] chore: simplified docs generation --- .github/workflows/deploy-docs.yml | 4 +- Makefile | 18 ++----- scripts/generate-docs.sh | 87 +++++++++++++++++++++++++++++-- scripts/install-docs-deps.sh | 15 ------ scripts/preview-docs.sh | 4 -- 5 files changed, 88 insertions(+), 40 deletions(-) mode change 100644 => 100755 scripts/generate-docs.sh delete mode 100755 scripts/install-docs-deps.sh delete mode 100644 scripts/preview-docs.sh diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 2cac7a9..b494d3c 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -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 diff --git a/Makefile b/Makefile index bb825a7..fbbf363 100644 --- a/Makefile +++ b/Makefile @@ -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 ./... @@ -16,13 +8,13 @@ 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 diff --git a/scripts/generate-docs.sh b/scripts/generate-docs.sh old mode 100644 new mode 100755 index c6b8d72..e588492 --- a/scripts/generate-docs.sh +++ b/scripts/generate-docs.sh @@ -1,8 +1,85 @@ +#!/bin/bash + +# set opts +PREVIEW=false +while getopts ":p" opt; do + case $opt in + p) + PREVIEW=true + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# set a variable to know this script path +SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" +ROOT="$(realpath $SCRIPT_PATH/..)" + +################################################################################ +## Build api-wrapper docs +################################################################################ +which swag &> /dev/null +if [ "$?" -ne "0" ]; then + set -e + echo "info: installing swag" + go install github.com/swaggo/swag/cmd/swag@v1.16.6 + set +e +fi +swag init \ + -d $ROOT \ + -g ./cmd/pve_api_wrapper/pve_api_wrapper.go \ + --exclude ./ \ + --parseInternal \ + -o $ROOT/docs/api-wrapper \ + +################################################################################ +## Build go-client docs and generate site +################################################################################ +# Check if $TMPDIR is set +if [ -z "$TMPDIR" ]; then + echo "warn: TMPDIR is not set, using /tmp" + TMPDIR="/tmp" +fi + +# check if TMPDIR is exists +if [ ! -d "$TMPDIR" ]; then + echo "error: TMPDIR '$TMPDIR' does not exist" + exit 1 +fi + VENV="${TMPDIR}/venv/go-proxmox" +mkdir -p $VENV +python3 -m venv ${VENV} source "${VENV}/bin/activate" -rm -rf ./docs/go-client/pkg -mkdir -p ./docs/go-client/pkg/ -go run ./cmd/gomarkdoc/main.go -swag init -g ./cmd/pve_api_wrapper/pve_api_wrapper.go --parseInternal -o ./docs/api-wrapper -mkdocs build + +PIP_DEPS=" \ + mkdocs-material \ + pymdown-extensions \ + markdown-callouts \ + mkdocs-render-swagger-plugin \ +" + +# iterate over the list of dependencies +for dep in $PIP_DEPS; do + pip3 show $dep &> /dev/null + if [ "$?" -ne "0" ]; then + echo "info: installing $dep" + pip3 install $dep + fi +done + +rm -rf $ROOT/docs/go-client/pkg +mkdir -p $ROOT/docs/go-client/pkg +go run $ROOT/cmd/gomarkdoc/main.go +mkdocs build -f $ROOT/mkdocs.yml + +################################################################################ +## Preview docs +################################################################################ +if [ "$PREVIEW" == "true" ]; then + mkdocs serve -f $ROOT/mkdocs.yml +fi diff --git a/scripts/install-docs-deps.sh b/scripts/install-docs-deps.sh deleted file mode 100755 index 5999003..0000000 --- a/scripts/install-docs-deps.sh +++ /dev/null @@ -1,15 +0,0 @@ -VENV="${TMPDIR}/venv/go-proxmox" -mkdir -p $VENV - -python3 -m venv ${VENV} -source "${VENV}/bin/activate" - -pip3 install \ - mkdocs \ - mkdocs-material \ - pymdown-extensions \ - markdown-callouts \ - mkdocs-render-swagger-plugin - -go install github.com/swaggo/swag/cmd/swag@latest - diff --git a/scripts/preview-docs.sh b/scripts/preview-docs.sh deleted file mode 100644 index f85367b..0000000 --- a/scripts/preview-docs.sh +++ /dev/null @@ -1,4 +0,0 @@ -VENV="${TMPDIR}/venv/go-proxmox" - -source "${VENV}/bin/activate" -mkdocs serve From cf5d068442f691bf3cd67530721ab4b0fc4853f0 Mon Sep 17 00:00:00 2001 From: Ignacio Olave Date: Mon, 11 Aug 2025 13:10:07 -0400 Subject: [PATCH 03/38] docs: renamed install script to install-paw --- docs/api-wrapper/index.md | 6 +++--- mkdocs.yml | 2 +- scripts/{install.sh => install-paw.sh} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename scripts/{install.sh => install-paw.sh} (100%) diff --git a/docs/api-wrapper/index.md b/docs/api-wrapper/index.md index 4991483..e6ad466 100644 --- a/docs/api-wrapper/index.md +++ b/docs/api-wrapper/index.md @@ -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]._ @@ -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/