Skip to content

Commit b6e6101

Browse files
committed
[codegen] update to latest spec
0 parents  commit b6e6101

4,387 files changed

Lines changed: 1153198 additions & 0 deletions

File tree

Some content is hidden

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

.backportrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"upstream": "elastic/elasticsearch-java",
3+
"targetBranchChoices": [
4+
"main",
5+
"8.0",
6+
"7.17",
7+
"7.16"
8+
],
9+
"targetPRLabels": ["backport"],
10+
"branchLabelMapping": {
11+
"^v8.1.0$": "main",
12+
"^v(\\d+).(\\d+).\\d+(?:-(?:alpha|beta|rc)\\d+)?$": "$1.$2"
13+
}
14+
}

.buildkite/pipeline.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
steps:
2+
- label: ":java: :elasticsearch: Elasticsearch Java API client DRA - {{matrix.workflow}}"
3+
agents:
4+
provider: "gcp"
5+
branches: [ "main", "7.17", "8.17", "8.18", "8.x", "9.0" ]
6+
matrix:
7+
setup:
8+
workflow:
9+
- "snapshot"
10+
- "staging"
11+
command: ".ci/release_dra.sh {{matrix.workflow}}"

.buildkite/release_central.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
agents:
2+
provider: "gcp"
3+
4+
steps:
5+
- label: ":java: :elasticsearch: Elasticsearch Java API client - Release"
6+
key: "release"
7+
command: ".ci/release_central.sh"
8+
artifact_paths:
9+
- ".ci/output/repository/**/*"
10+
- "signed-artifacts/**/*"
11+
- wait: ~
12+
- label: "Publish S3 Artifacts :s3:"
13+
trigger: unified-release-publish-s3-artifacts
14+
key: publish-s3-service
15+
build:
16+
env:
17+
DESTINATION_PATH: "s3://artifacts.elastic.co/javadoc/co/elastic/clients/elasticsearch-java/"
18+
EXTRACT_ARTIFACT: "${VERSION}/elasticsearch-java-${VERSION}-javadoc.jar"
19+
20+
#notify:
21+
# - slack: "#devtools-notify"
22+
# # skip slack messages if no failures and dry-run mode
23+
# if: 'build.state != "passed" && build.env("dry_run") == "false"'

.ci/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# Licensed to Elasticsearch B.V. under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch B.V. licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# 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+
20+
# Build a Docker image that has Gradle and all project dependencies ready.
21+
# Needs to be run with .git and java-client/src mounted under /elasticsearch-java.
22+
23+
FROM eclipse-temurin:17
24+
25+
# Default UID/GID to 1000
26+
# it can be overridden at build time
27+
ARG BUILDER_UID=1000
28+
ARG BUILDER_GID=1000
29+
30+
# Create group and user if needed
31+
RUN (getent group ${BUILDER_GID} || groupadd -g ${BUILDER_GID} elastic) \
32+
&& (getent passwd ${BUILDER_UID} || useradd -u ${BUILDER_UID} -g ${BUILDER_GID} elastic) \
33+
&& mkdir -p /elasticsearch-java/build \
34+
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /elasticsearch-java \
35+
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /home
36+
37+
WORKDIR /elasticsearch-java/
38+
USER ${BUILDER_UID}:${BUILDER_GID}
39+
40+
# Download and initialize Gradle
41+
COPY --chown=$BUILDER_UID:$BUILDER_GID gradlew ./
42+
COPY --chown=$BUILDER_UID:$BUILDER_GID gradle ./gradle
43+
RUN ./gradlew
44+
45+
COPY --chown=$BUILDER_UID:$BUILDER_GID LICENSE.txt NOTICE.txt ./
46+
47+
48+
49+
# Prefetch and cache dependencies
50+
COPY --chown=$BUILDER_UID:$BUILDER_GID build.gradle.kts settings.gradle.kts ./
51+
COPY --chown=$BUILDER_UID:$BUILDER_GID buildSrc ./buildSrc/
52+
COPY --chown=$BUILDER_UID:$BUILDER_GID config ./config/
53+
COPY --chown=$BUILDER_UID:$BUILDER_GID rest5-client ./rest5-client/
54+
COPY --chown=$BUILDER_UID:$BUILDER_GID java-client/build.gradle.kts ./java-client/
55+
RUN ./gradlew resolveDependencies
56+
57+
# Note: trailing '*' avoids failing if the file doesn't exist
58+
COPY --chown=$BUILDER_UID:$BUILDER_GID gradle.properties* ./
59+
60+
# Build artifacts. Expects these mounted directories:
61+
# /elasticsearch-java/.git - git index (read-only)
62+
# /elasticsearch-java/java-client/src - source files (read-only)
63+
# /elasticsearch-java/build - output directory (read-write)
64+
ENTRYPOINT ["./gradlew"]

.ci/configure_signing.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to Elasticsearch B.V. under one or more contributor
5+
# license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright
7+
# ownership. Elasticsearch B.V. licenses this file to you under
8+
# the Apache License, Version 2.0 (the "License"); you may
9+
# not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing,
15+
# software distributed under the License is distributed on an
16+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
# KIND, either express or implied. See the License for the
18+
# specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
22+
#see https://central.sonatype.org/publish/publish-gradle/#distributing-your-public-key
23+
24+
set -euo pipefail
25+
26+
if grep -sq "signing.keyId" gradle.properties; then
27+
# Keys already present
28+
exit 0
29+
fi
30+
31+
mkdir -p /tmp/secured
32+
keyring_file="/tmp/secured/keyring.gpg"
33+
34+
vault_path="kv/ci-shared/release-eng/team-release-secrets/elasticsearch-java"
35+
36+
vault kv get --field="keyring" $vault_path/gpg | base64 -d > $keyring_file
37+
## NOTE: passphase is the name of the field.
38+
signing_password=$(vault kv get --field="passphase" $vault_path/gpg)
39+
signing_key=$(vault kv get --field="key_id" $vault_path/gpg)
40+
41+
maven_username=$(vault kv get --field="username" $vault_path/maven_central)
42+
maven_password=$(vault kv get --field="password" $vault_path/maven_central)
43+
44+
cat >> gradle.properties <<EOF
45+
signing.keyId=${signing_key: -8}
46+
signing.password=${signing_password}
47+
signing.secretKeyRingFile=${keyring_file}
48+
49+
sonatypeUsername=${maven_username}
50+
sonatypePassword=${maven_password}
51+
EOF

.ci/make.sh

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to Elasticsearch B.V. under one or more contributor
4+
# license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright
6+
# ownership. Elasticsearch B.V. licenses this file to you under
7+
# the Apache License, Version 2.0 (the "License"); you may
8+
# not use this file except in compliance with the License.
9+
# 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+
# ------------------------------------------------------- #
22+
#
23+
# Skeleton for common build entry script for all elastic
24+
# clients. Needs to be adapted to individual client usage.
25+
#
26+
# Must be called: ./.ci/make.sh <target> <params>
27+
#
28+
# Version: 1.1.0
29+
#
30+
# Targets:
31+
# ---------------------------
32+
# assemble <VERSION> : build client artefacts with version
33+
# bump <VERSION> : bump client internals to version
34+
# codegen <VERSION> : generate endpoints
35+
# docsgen <VERSION> : generate documentation
36+
# examplegen : generate the doc examples
37+
# clean : clean workspace
38+
#
39+
# ------------------------------------------------------- #
40+
41+
# ------------------------------------------------------- #
42+
# Bootstrap
43+
# ------------------------------------------------------- #
44+
45+
set -euo pipefail
46+
47+
script_path=$(dirname "$(realpath "$0")")
48+
repo=$(realpath "$script_path/../")
49+
50+
# shellcheck disable=SC1090
51+
CMD=$1
52+
TASK=$1
53+
TASK_ARGS=()
54+
VERSION=$2
55+
STACK_VERSION=$VERSION
56+
57+
product="elastic/elasticsearch-java"
58+
output_folder=".ci/output"
59+
codegen_folder=".ci/output"
60+
OUTPUT_DIR="$repo/${output_folder}"
61+
WORKFLOW="${WORKFLOW-staging}"
62+
mkdir -p "$OUTPUT_DIR"
63+
64+
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
65+
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
66+
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
67+
68+
# ------------------------------------------------------- #
69+
# Parse Command
70+
# ------------------------------------------------------- #
71+
72+
case $CMD in
73+
clean)
74+
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
75+
rm -rf "$output_folder"
76+
echo -e "\033[32;1mdone.\033[0m"
77+
exit 0
78+
;;
79+
assemble)
80+
if [ -z "$VERSION" ]; then
81+
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
82+
exit 1
83+
fi
84+
echo -e "\033[36;1mTARGET: assemble artefact $VERSION\033[0m"
85+
TASK=assemble
86+
TASK_ARGS=("$VERSION" "$output_folder")
87+
;;
88+
release)
89+
if [ -z "$VERSION" ]; then
90+
echo -e "\033[31;1mTARGET: release -> missing version parameter\033[0m"
91+
exit 1
92+
fi
93+
echo -e "\033[36;1mTARGET: release artefact $VERSION\033[0m"
94+
TASK=release
95+
TASK_ARGS=("$VERSION" "$output_folder")
96+
;;
97+
codegen)
98+
if [ -v "$VERSION" ]; then
99+
echo -e "\033[31;1mTARGET: codegen -> missing version parameter\033[0m"
100+
exit 1
101+
fi
102+
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
103+
TASK=codegen
104+
# VERSION is BRANCH here for now
105+
TASK_ARGS=("$VERSION" "$codegen_folder")
106+
;;
107+
docsgen)
108+
if [ -v "$VERSION" ]; then
109+
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
110+
exit 1
111+
fi
112+
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
113+
TASK=codegen
114+
# VERSION is BRANCH here for now
115+
TASK_ARGS=("$VERSION" "$codegen_folder")
116+
;;
117+
examplesgen)
118+
echo -e "\033[36;1mTARGET: generate examples\033[0m"
119+
TASK=codegen
120+
# VERSION is BRANCH here for now
121+
TASK_ARGS=("$VERSION" "$codegen_folder")
122+
;;
123+
bump)
124+
if [ -z "$VERSION" ]; then
125+
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
126+
exit 1
127+
fi
128+
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
129+
TASK=bump
130+
# VERSION is BRANCH here for now
131+
TASK_ARGS=("$VERSION")
132+
;;
133+
*)
134+
echo -e "\nUsage:\n\t $CMD is not supported right now\n"
135+
exit 1
136+
esac
137+
138+
139+
# ------------------------------------------------------- #
140+
# Build Container
141+
# ------------------------------------------------------- #
142+
143+
docker_image=${product}-build-$(echo "$VERSION" | tr '[:upper:]' '[:lower:]')
144+
git_mount="-v $repo/.git:/elasticsearch-java/.git:ro"
145+
src_mount="-v $repo/java-client/src:/elasticsearch-java/java-client/src:ro"
146+
output_mount="-v $repo/.ci/output:/elasticsearch-java/build"
147+
148+
build_image() {
149+
echo -e "\033[34;1mINFO: building $product container\033[0m"
150+
151+
docker build \
152+
--file .ci/Dockerfile \
153+
--tag $docker_image \
154+
--build-arg BUILDER_UID="$(id -u)" \
155+
--build-arg BUILDER_GID="$(id -g)" .
156+
}
157+
158+
# ------------------------------------------------------- #
159+
# Post Command tasks & checks
160+
# ------------------------------------------------------- #
161+
162+
if [[ "$CMD" == "assemble" ]]; then
163+
rm -rf .ci/output/repository
164+
165+
if [[ "$WORKFLOW" == 'snapshot' ]]; then
166+
assemble_version="$VERSION-SNAPSHOT"
167+
else
168+
assemble_version="$VERSION"
169+
fi
170+
171+
build_image
172+
echo -e "\033[34;1mINFO:\033[0m Building version ${assemble_version}\033[0m"
173+
docker run --rm --env VERSION=$assemble_version -u "$(id -u)" \
174+
$git_mount $src_mount $output_mount \
175+
$docker_image \
176+
publishForReleaseManager
177+
178+
if compgen -G ".ci/output/release/*" > /dev/null; then
179+
if [[ -n ${DEPENDENCIES_REPORTS_DIR+x} ]]; then
180+
cp .ci/output/release/dependencies.csv "$DEPENDENCIES_REPORTS_DIR"/"$DEPENDENCIES_REPORT"
181+
fi
182+
echo -e "\033[32;1mTARGET: successfully assembled client version $assemble_version\033[0m"
183+
else
184+
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
185+
exit 1
186+
fi
187+
fi
188+
189+
if [[ "$CMD" == "release" ]]; then
190+
rm -rf .ci/output/repository
191+
rm -rf signed-artifacts
192+
build_image
193+
echo -e "\033[34;1mINFO:\033[0m Building version ${VERSION}\033[0m"
194+
195+
if [[ "$DRY_RUN" = "true" ]]; then
196+
echo "Dry run: building and publishing to the local repository"
197+
gradle_task="publishForReleaseManager"
198+
else
199+
echo "Releasing to Maven repo"
200+
gradle_task="publishForMavenCentral"
201+
fi
202+
docker run --rm --env VERSION=$VERSION -u "$(id -u)" \
203+
$git_mount $src_mount $output_mount \
204+
-v /tmp/secured:/tmp/secured \
205+
$docker_image \
206+
$gradle_task
207+
208+
mkdir -p signed-artifacts/$VERSION
209+
cp .ci/output/repository/co/elastic/clients/elasticsearch-java/$VERSION/elasticsearch-java-${VERSION}-javadoc.jar signed-artifacts/$VERSION/elasticsearch-java-${VERSION}-javadoc.jar
210+
fi
211+
212+
if [[ "$CMD" == "bump" ]]; then
213+
echo $VERSION > config/version.txt
214+
fi
215+
216+
if [[ "$CMD" == "codegen" ]]; then
217+
echo "TODO"
218+
fi
219+
220+
if [[ "$CMD" == "docsgen" ]]; then
221+
echo "TODO"
222+
fi
223+
224+
if [[ "$CMD" == "examplesgen" ]]; then
225+
echo "TODO"
226+
fi

0 commit comments

Comments
 (0)