-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
target/ | ||
.idea | ||
project/project | ||
project/target | ||
.vscode | ||
metals.sbt | ||
.bloop | ||
.metals | ||
.bsp | ||
.openapi-generator | ||
generated/src/ | ||
client/src/ | ||
openapitools.json | ||
.DS_Store | ||
client/project/build.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
|
||
build.sbt | ||
project/plugins.sbt | ||
project/build.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version = 2.7.5 | ||
style = defaultWithAlign | ||
maxColumn = 120 | ||
align.openParenCallSite = false | ||
align.openParenDefnSite = false | ||
danglingParentheses.preset = true | ||
assumeStandardLibraryStripMargin = true | ||
continuationIndent.callSite = 2 | ||
continuationIndent.defnSite = 2 | ||
optIn.configStyleArguments = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
pipeline { | ||
|
||
agent none | ||
|
||
stages { | ||
|
||
stage('Initialize') { | ||
agent { label 'sbt-template' } | ||
environment { | ||
PDND_TRUST_STORE_PSW = credentials('pdnd-interop-trust-psw') | ||
} | ||
steps { | ||
withCredentials([file(credentialsId: 'pdnd-interop-trust-cert', variable: 'pdnd_certificate')]) { | ||
sh ''' | ||
cat \$pdnd_certificate > gateway.interop.pdnd.dev.cer | ||
keytool -import -file gateway.interop.pdnd.dev.cer -alias pdnd-interop-gateway -keystore PDNDTrustStore -storepass ${PDND_TRUST_STORE_PSW} -noprompt | ||
cp $JAVA_HOME/jre/lib/security/cacerts main_certs | ||
keytool -importkeystore -srckeystore main_certs -destkeystore PDNDTrustStore -srcstorepass ${PDND_TRUST_STORE_PSW} -deststorepass ${PDND_TRUST_STORE_PSW} | ||
''' | ||
stash includes: "PDNDTrustStore", name: "pdnd_trust_store" | ||
} | ||
} | ||
} | ||
|
||
stage('Deploy DAGS') { | ||
agent { label 'sbt-template' } | ||
environment { | ||
NEXUS = 'gateway.interop.pdnd.dev' | ||
NEXUS_CREDENTIALS = credentials('pdnd-nexus') | ||
PDND_TRUST_STORE_PSW = credentials('pdnd-interop-trust-psw') | ||
} | ||
steps { | ||
container('sbt-container') { | ||
unstash "pdnd_trust_store" | ||
script { | ||
|
||
sh ''' | ||
curl -sL https://deb.nodesource.com/setup_10.x | bash - | ||
apt-get install -y nodejs | ||
npm install @openapitools/openapi-generator-cli -g | ||
openapi-generator-cli version | ||
curl -fsSL https://get.docker.com -o get-docker.sh | ||
sh get-docker.sh | ||
docker login $NEXUS -u $NEXUS_CREDENTIALS_USR -p $NEXUS_CREDENTIALS_PSW | ||
''' | ||
|
||
sh '''#!/bin/bash | ||
export DOCKER_REPO=$NEXUS | ||
export MAVEN_REPO=${NEXUS} | ||
echo "realm=Sonatype Nexus Repository Manager\nhost=${NEXUS}\nuser=${NEXUS_CREDENTIALS_USR}\npassword=${NEXUS_CREDENTIALS_PSW}" > /home/sbtuser/.sbt/.credentials | ||
sbt -Djavax.net.ssl.trustStore=./PDNDTrustStore -Djavax.net.ssl.trustStorePassword=${PDND_TRUST_STORE_PSW} generateCode "project root" docker:publish | ||
''' | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Apply Kubernetes files') { | ||
agent { label 'sbt-template' } | ||
environment { | ||
CASSANDRA = credentials('cassandra-db') | ||
CASSANDRA_HOST = 'cluster1-dc1-service.cassandra-operator.svc.cluster.local:9042' | ||
DOCKER_REPO = 'gateway.interop.pdnd.dev' | ||
//REPLICAS_NR = 1 | ||
} | ||
steps{ | ||
// we should use a container with kubectl preinstalled | ||
container('sbt-container') { | ||
withKubeConfig([credentialsId: 'kube-config']) { | ||
sh ''' | ||
cd kubernetes | ||
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" | ||
chmod u+x ./kubectl | ||
chmod u+x undeploy.sh | ||
chmod u+x deploy.sh | ||
cp kubectl /usr/local/bin/ | ||
./undeploy.sh | ||
./deploy.sh | ||
''' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
ThisBuild / scalaVersion := "2.13.5" | ||
ThisBuild / organization := "it.pagopa" | ||
ThisBuild / organizationName := "Pagopa S.p.A." | ||
ThisBuild / libraryDependencies := Dependencies.Jars.`server`.map(m => | ||
if (scalaVersion.value.startsWith("3.0")) | ||
m.withDottyCompat(scalaVersion.value) | ||
else | ||
m | ||
) | ||
ThisBuild / dependencyOverrides ++= Dependencies.Jars.overrides | ||
ThisBuild / version := "0.1.0-SNAPSHOT" | ||
|
||
ThisBuild / resolvers += "Pagopa Nexus Snapshots" at s"https://gateway.interop.pdnd.dev/nexus/repository/maven-snapshots/" | ||
ThisBuild / resolvers += "Pagopa Nexus Releases" at s"https://gateway.interop.pdnd.dev/nexus/repository/maven-releases/" | ||
|
||
credentials += Credentials(Path.userHome / ".sbt" / ".credentials") | ||
|
||
lazy val generateCode = taskKey[Unit]("A task for generating the code starting from the swagger definition") | ||
|
||
generateCode := { | ||
import sys.process._ | ||
|
||
val packagePrefix = name.value | ||
.replaceFirst("pdnd-", "pdnd.") | ||
.replaceFirst("interop-", "interop.") | ||
.replaceFirst("uservice-", "uservice.") | ||
.replaceAll("-", "") | ||
|
||
Process(s"""openapi-generator-cli generate -t template/scala-akka-http-server | ||
| -i src/main/resources/interface-specification.yml | ||
| -g scala-akka-http-server | ||
| -p projectName=${name.value} | ||
| -p invokerPackage=it.pagopa.${packagePrefix}.server | ||
| -p modelPackage=it.pagopa.${packagePrefix}.model | ||
| -p apiPackage=it.pagopa.${packagePrefix}.api | ||
| -p dateLibrary=java8 | ||
| -o generated""".stripMargin).!! | ||
|
||
Process(s"""openapi-generator-cli generate -t template/scala-akka-http-client | ||
| -i src/main/resources/interface-specification.yml | ||
| -g scala-akka | ||
| -p projectName=${name.value} | ||
| -p invokerPackage=it.pagopa.${packagePrefix}.client.invoker | ||
| -p modelPackage=it.pagopa.${packagePrefix}.client.model | ||
| -p apiPackage=it.pagopa.${packagePrefix}.client.api | ||
| -p dateLibrary=java8 | ||
| -o client""".stripMargin).!! | ||
|
||
} | ||
|
||
(compile in Compile) := ((compile in Compile) dependsOn generateCode).value | ||
|
||
cleanFiles += baseDirectory.value / "generated" / "src" | ||
|
||
cleanFiles += baseDirectory.value / "client" / "src" | ||
|
||
lazy val generated = project | ||
.in(file("generated")) | ||
.settings(scalacOptions := Seq()) | ||
|
||
lazy val client = project | ||
.in(file("client")) | ||
.settings( | ||
name := "pdnd-interop-uservice-agreement-process-client", | ||
scalacOptions := Seq(), | ||
libraryDependencies := Dependencies.Jars.client.map(m => | ||
if (scalaVersion.value.startsWith("3.0")) | ||
m.withDottyCompat(scalaVersion.value) | ||
else | ||
m | ||
), | ||
credentials += Credentials(Path.userHome / ".sbt" / ".credentials"), | ||
updateOptions := updateOptions.value.withGigahorse(false), | ||
publishTo := { | ||
val nexus = s"https://${System.getenv("MAVEN_REPO")}/nexus/repository/" | ||
|
||
if (isSnapshot.value) | ||
Some("snapshots" at nexus + "maven-snapshots/") | ||
else | ||
Some("releases" at nexus + "maven-releases/") | ||
} | ||
) | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
name := "pdnd-interop-uservice-agreement-process", | ||
Test / parallelExecution := false, | ||
dockerBuildOptions ++= Seq("--network=host"), | ||
dockerRepository := Some(System.getenv("DOCKER_REPO")), | ||
dockerBaseImage := "adoptopenjdk:11-jdk-hotspot", | ||
dockerUpdateLatest := true, | ||
daemonUser := "daemon", | ||
Docker / version := (ThisBuild / version).value, | ||
Docker / packageName := s"services/${name.value}", | ||
Docker / dockerExposedPorts := Seq(8080), | ||
Compile / compile / wartremoverErrors ++= Warts.all, | ||
wartremoverExcluded += sourceManaged.value, | ||
scalafmtOnCompile := true | ||
) | ||
.aggregate(client) | ||
.dependsOn(generated) | ||
.enablePlugins(JavaAppPackaging, JavaAgent) | ||
|
||
//javaAgents += "io.kamon" % "kanela-agent" % "1.0.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
build.sbt | ||
pom.xml | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
build.sbt | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
SCRIPT_PATH="${BASH_SOURCE[0]}"; | ||
if ([ -h "${SCRIPT_PATH}" ]) then | ||
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done | ||
fi | ||
pushd . > /dev/null | ||
cd `dirname ${SCRIPT_PATH}` > /dev/null | ||
SCRIPT_PATH=`pwd`; | ||
popd > /dev/null | ||
repository=$DOCKER_REPO | ||
|
||
name=$(cat $SCRIPT_PATH/../build.sbt | grep "name :=" | awk -F:= '{ print $2 }' | sed 's/\"//' | sed 's/\",//' | sed 's/ //' | tr '[:upper:]' '[:lower:]' | grep -v client ) | ||
version=$(cat $SCRIPT_PATH/../build.sbt | grep "ThisBuild / version := " | awk -F:= '{ print $2 }' | sed 's/ //' | sed 's/"//' | sed 's/"//' | uniq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
SCRIPT_PATH="${BASH_SOURCE[0]}"; | ||
if ([ -h "${SCRIPT_PATH}" ]) then | ||
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done | ||
fi | ||
pushd . > /dev/null | ||
cd `dirname ${SCRIPT_PATH}` > /dev/null | ||
SCRIPT_PATH=`pwd`; | ||
popd > /dev/null | ||
|
||
NAMESPACE=$(source $SCRIPT_PATH/config; echo $name) | ||
|
||
kubectl create namespace $NAMESPACE | ||
|
||
kubectl get secret regcred -n default -o yaml | sed s/"namespace: default"/"namespace: $NAMESPACE"/ | kubectl apply -n $NAMESPACE -f - | ||
|
||
kubectl create secret generic cassandra --from-literal=CASSANDRA_HOST=$CASSANDRA_HOST --from-literal=CASSANDRA_USER=$CASSANDRA_USR --from-literal=CASSANDRA_PWD=$CASSANDRA_PSW -n $NAMESPACE | ||
|
||
kubectl create secret generic application.conf --from-file=application.conf=$SCRIPT_PATH/../src/main/resources/application.conf -n $NAMESPACE | ||
|
||
$SCRIPT_PATH/templater.sh $SCRIPT_PATH/deployment.yaml.template -s -f $SCRIPT_PATH/config > $SCRIPT_PATH/deployment.yaml | ||
|
||
kubectl create -f $SCRIPT_PATH/deployment.yaml && rm -rf $SCRIPT_PATH/deployment.yaml |
Oops, something went wrong.