From 74f00f11c2bc36bf333f977f8074c0121a461560 Mon Sep 17 00:00:00 2001 From: smutel <12967891+smutel@users.noreply.github.com> Date: Sun, 10 Jul 2022 18:28:46 +0200 Subject: [PATCH] feat: Update from Netbox 3.2 swagger --- .github/workflows/main.yml | 4 +- ...ger-v3.2.9-contact-assignment-object.patch | 13 +++ ...er-v3.2.9-device-vm-localcontextdata.patch | 91 +++++++++++++++++++ ...gger-v3.2.9-ipaddress-assignedobject.patch | 13 +++ patchs/swagger-v3.2.9-vlangroup-scope.patch | 11 +++ utils/netbox_generate_client | 24 +++-- utils/netbox_major_version | 2 +- 7 files changed, 149 insertions(+), 9 deletions(-) create mode 100644 patchs/swagger-v3.2.9-contact-assignment-object.patch create mode 100644 patchs/swagger-v3.2.9-device-vm-localcontextdata.patch create mode 100644 patchs/swagger-v3.2.9-ipaddress-assignedobject.patch create mode 100644 patchs/swagger-v3.2.9-vlangroup-scope.patch diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 94fb9fb7..89eadaf5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 - name: Lint - uses: reviewdog/action-golangci-lint@v2.1.3 + uses: reviewdog/action-golangci-lint@v2.1.5 with: github_token: ${{ secrets.github_token }} golangci_lint_flags: "--config=.golangci.yml" @@ -39,7 +39,7 @@ jobs: shell: bash - name: Commit library - uses: EndBug/add-and-commit@v9.0.0 + uses: EndBug/add-and-commit@v9.0.1 with: add: 'netbox swagger' author_name: smutel diff --git a/patchs/swagger-v3.2.9-contact-assignment-object.patch b/patchs/swagger-v3.2.9-contact-assignment-object.patch new file mode 100644 index 00000000..0a651792 --- /dev/null +++ b/patchs/swagger-v3.2.9-contact-assignment-object.patch @@ -0,0 +1,13 @@ +--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200 ++++ swagger-v3.2.9.json 2022-08-24 18:07:43.286801649 +0200 +@@ -1811,10 +1811,6 @@ + "type" : "string" + }, + "object" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Object", + "type" : "object" diff --git a/patchs/swagger-v3.2.9-device-vm-localcontextdata.patch b/patchs/swagger-v3.2.9-device-vm-localcontextdata.patch new file mode 100644 index 00000000..72401f25 --- /dev/null +++ b/patchs/swagger-v3.2.9-device-vm-localcontextdata.patch @@ -0,0 +1,91 @@ +--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200 ++++ swagger-v3.2.9.json 2022-08-24 17:39:14.901691297 +0200 +@@ -2445,7 +2445,7 @@ + }, + "local_context_data" : { + "title" : "Local context data", +- "type" : "string", ++ "type" : "object", + "x-nullable" : true + }, + "location" : { "$ref" : "#/definitions/NestedLocation" }, +@@ -2969,10 +2969,6 @@ + "type" : "string" + }, + "config_context" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Config context", + "type" : "object" +@@ -3032,7 +3028,7 @@ + }, + "local_context_data" : { + "title" : "Local context data", +- "type" : "string", ++ "type" : "object", + "x-nullable" : true + }, + "location" : { "$ref" : "#/definitions/NestedLocation" }, +@@ -12339,10 +12335,6 @@ + "type" : "string" + }, + "config_context" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Config context", + "type" : "object" +@@ -12383,7 +12375,7 @@ + }, + "local_context_data" : { + "title" : "Local context data", +- "type" : "string", ++ "type" : "object", + "x-nullable" : true + }, + "memory" : { +@@ -15311,10 +15303,6 @@ + "type" : "string" + }, + "config_context" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Config context", + "type" : "object" +@@ -15364,7 +15352,7 @@ + }, + "local_context_data" : { + "title" : "Local context data", +- "type" : "string", ++ "type" : "object", + "x-nullable" : true + }, + "location" : { +@@ -20517,10 +20505,6 @@ + "type" : "string" + }, + "config_context" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Config context", + "type" : "object" +@@ -20561,7 +20545,7 @@ + }, + "local_context_data" : { + "title" : "Local context data", +- "type" : "string", ++ "type" : "object", + "x-nullable" : true + }, + "memory" : { diff --git a/patchs/swagger-v3.2.9-ipaddress-assignedobject.patch b/patchs/swagger-v3.2.9-ipaddress-assignedobject.patch new file mode 100644 index 00000000..d72e04e5 --- /dev/null +++ b/patchs/swagger-v3.2.9-ipaddress-assignedobject.patch @@ -0,0 +1,13 @@ +--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200 ++++ swagger-v3.2.9.json 2022-08-24 17:41:26.611554335 +0200 +@@ -5331,10 +5331,6 @@ + "type" : "string" + }, + "assigned_object" : { +- "additionalProperties" : { +- "type" : "string", +- "x-nullable" : true +- }, + "readOnly" : true, + "title" : "Assigned object", + "type" : "object" diff --git a/patchs/swagger-v3.2.9-vlangroup-scope.patch b/patchs/swagger-v3.2.9-vlangroup-scope.patch new file mode 100644 index 00000000..9ed30091 --- /dev/null +++ b/patchs/swagger-v3.2.9-vlangroup-scope.patch @@ -0,0 +1,11 @@ +--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200 ++++ swagger-v3.2.9.json 2022-08-24 17:42:38.992587932 +0200 +@@ -12617,7 +12617,7 @@ + "scope" : { + "readOnly" : true, + "title" : "Scope", +- "type" : "string" ++ "type" : "object" + }, + "scope_id" : { + "title" : "Scope id", diff --git a/utils/netbox_generate_client b/utils/netbox_generate_client index c5418646..24d102a7 100755 --- a/utils/netbox_generate_client +++ b/utils/netbox_generate_client @@ -23,33 +23,42 @@ get_last_netbox_version() { done for t in $tags_list; do - if [[ $t =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - MAJOR=$(echo $t | cut -d"." -f3) + if [[ $t =~ ^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + MAJOR=$(echo $t | cut -d"-" -f1 | cut -d"." -f3) if [ "$MAJOR" != "" ]; then if [ $MAJOR -gt $max ]; then max=$MAJOR + docker="$(echo $t | cut -d"-" -f2)" fi fi fi done - echo "$version.$max" + echo "$version.$max-$docker" } NETBOX_MAJOR_VERSION=$(cat netbox_major_version) echo "NETBOX_MAJOR_VERSION=${NETBOX_MAJOR_VERSION}" -LAST_NETBOX_VERSION="$(get_last_netbox_version ${NETBOX_MAJOR_VERSION})" +DOCKER_RESULT="$(get_last_netbox_version ${NETBOX_MAJOR_VERSION})" + +LAST_NETBOX_VERSION="$(echo ${DOCKER_RESULT} | cut -d"-" -f1)" echo "LAST_NETBOX_VERSION=${LAST_NETBOX_VERSION}" +DOCKER_VERSION="$(echo ${DOCKER_RESULT} | cut -d"-" -f2)" +echo "DOCKER_VERSION=${DOCKER_VERSION}" + echo "Get github project netbox-docker ..." rm -rf netbox-docker export VERSION=${LAST_NETBOX_VERSION} git clone https://github.com/netbox-community/netbox-docker.git -q cd netbox-docker git config advice.detachedHead false -git checkout 1.6.0 +git checkout ${DOCKER_VERSION} mv docker-compose.override.yml.example docker-compose.override.yml +sed -i 's/netbox-media-files/gonetbox-media-files/g' docker-compose.yml +sed -i 's/netbox-postgres-data/gonetbox-postgres-data/g' docker-compose.yml +sed -i 's/netbox-redis-data/gonetbox-redis-data/g' docker-compose.yml docker-compose up -d --quiet-pull cd .. @@ -66,6 +75,9 @@ cd ../patchs find . -type f -name "swagger-${VERSION}-*.patch" -exec echo "Using path {}" \; -exec patch -u ../netbox/swagger-${VERSION}.json -i {} \; cd ../utils +echo "Apply ack for int64 ..." +sed -i 's/9223372036854775807/2147483647/g' "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/go-netbox/netbox/swagger-${VERSION}.json" + echo "Check swagger definition ..." jsonlint "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/go-netbox/netbox/swagger-${VERSION}.json" @@ -76,7 +88,7 @@ chmod 755 swagger echo "Destroy docker containers ..." cd netbox-docker -docker-compose down +docker-compose down -v cd .. echo "Cleaning ..." diff --git a/utils/netbox_major_version b/utils/netbox_major_version index 86166894..4d5034ce 100644 --- a/utils/netbox_major_version +++ b/utils/netbox_major_version @@ -1 +1 @@ -v3.1 +v3.2