Skip to content

Commit 56477d4

Browse files
committed
rebase
1 parent 98809fe commit 56477d4

File tree

10 files changed

+312
-0
lines changed

10 files changed

+312
-0
lines changed

client/templates/header-cfg.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+

client/templates/header-json5.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+

client/templates/header-md.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->

client/templates/header-py.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+

client/templates/header-sh.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#

client/templates/header-typed.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+

client/templates/header-xml.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+

client/templates/header-yaml.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+

client/templates/header-yml.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+

client/templates/regenerate.sh

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
set -e
22+
23+
#############################
24+
# Regenerate Python clients #
25+
#############################
26+
27+
echo "Regenerating python from the spec"
28+
29+
# TODO skip-validate-spec is needed because the upstream Iceberg spec seems invalid. e.g.:
30+
# [main] ERROR o.o.codegen.DefaultCodegen - Required var sort-order-id not in properties
31+
32+
docker run --rm \
33+
-v "$(dirname "$0")/../..:/local" \
34+
openapitools/openapi-generator-cli generate \
35+
-i /local/spec/polaris-management-service.yml \
36+
-g python \
37+
-o /local/client/python \
38+
--additional-properties=packageName=polaris.management \
39+
--additional-properties=apiNamePrefix=polaris > /dev/null
40+
41+
docker run --rm \
42+
-v "$(dirname "$0")/../..:/local" \
43+
openapitools/openapi-generator-cli generate \
44+
-i /local/spec/polaris-catalog-service.yaml \
45+
-g python \
46+
-o /local/client/python \
47+
--additional-properties=packageName=polaris.catalog \
48+
--additional-properties=apiNameSuffix="" \
49+
--skip-validate-spec > /dev/null
50+
51+
docker run --rm \
52+
-v "$(dirname "$0")/../..:/local" \
53+
openapitools/openapi-generator-cli generate \
54+
-i /local/spec/iceberg-rest-catalog-open-api.yaml \
55+
-g python \
56+
-o /local/client/python \
57+
--additional-properties=packageName=polaris.catalog \
58+
--additional-properties=apiNameSuffix="" \
59+
--additional-properties=apiNamePrefix=Iceberg \
60+
--skip-validate-spec > /dev/null
61+
62+
#############################
63+
# Prepend Licenses #
64+
#############################
65+
66+
echo "Re-applying license headers"
67+
68+
prepend_header() {
69+
local file="$1"
70+
local header_file="$2"
71+
tmpfile=$(mktemp)
72+
cat "$header_file" "$file" > "$tmpfile"
73+
mv "$tmpfile" "$file"
74+
}
75+
76+
77+
pushd "$(dirname "$0")/.." > /dev/null
78+
TARGET_DIR="$(dirname "$0")/../python"
79+
80+
# List of paths to exclude (.../client)
81+
EXCLUDE_PATHS=(
82+
"python/.gitignore"
83+
"python/.openapi-generator/"
84+
"python/.openapi-generator-ignore"
85+
"python/pyproject.toml"
86+
)
87+
88+
EXCLUDE_EXTENSIONS=(
89+
"json"
90+
)
91+
92+
# Process all files in the target directory
93+
git ls-files "${TARGET_DIR}" | while read -r file; do
94+
if [ -f "$file" ]; then
95+
# Extract the extension
96+
ext="${file##*.}"
97+
98+
# Check if we need to exclude this extension
99+
extension_excluded=false
100+
for exclude_ext in "${EXCLUDE_EXTENSIONS[@]}"; do
101+
if [ "$ext" = "$exclude_ext" ]; then
102+
extension_excluded=true
103+
fi
104+
done
105+
106+
# Skip this file if its extension is excluded
107+
if [ "$extension_excluded" = true ]; then
108+
echo "${file}: skipped"
109+
continue
110+
else
111+
# Construct the header file path
112+
header_file="$(dirname "$0")/header-${ext}.txt"
113+
114+
# Only process if the license file exists
115+
if [ -f "$header_file" ]; then
116+
echo "${file}: updated"
117+
prepend_header "$file" "$header_file"
118+
else
119+
# Check if file should be excluded
120+
exclude=false
121+
for exclude_path in "${EXCLUDE_PATHS[@]}"; do
122+
if [[ "$file" == "$exclude_path"* ]]; then
123+
exclude=true
124+
fi
125+
done
126+
127+
if [ "$exclude" = false ]; then
128+
echo "No header compatible with file ${file}"
129+
exit 2
130+
fi
131+
fi
132+
fi
133+
fi
134+
done
135+
136+
echo "Regeneration complete"
137+
138+
popd > /dev/null
139+

0 commit comments

Comments
 (0)