Skip to content

Commit 9ed11bc

Browse files
authored
Merge branch 'master' into pd/influxdb3-plugins-doc
2 parents df3e4ca + 43efe0c commit 9ed11bc

File tree

196 files changed

+18055
-841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+18055
-841
lines changed

api-docs/.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins:
2-
- './openapi/plugins/docs-plugin.js'
2+
- './../openapi/plugins/docs-plugin.js'
33
extends:
44
- recommended
55
- docs/all

api-docs/cloud-dedicated/management/content/info.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

api-docs/generate-api-docs.sh

Lines changed: 77 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,30 @@ while getopts "hc" opt; do
3636
done
3737

3838
function generateHtml {
39-
specPath="$1"
40-
product="$2"
41-
productName="$3"
42-
api="$4"
43-
configPath="$5"
44-
isDefault=$6
39+
local specPath="$1"
40+
local productVersion="$2"
41+
local productName="$3"
42+
local api="$4"
43+
local configPath="$5"
44+
local isDefault=$6
4545

4646
# Use the product name to define the menu for the Hugo template
47-
menu="influxdb_$(echo $product | sed 's/\./_/g;s/-/_/g;')"
47+
local menu="$(echo $productVersion | sed 's/\./_/g;s/-/_/g;s/\//_/g;')"
48+
# Short version name (for old aliases)
49+
# Everything after the last slash
50+
local versionDir=$(echo $productVersion | sed 's/.*\///g;')
4851
# Extract the API name--for example, "management" from "management@v2".
49-
apiName=$(echo $api | sed 's/@.*//g;')
52+
local apiName=$(echo $api | sed 's/@.*//g;')
5053
# Extract the API version--for example, "v0" from "management@v0".
51-
version=$(echo $api | sed 's/.*@//g;')
54+
local apiVersion=$(echo $api | sed 's/.*@//g;')
5255
# Use the title and summary defined in the product API's info.yml file.
53-
title=$(yq '.title' $product/$apiName/content/info.yml)
54-
menuTitle=$(yq '.x-influxdata-short-title' $product/$apiName/content/info.yml)
55-
description=$(yq '.summary' $product/$apiName/content/info.yml)
56+
local title=$(yq '.title' $productVersion/$apiName/content/info.yml)
57+
local menuTitle=$(yq '.x-influxdata-short-title' $productVersion/$apiName/content/info.yml)
58+
local description=$(yq '.summary' $productVersion/$apiName/content/info.yml)
5659
# Define the file name for the Redoc HTML output.
57-
specbundle=redoc-static_index.html
60+
local specbundle=redoc-static_index.html
5861
# Define the temporary file for the Hugo template and Redoc HTML.
59-
tmpfile="${product}-${api}_index.tmp"
62+
local tmpfile="${productVersion}-${api}_index.tmp"
6063

6164
echo "Bundling $specPath"
6265

@@ -75,7 +78,7 @@ function generateHtml {
7578
--options.noAutoAuth \
7679
--output=$specbundle \
7780
--templateOptions.description=$description \
78-
--templateOptions.product="$product" \
81+
--templateOptions.product="$productVersion" \
7982
--templateOptions.productName="$productName"
8083

8184
if [[ $apiName == "v1-compatibility" ]]; then
@@ -90,10 +93,10 @@ menu:
9093
identifier: api-reference-$apiName
9194
weight: 304
9295
aliases:
93-
- /influxdb/$product/api/v1/
96+
- /influxdb/$versionDir/api/v1/
9497
---
9598
"
96-
elif [[ $version == "0" ]]; then
99+
elif [[ $apiVersion == "0" ]]; then
97100
echo $productName $apiName
98101
frontmatter="---
99102
title: $title
@@ -119,7 +122,7 @@ menu:
119122
identifier: api-reference-$apiName
120123
weight: 102
121124
aliases:
122-
- /influxdb/$product/api/
125+
- /influxdb/$versionDir/api/
123126
---
124127
"
125128
else
@@ -152,68 +155,74 @@ weight: 102
152155
rm -f $specbundle
153156
# Create the directory and move the file.
154157
if [ ! -z "$apiName" ]; then
155-
mkdir -p ../content/influxdb/$product/api/$apiName
156-
mv $tmpfile ../content/influxdb/$product/api/$apiName/_index.html
158+
mkdir -p ../content/$productVersion/api/$apiName
159+
mv $tmpfile ../content/$productVersion/api/$apiName/_index.html
157160
else
158-
mkdir -p ../content/influxdb/$product/api
159-
mv $tmpfile ../content/influxdb/$product/api/_index.html
161+
mkdir -p ../content/$productVersion/api
162+
mv $tmpfile ../content/$productVersion/api/_index.html
160163
fi
161164
}
162165

163166
# Use a combination of directory names and configuration files to build the API documentation.
164167
# Each directory represents a product, and each product directory contains a configuration file that defines APIs and their spec file locations.
165168
function build {
166-
# Get the list of products from directory names
167-
products="$(ls -d -- */ | grep -v 'node_modules' | grep -v 'openapi')"
168-
169-
for product in $products; do
170-
#Trim the trailing slash off the directory name
171-
product="${product%/}"
172-
# Get the product API configuration file.
173-
configPath="$product/.config.yml"
174-
if [ ! -f $configPath ]; then
175-
configPath=".config.yml"
176-
fi
177-
echo "Checking product config $configPath"
178-
# Get the product name from the configuration.
179-
productName=$(yq e '.x-influxdata-product-name' $configPath)
180-
if [[ -z "$productName" ]]; then
181-
productName=InfluxDB
182-
fi
183-
# Get an array of product API names (keys) from the configuration file
184-
apis=$(yq e '.apis | keys | .[]' $configPath)
185-
# Read each element of the apis array
186-
while IFS= read -r api; do
187-
# Get the spec file path from the configuration.
188-
specRootPath=$(yq e ".apis | .$api | .root" $configPath)
189-
# Check that the YAML spec file exists.
190-
specPath="$product/$specRootPath"
191-
echo "Checking for spec $specPath"
192-
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
193-
echo "OpenAPI spec $specPath doesn't exist."
169+
local versions
170+
versions="$(ls -d -- */* | grep -v 'node_modules' | grep -v 'openapi')"
171+
for version in $versions; do
172+
# Trim the trailing slash off the directory name
173+
local version="${version%/}"
174+
# Get the version API configuration file.
175+
local configPath="$version/.config.yml"
176+
if [ ! -f "$configPath" ]; then
177+
configPath=".config.yml"
194178
fi
195-
# Get default status from the configuration.
196-
isDefault=false
197-
defaultStatus=$(yq e ".apis | .$api | .x-influxdata-default" $configPath)
198-
if [[ $defaultStatus == "true" ]]; then
199-
isDefault=true
179+
echo "Using config $configPath"
180+
# Get the product name from the configuration.
181+
local versionName
182+
versionName=$(yq e '.x-influxdata-product-name' "$configPath")
183+
if [[ -z "$versionName" ]]; then
184+
versionName=InfluxDB
200185
fi
186+
# Get an array of API names (keys) from the configuration file
187+
local apis
188+
apis=$(yq e '.apis | keys | .[]' "$configPath")
189+
# Read each element of the apis array
190+
while IFS= read -r api; do
191+
echo "======Building $version $api======"
192+
# Get the spec file path from the configuration.
193+
local specRootPath
194+
specRootPath=$(yq e ".apis | .$api | .root" "$configPath")
195+
# Check that the YAML spec file exists.
196+
local specPath
197+
specPath="$version/$specRootPath"
198+
if [ -d "$specPath" ] || [ ! -f "$specPath" ]; then
199+
echo "OpenAPI spec $specPath doesn't exist."
200+
fi
201+
# Get default status from the configuration.
202+
local isDefault=false
203+
local defaultStatus
204+
defaultStatus=$(yq e ".apis | .$api | .x-influxdata-default" "$configPath")
205+
if [[ $defaultStatus == "true" ]]; then
206+
isDefault=true
207+
fi
201208

202-
# If the spec file differs from master, regenerate the HTML.
203-
update=0
204-
if [[ $generate_changed == 0 ]]; then
205-
diff=$(git diff --name-status master -- ${specPath})
206-
if [[ -z "$diff" ]]; then
207-
update=1
209+
# If the spec file differs from master, regenerate the HTML.
210+
local update=0
211+
if [[ $generate_changed == 0 ]]; then
212+
local diff
213+
diff=$(git diff --name-status master -- "${specPath}")
214+
if [[ -z "$diff" ]]; then
215+
update=1
216+
fi
208217
fi
209-
fi
210218

211-
if [[ $update -eq 0 ]]; then
212-
echo "Regenerating $product $api"
213-
generateHtml "$specPath" "$product" "$productName" "$api" "$configPath" $isDefault
214-
fi
215-
done <<< "$apis"
216-
done
219+
if [[ $update -eq 0 ]]; then
220+
echo "Regenerating $version $api"
221+
generateHtml "$specPath" "$version" "$versionName" "$api" "$configPath" "$isDefault"
222+
fi
223+
echo "========Done with $version $api========"
224+
done <<< "$apis"
225+
done
217226
}
218227

219228
build

api-docs/getswagger.sh

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,93 +139,98 @@ function postProcess() {
139139
}
140140

141141
function updateCloudV2 {
142-
outFile="cloud/v2/ref.yml"
142+
outFile="influxdb/cloud/v2/ref.yml"
143143
if [[ -z "$baseUrl" ]];
144144
then
145145
echo "Using existing $outFile"
146146
else
147147
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
148148
fi
149-
postProcess $outFile 'cloud/.config.yml' v2@2
149+
postProcess $outFile 'influxdb/cloud/.config.yml' v2@2
150150
}
151151

152152
function updateCloudDedicatedManagement {
153-
outFile="cloud-dedicated/management/openapi.yml"
153+
outFile="influxdb3/cloud-dedicated/management/openapi.yml"
154154
if [[ -z "$baseUrl" ]];
155155
then
156156
echo "Using existing $outFile"
157157
else
158-
curl $UPDATE_OPTIONS https://raw.githubusercontent.com/influxdata/granite/ab7ee2aceacfae7f415d15ffbcf8c9d0f6f3e015/openapi.yaml -o $outFile
158+
# Clone influxdata/granite and fetch the latest openapi.yaml file.
159+
echo "Fetching the latest openapi.yaml file from influxdata/granite"
160+
tmp_dir=$(mktemp -d)
161+
git clone --depth 1 --branch main https://github.com/influxdata/granite.git "$tmp_dir"
162+
cp "$tmp_dir/openapi.yaml" "$outFile"
163+
rm -rf "$tmp_dir"
159164
fi
160-
postProcess $outFile 'cloud-dedicated/.config.yml' management@0
165+
postProcess $outFile 'influxdb3/cloud-dedicated/.config.yml' management@0
161166
}
162167

163168
function updateCloudDedicatedV2 {
164-
outFile="cloud-dedicated/v2/ref.yml"
169+
outFile="influxdb3/cloud-dedicated/v2/ref.yml"
165170
if [[ -z "$baseUrl" ]];
166171
then
167172
echo "Using existing $outFile"
168173
else
169174
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
170175
fi
171-
postProcess $outFile 'cloud-dedicated/.config.yml' v2@2
176+
postProcess $outFile 'influxdb3/cloud-dedicated/.config.yml' v2@2
172177
}
173178

174179
function updateClusteredV2 {
175-
outFile="clustered/v2/ref.yml"
180+
outFile="influxdb3/clustered/v2/ref.yml"
176181
if [[ -z "$baseUrl" ]];
177182
then
178183
echo "Using existing $outFile"
179184
else
180185
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
181186
fi
182-
postProcess $outFile 'clustered/.config.yml' v2@2
187+
postProcess $outFile 'influxdb3/clustered/.config.yml' v2@2
183188
}
184189

185190
function updateCloudServerlessV2 {
186-
outFile="cloud-serverless/v2/ref.yml"
191+
outFile="influxdb3/cloud-serverless/v2/ref.yml"
187192
if [[ -z "$baseUrl" ]];
188193
then
189194
echo "Using existing $outFile"
190195
else
191196
curl $UPDATE_OPTIONS ${baseUrl}/contracts/ref/cloud.yml -o $outFile
192197
fi
193-
postProcess $outFile 'cloud-serverless/.config.yml' v2@2
198+
postProcess $outFile 'influxdb3/cloud-serverless/.config.yml' v2@2
194199
}
195200

196201
function updateOSSV2 {
197-
outFile="v2/ref.yml"
202+
outFile="influxdb/v2/ref.yml"
198203
if [[ -z "$baseUrlOSS" ]];
199204
then
200205
echo "Using existing $outFile"
201206
else
202207
curl $UPDATE_OPTIONS ${baseUrlOSS}/contracts/ref/oss.yml -o $outFile
203208
fi
204-
postProcess $outFile 'v2/.config.yml' '@2'
209+
postProcess $outFile 'influxdb/v2/.config.yml' '@2'
205210
}
206211

207212
function updateV1Compat {
208-
outFile="cloud/v1-compatibility/swaggerV1Compat.yml"
213+
outFile="influxdb/cloud/v1-compatibility/swaggerV1Compat.yml"
209214
if [[ -z "$baseUrl" ]];
210215
then
211216
echo "Using existing $outFile"
212217
else
213218
curl $UPDATE_OPTIONS ${baseUrl}/contracts/swaggerV1Compat.yml -o $outFile
214219
fi
215-
postProcess $outFile 'cloud/.config.yml' 'v1-compatibility'
220+
postProcess $outFile 'influxdb/cloud/.config.yml' 'v1-compatibility'
216221

217-
outFile="v2/v1-compatibility/swaggerV1Compat.yml"
222+
outFile="influxdb/v2/v1-compatibility/swaggerV1Compat.yml"
218223
cp cloud/v1-compatibility/swaggerV1Compat.yml $outFile
219-
postProcess $outFile 'v2/.config.yml' 'v1-compatibility'
224+
postProcess $outFile 'influxdb/v2/.config.yml' 'v1-compatibility'
220225

221-
outFile="cloud-dedicated/v1-compatibility/swaggerV1Compat.yml"
222-
postProcess $outFile 'cloud-dedicated/.config.yml' 'v1-compatibility'
226+
outFile="influxdb3/cloud-dedicated/v1-compatibility/swaggerV1Compat.yml"
227+
postProcess $outFile 'influxdb3/cloud-dedicated/.config.yml' 'v1-compatibility'
223228

224-
outFile="cloud-serverless/v1-compatibility/swaggerV1Compat.yml"
225-
postProcess $outFile 'cloud-serverless/.config.yml' 'v1-compatibility'
229+
outFile="influxdb3/cloud-serverless/v1-compatibility/swaggerV1Compat.yml"
230+
postProcess $outFile 'influxdb3/cloud-serverless/.config.yml' 'v1-compatibility'
226231

227-
outFile="clustered/v1-compatibility/swaggerV1Compat.yml"
228-
postProcess $outFile 'clustered/.config.yml' 'v1-compatibility'
232+
outFile="influxdb3/clustered/v1-compatibility/swaggerV1Compat.yml"
233+
postProcess $outFile 'influxdb3/clustered/.config.yml' 'v1-compatibility'
229234
}
230235

231236
UPDATE_OPTIONS="--fail"

api-docs/cloud/.config.yml renamed to api-docs/influxdb/cloud/.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins:
2-
- '../openapi/plugins/docs-plugin.js'
2+
- '../../openapi/plugins/docs-plugin.js'
33
extends:
44
- recommended
55
- docs/all

0 commit comments

Comments
 (0)