Skip to content

Commit 2c63b0b

Browse files
author
simone
committed
FIRST Commit
0 parents  commit 2c63b0b

17 files changed

+722
-0
lines changed

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

.mvn/wrapper/maven-wrapper.properties

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

Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:22-jdk
2+
3+
WORKDIR /app
4+
5+
COPY .mvn/ .mvn
6+
COPY mvnw pom.xml ./
7+
RUN ./mvnw dependency:go-offline
8+
9+
COPY src ./src
10+
11+
CMD ["./mvnw", "spring-boot:run"]

Readme.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Usefull command
2+
3+
minikube start
4+
docker build -t javaoperator .
5+
minikube image load javaoperator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: operator-role-binding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: operator-role
9+
subjects:
10+
- kind: ServiceAccount
11+
name: default
12+
namespace: operator-java

kubernetes-charts/operator-role.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: operator-role
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- events
10+
- pods
11+
verbs:
12+
- get
13+
- list
14+
- create
15+
- update
16+
- delete
17+
- apiGroups:
18+
- coordination.k8s.io
19+
resources:
20+
- leases
21+
verbs:
22+
- '*'
23+
- apiGroups:
24+
- intre.com
25+
resources:
26+
- sites
27+
verbs:
28+
- '*'
29+
- apiGroups:
30+
- intre.com
31+
resources:
32+
- sites/status
33+
verbs:
34+
- get
35+
- update
36+
- patch

kubernetes-charts/operator.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: javaoperator
5+
namespace: operator-java
6+
spec:
7+
containers:
8+
- name: javaoperator
9+
image: javaoperator:latest
10+
imagePullPolicy: Never

mvnw

+250
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
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+
# https://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+
# Apache Maven Wrapper startup batch script, version 3.3.1
23+
#
24+
# Optional ENV vars
25+
# -----------------
26+
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
27+
# MVNW_REPOURL - repo url base for downloading maven distribution
28+
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
29+
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
30+
# ----------------------------------------------------------------------------
31+
32+
set -euf
33+
[ "${MVNW_VERBOSE-}" != debug ] || set -x
34+
35+
# OS specific support.
36+
native_path() { printf %s\\n "$1"; }
37+
case "$(uname)" in
38+
CYGWIN* | MINGW*)
39+
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
40+
native_path() { cygpath --path --windows "$1"; }
41+
;;
42+
esac
43+
44+
# set JAVACMD and JAVACCMD
45+
set_java_home() {
46+
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
47+
if [ -n "${JAVA_HOME-}" ]; then
48+
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
49+
# IBM's JDK on AIX uses strange locations for the executables
50+
JAVACMD="$JAVA_HOME/jre/sh/java"
51+
JAVACCMD="$JAVA_HOME/jre/sh/javac"
52+
else
53+
JAVACMD="$JAVA_HOME/bin/java"
54+
JAVACCMD="$JAVA_HOME/bin/javac"
55+
56+
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
57+
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
58+
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
59+
return 1
60+
fi
61+
fi
62+
else
63+
JAVACMD="$(
64+
'set' +e
65+
'unset' -f command 2>/dev/null
66+
'command' -v java
67+
)" || :
68+
JAVACCMD="$(
69+
'set' +e
70+
'unset' -f command 2>/dev/null
71+
'command' -v javac
72+
)" || :
73+
74+
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
75+
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
76+
return 1
77+
fi
78+
fi
79+
}
80+
81+
# hash string like Java String::hashCode
82+
hash_string() {
83+
str="${1:-}" h=0
84+
while [ -n "$str" ]; do
85+
char="${str%"${str#?}"}"
86+
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
87+
str="${str#?}"
88+
done
89+
printf %x\\n $h
90+
}
91+
92+
verbose() { :; }
93+
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
94+
95+
die() {
96+
printf %s\\n "$1" >&2
97+
exit 1
98+
}
99+
100+
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
101+
while IFS="=" read -r key value; do
102+
case "${key-}" in
103+
distributionUrl) distributionUrl="${value-}" ;;
104+
distributionSha256Sum) distributionSha256Sum="${value-}" ;;
105+
esac
106+
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
107+
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
108+
109+
case "${distributionUrl##*/}" in
110+
maven-mvnd-*bin.*)
111+
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
112+
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
113+
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
114+
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
115+
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
116+
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
117+
*)
118+
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
119+
distributionPlatform=linux-amd64
120+
;;
121+
esac
122+
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
123+
;;
124+
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
125+
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
126+
esac
127+
128+
# apply MVNW_REPOURL and calculate MAVEN_HOME
129+
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
130+
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
131+
distributionUrlName="${distributionUrl##*/}"
132+
distributionUrlNameMain="${distributionUrlName%.*}"
133+
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
134+
MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
135+
136+
exec_maven() {
137+
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
138+
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
139+
}
140+
141+
if [ -d "$MAVEN_HOME" ]; then
142+
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
143+
exec_maven "$@"
144+
fi
145+
146+
case "${distributionUrl-}" in
147+
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
148+
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
149+
esac
150+
151+
# prepare tmp dir
152+
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
153+
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
154+
trap clean HUP INT TERM EXIT
155+
else
156+
die "cannot create temp dir"
157+
fi
158+
159+
mkdir -p -- "${MAVEN_HOME%/*}"
160+
161+
# Download and Install Apache Maven
162+
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
163+
verbose "Downloading from: $distributionUrl"
164+
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
165+
166+
# select .zip or .tar.gz
167+
if ! command -v unzip >/dev/null; then
168+
distributionUrl="${distributionUrl%.zip}.tar.gz"
169+
distributionUrlName="${distributionUrl##*/}"
170+
fi
171+
172+
# verbose opt
173+
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
174+
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
175+
176+
# normalize http auth
177+
case "${MVNW_PASSWORD:+has-password}" in
178+
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
179+
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
180+
esac
181+
182+
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
183+
verbose "Found wget ... using wget"
184+
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
185+
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
186+
verbose "Found curl ... using curl"
187+
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
188+
elif set_java_home; then
189+
verbose "Falling back to use Java to download"
190+
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
191+
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
192+
cat >"$javaSource" <<-END
193+
public class Downloader extends java.net.Authenticator
194+
{
195+
protected java.net.PasswordAuthentication getPasswordAuthentication()
196+
{
197+
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
198+
}
199+
public static void main( String[] args ) throws Exception
200+
{
201+
setDefault( new Downloader() );
202+
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
203+
}
204+
}
205+
END
206+
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
207+
verbose " - Compiling Downloader.java ..."
208+
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
209+
verbose " - Running Downloader.java ..."
210+
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
211+
fi
212+
213+
# If specified, validate the SHA-256 sum of the Maven distribution zip file
214+
if [ -n "${distributionSha256Sum-}" ]; then
215+
distributionSha256Result=false
216+
if [ "$MVN_CMD" = mvnd.sh ]; then
217+
echo "Checksum validation is not supported for maven-mvnd." >&2
218+
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
219+
exit 1
220+
elif command -v sha256sum >/dev/null; then
221+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
222+
distributionSha256Result=true
223+
fi
224+
elif command -v shasum >/dev/null; then
225+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
226+
distributionSha256Result=true
227+
fi
228+
else
229+
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
230+
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
231+
exit 1
232+
fi
233+
if [ $distributionSha256Result = false ]; then
234+
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
235+
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
236+
exit 1
237+
fi
238+
fi
239+
240+
# unzip and move
241+
if command -v unzip >/dev/null; then
242+
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
243+
else
244+
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
245+
fi
246+
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
247+
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
248+
249+
clean || :
250+
exec_maven "$@"

0 commit comments

Comments
 (0)