Skip to content

Commit 74f00f1

Browse files
committed
feat: Update from Netbox 3.2 swagger
1 parent f12b31c commit 74f00f1

7 files changed

+149
-9
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fetch-depth: 0
1919

2020
- name: Lint
21-
uses: reviewdog/action-golangci-lint@v2.1.3
21+
uses: reviewdog/action-golangci-lint@v2.1.5
2222
with:
2323
github_token: ${{ secrets.github_token }}
2424
golangci_lint_flags: "--config=.golangci.yml"
@@ -39,7 +39,7 @@ jobs:
3939
shell: bash
4040

4141
- name: Commit library
42-
uses: EndBug/add-and-commit@v9.0.0
42+
uses: EndBug/add-and-commit@v9.0.1
4343
with:
4444
add: 'netbox swagger'
4545
author_name: smutel
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200
2+
+++ swagger-v3.2.9.json 2022-08-24 18:07:43.286801649 +0200
3+
@@ -1811,10 +1811,6 @@
4+
"type" : "string"
5+
},
6+
"object" : {
7+
- "additionalProperties" : {
8+
- "type" : "string",
9+
- "x-nullable" : true
10+
- },
11+
"readOnly" : true,
12+
"title" : "Object",
13+
"type" : "object"
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200
2+
+++ swagger-v3.2.9.json 2022-08-24 17:39:14.901691297 +0200
3+
@@ -2445,7 +2445,7 @@
4+
},
5+
"local_context_data" : {
6+
"title" : "Local context data",
7+
- "type" : "string",
8+
+ "type" : "object",
9+
"x-nullable" : true
10+
},
11+
"location" : { "$ref" : "#/definitions/NestedLocation" },
12+
@@ -2969,10 +2969,6 @@
13+
"type" : "string"
14+
},
15+
"config_context" : {
16+
- "additionalProperties" : {
17+
- "type" : "string",
18+
- "x-nullable" : true
19+
- },
20+
"readOnly" : true,
21+
"title" : "Config context",
22+
"type" : "object"
23+
@@ -3032,7 +3028,7 @@
24+
},
25+
"local_context_data" : {
26+
"title" : "Local context data",
27+
- "type" : "string",
28+
+ "type" : "object",
29+
"x-nullable" : true
30+
},
31+
"location" : { "$ref" : "#/definitions/NestedLocation" },
32+
@@ -12339,10 +12335,6 @@
33+
"type" : "string"
34+
},
35+
"config_context" : {
36+
- "additionalProperties" : {
37+
- "type" : "string",
38+
- "x-nullable" : true
39+
- },
40+
"readOnly" : true,
41+
"title" : "Config context",
42+
"type" : "object"
43+
@@ -12383,7 +12375,7 @@
44+
},
45+
"local_context_data" : {
46+
"title" : "Local context data",
47+
- "type" : "string",
48+
+ "type" : "object",
49+
"x-nullable" : true
50+
},
51+
"memory" : {
52+
@@ -15311,10 +15303,6 @@
53+
"type" : "string"
54+
},
55+
"config_context" : {
56+
- "additionalProperties" : {
57+
- "type" : "string",
58+
- "x-nullable" : true
59+
- },
60+
"readOnly" : true,
61+
"title" : "Config context",
62+
"type" : "object"
63+
@@ -15364,7 +15352,7 @@
64+
},
65+
"local_context_data" : {
66+
"title" : "Local context data",
67+
- "type" : "string",
68+
+ "type" : "object",
69+
"x-nullable" : true
70+
},
71+
"location" : {
72+
@@ -20517,10 +20505,6 @@
73+
"type" : "string"
74+
},
75+
"config_context" : {
76+
- "additionalProperties" : {
77+
- "type" : "string",
78+
- "x-nullable" : true
79+
- },
80+
"readOnly" : true,
81+
"title" : "Config context",
82+
"type" : "object"
83+
@@ -20561,7 +20545,7 @@
84+
},
85+
"local_context_data" : {
86+
"title" : "Local context data",
87+
- "type" : "string",
88+
+ "type" : "object",
89+
"x-nullable" : true
90+
},
91+
"memory" : {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200
2+
+++ swagger-v3.2.9.json 2022-08-24 17:41:26.611554335 +0200
3+
@@ -5331,10 +5331,6 @@
4+
"type" : "string"
5+
},
6+
"assigned_object" : {
7+
- "additionalProperties" : {
8+
- "type" : "string",
9+
- "x-nullable" : true
10+
- },
11+
"readOnly" : true,
12+
"title" : "Assigned object",
13+
"type" : "object"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- swagger-v3.2.9.json.ori 2022-08-24 17:33:22.468870615 +0200
2+
+++ swagger-v3.2.9.json 2022-08-24 17:42:38.992587932 +0200
3+
@@ -12617,7 +12617,7 @@
4+
"scope" : {
5+
"readOnly" : true,
6+
"title" : "Scope",
7+
- "type" : "string"
8+
+ "type" : "object"
9+
},
10+
"scope_id" : {
11+
"title" : "Scope id",

utils/netbox_generate_client

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,42 @@ get_last_netbox_version() {
2323
done
2424

2525
for t in $tags_list; do
26-
if [[ $t =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
27-
MAJOR=$(echo $t | cut -d"." -f3)
26+
if [[ $t =~ ^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
27+
MAJOR=$(echo $t | cut -d"-" -f1 | cut -d"." -f3)
2828
if [ "$MAJOR" != "" ]; then
2929
if [ $MAJOR -gt $max ]; then
3030
max=$MAJOR
31+
docker="$(echo $t | cut -d"-" -f2)"
3132
fi
3233
fi
3334
fi
3435
done
3536

36-
echo "$version.$max"
37+
echo "$version.$max-$docker"
3738
}
3839

3940
NETBOX_MAJOR_VERSION=$(cat netbox_major_version)
4041
echo "NETBOX_MAJOR_VERSION=${NETBOX_MAJOR_VERSION}"
4142

42-
LAST_NETBOX_VERSION="$(get_last_netbox_version ${NETBOX_MAJOR_VERSION})"
43+
DOCKER_RESULT="$(get_last_netbox_version ${NETBOX_MAJOR_VERSION})"
44+
45+
LAST_NETBOX_VERSION="$(echo ${DOCKER_RESULT} | cut -d"-" -f1)"
4346
echo "LAST_NETBOX_VERSION=${LAST_NETBOX_VERSION}"
4447

48+
DOCKER_VERSION="$(echo ${DOCKER_RESULT} | cut -d"-" -f2)"
49+
echo "DOCKER_VERSION=${DOCKER_VERSION}"
50+
4551
echo "Get github project netbox-docker ..."
4652
rm -rf netbox-docker
4753
export VERSION=${LAST_NETBOX_VERSION}
4854
git clone https://github.com/netbox-community/netbox-docker.git -q
4955
cd netbox-docker
5056
git config advice.detachedHead false
51-
git checkout 1.6.0
57+
git checkout ${DOCKER_VERSION}
5258
mv docker-compose.override.yml.example docker-compose.override.yml
59+
sed -i 's/netbox-media-files/gonetbox-media-files/g' docker-compose.yml
60+
sed -i 's/netbox-postgres-data/gonetbox-postgres-data/g' docker-compose.yml
61+
sed -i 's/netbox-redis-data/gonetbox-redis-data/g' docker-compose.yml
5362
docker-compose up -d --quiet-pull
5463
cd ..
5564

@@ -66,6 +75,9 @@ cd ../patchs
6675
find . -type f -name "swagger-${VERSION}-*.patch" -exec echo "Using path {}" \; -exec patch -u ../netbox/swagger-${VERSION}.json -i {} \;
6776
cd ../utils
6877

78+
echo "Apply ack for int64 ..."
79+
sed -i 's/9223372036854775807/2147483647/g' "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/go-netbox/netbox/swagger-${VERSION}.json"
80+
6981
echo "Check swagger definition ..."
7082
jsonlint "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/go-netbox/netbox/swagger-${VERSION}.json"
7183

@@ -76,7 +88,7 @@ chmod 755 swagger
7688

7789
echo "Destroy docker containers ..."
7890
cd netbox-docker
79-
docker-compose down
91+
docker-compose down -v
8092
cd ..
8193

8294
echo "Cleaning ..."

utils/netbox_major_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.1
1+
v3.2

0 commit comments

Comments
 (0)