Skip to content

Commit

Permalink
feat: Update from Netbox 3.2 swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
smutel committed Aug 24, 2022
1 parent f12b31c commit 74f00f1
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0

- name: Lint
uses: reviewdog/[email protected].3
uses: reviewdog/[email protected].5
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
Expand All @@ -39,7 +39,7 @@ jobs:
shell: bash

- name: Commit library
uses: EndBug/[email protected].0
uses: EndBug/[email protected].1
with:
add: 'netbox swagger'
author_name: smutel
Expand Down
13 changes: 13 additions & 0 deletions patchs/swagger-v3.2.9-contact-assignment-object.patch
Original file line number Diff line number Diff line change
@@ -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"
91 changes: 91 additions & 0 deletions patchs/swagger-v3.2.9-device-vm-localcontextdata.patch
Original file line number Diff line number Diff line change
@@ -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" : {
13 changes: 13 additions & 0 deletions patchs/swagger-v3.2.9-ipaddress-assignedobject.patch
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions patchs/swagger-v3.2.9-vlangroup-scope.patch
Original file line number Diff line number Diff line change
@@ -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",
24 changes: 18 additions & 6 deletions utils/netbox_generate_client
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..

Expand All @@ -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"

Expand All @@ -76,7 +88,7 @@ chmod 755 swagger

echo "Destroy docker containers ..."
cd netbox-docker
docker-compose down
docker-compose down -v
cd ..

echo "Cleaning ..."
Expand Down
2 changes: 1 addition & 1 deletion utils/netbox_major_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.1
v3.2

0 comments on commit 74f00f1

Please sign in to comment.