diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a5090209307999795ef86a59bb37cd1cb82df13..7e312c6674f899758032ed003575f2e6f5ab7af8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,13 +16,6 @@ variables: MONGODB_AWS_EKS_DEPLOYMENT_NAME: os-legal MONGODB_AWS_DEPLOY_TARGET: TF - GCP_BUILD_SUBDIR: provider/legal-gcp - GCP_INT_TEST_SUBDIR: testing/legal-test-gcp - GCP_APPLICATION_NAME: os-legal - GCP_ENVIRONMENT: testing - GCP_PROJECT: opendes-evt - GCP_TENANT_NAME: opendes-evt - IBM_BUILD_SUBDIR: provider/legal-ibm IBM_INT_TEST_SUBDIR: testing/legal-test-ibm @@ -74,6 +67,9 @@ include: - project: "osdu/platform/ci-cd-pipelines" file: "cloud-providers/gc-global.yml" + - project: "osdu/platform/ci-cd-pipelines" + file: "cloud-providers/core-global.yml" + - project: "osdu/platform/ci-cd-pipelines" file: "publishing/pages.yml" @@ -83,7 +79,7 @@ include: .maven: image: maven:3.8.3-openjdk-17-slim - tags: ['osdu-medium'] + tags: ["osdu-medium"] variables: MAVEN_REPO_PATH: "$CI_PROJECT_DIR/.m2/repository" MAVEN_CLI_OPTS: "--batch-mode --settings=$CI_PROJECT_DIR/.mvn/community-maven.settings.xml" @@ -145,7 +141,6 @@ include: sys.stdout.write(dir + '\0') EOF - xargs -0rn 1 echo < $ALL_MAVEN_BUILD_DIRS_Z - # This creates a script for running maven, capturing output to a file. # - First argument is the directory to build from # - Second argument is the name to use for the logfile @@ -203,10 +198,10 @@ download_plugins: only: variables: - - $PROTECTED == '1' - + - $CORE == '1' + gemnasium-maven-dependency_scanning: - variables: + variables: DS_JAVA_VERSION: 17 azure_containerize: @@ -223,7 +218,7 @@ aws-test-java: # image: $CI_REGISTRY/osdu/platform/deployment-and-operations/base-containers-aws/aws-maven/aws-maven:v2.0 fossa-analyze: - image: $CI_REGISTRY/divido/fossa-with-cache:v0.9-jdk17 - + image: $CI_REGISTRY/divido/fossa-with-cache:v0.9-jdk17 + fossa-check-notice: - image: $CI_REGISTRY/divido/fossa-with-cache:v0.9-jdk17 + image: $CI_REGISTRY/divido/fossa-with-cache:v0.9-jdk17 diff --git a/devops/core-plus/bootstrap_legalstatus_update/Dockerfile b/devops/core-plus/bootstrap_legalstatus_update/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a463cacfaff2b3ebeb6b835b9e283823b9eb13a1 --- /dev/null +++ b/devops/core-plus/bootstrap_legalstatus_update/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:latest +WORKDIR /opt +RUN apk update && \ + apk add --no-cache bash jq +COPY ./devops/core-plus/bootstrap_legalstatus_update/ /opt/ +RUN chmod +x update_legal_status.sh validate-env.sh +RUN addgroup -g 10001 -S nonroot \ + && adduser -h /opt -G nonroot -S -u 10001 nonroot +RUN chown -R 10001:10001 /opt +USER 10001:10001 +CMD ["/bin/bash", "-c", "./update_legal_status.sh"] diff --git a/devops/core-plus/bootstrap_legalstatus_update/update_legal_status.sh b/devops/core-plus/bootstrap_legalstatus_update/update_legal_status.sh new file mode 100644 index 0000000000000000000000000000000000000000..7c321fa8fe91cfc4ecb0436beda34e7a17998aae --- /dev/null +++ b/devops/core-plus/bootstrap_legalstatus_update/update_legal_status.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# The following script is intended for regular triggering of legal status update +# +# Expected variables: +## Common: +# - LEGAL_HOST +# - DATA_PARTITION_ID +## Baremetal: +# - OPENID_PROVIDER_URL +# - OPENID_PROVIDER_CLIENT_ID +# - OPENID_PROVIDER_CLIENT_SECRET + +set -ex + +get_token() { + # id token + TOKEN="$(curl --location --silent --globoff --request POST "${OPENID_PROVIDER_URL}/protocol/openid-connect/token" \ + --header "Content-Type: application/x-www-form-urlencoded" \ + --data-urlencode "grant_type=client_credentials" \ + --data-urlencode "scope=openid" \ + --data-urlencode "client_id=${OPENID_PROVIDER_CLIENT_ID}" \ + --data-urlencode "client_secret=${OPENID_PROVIDER_CLIENT_SECRET}" | jq -r ".id_token")" + export TOKEN +} + +update_legal_status() { + + DATA_PARTITION_ID=$1 + + status_code=$(curl --location --globoff --request GET "${LEGAL_HOST}/api/legal/v1/jobs/updateLegalTagStatus" \ + --write-out "%{http_code}" --silent --output "output.txt" \ + --header "data-partition-id: ${DATA_PARTITION_ID}" \ + --header "Authorization: Bearer ${TOKEN}") + + if [ "$status_code" == 204 ]; then + echo "Legal status update completed successfully!" + else + echo "Legal status update failed!" + cat /opt/output.txt | jq + exit 1 + fi + +} + +# Check variables +source ./validate-env.sh "PARTITION_HOST" +source ./validate-env.sh "LEGAL_HOST" +source ./validate-env.sh "OPENID_PROVIDER_URL" +source ./validate-env.sh "OPENID_PROVIDER_CLIENT_ID" +source ./validate-env.sh "OPENID_PROVIDER_CLIENT_SECRET" + +# Get list of partitions +status_code=$(curl --location --request GET \ + --url "${PARTITION_HOST}/api/partition/v1/partitions" \ + --write-out "%{http_code}" --silent --output "output.txt") + +if [ "$status_code" == 200 ]; then + partitions=$(cat /opt/output.txt | xargs) # unquote + partitions=${partitions:1:-1} # remove [] + IFS=',' read -ra PARTITIONS <<<"${partitions}," # append ',' for single partition case +else + echo "$status_code: Partition service is not available" + cat /opt/output.txt + exit 1 +fi + +# Update legal status for all partitions +for PARTITION in "${PARTITIONS[@]}"; do + if [[ "$PARTITION" == "system" ]]; then + continue + fi + get_token + update_legal_status "${PARTITION}" +done + +# cleanly exit envoy if present +set +e +curl -X POST http://localhost:15000/quitquitquit +set -e + +exit 0 diff --git a/devops/core-plus/bootstrap_legalstatus_update/validate-env.sh b/devops/core-plus/bootstrap_legalstatus_update/validate-env.sh new file mode 100644 index 0000000000000000000000000000000000000000..9de17ff4a83b4e297bba6aec875088dd313c416b --- /dev/null +++ b/devops/core-plus/bootstrap_legalstatus_update/validate-env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +{ set +x ;} 2> /dev/null # disable output to prevent secret logging +set -e + +ENV_VAR_NAME=$1 + +if [ "${!ENV_VAR_NAME}" = "" ] +then + echo "Missing environment variable '$ENV_VAR_NAME'. Please provide all variables and try again" + { set -x ;} 2> /dev/null # enable output back + exit 1 +fi + +{ set -x ;} 2> /dev/null # enable output back diff --git a/devops/core-plus/deploy/Chart.yaml b/devops/core-plus/deploy/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1309a69a452385c9d1fff96709b9704cad18ae84 --- /dev/null +++ b/devops/core-plus/deploy/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: core-plus-legal-deploy +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.19.0" diff --git a/devops/core-plus/deploy/README.md b/devops/core-plus/deploy/README.md new file mode 100644 index 0000000000000000000000000000000000000000..88c9256e0cd103dec65979c6603b596a3882145d --- /dev/null +++ b/devops/core-plus/deploy/README.md @@ -0,0 +1,168 @@ +<!--- Deploy --> + +# Deploy helm chart + +## Introduction + +This chart bootstraps a deployment on a [Kubernetes](https://kubernetes.io) cluster using [Helm](https://helm.sh) package manager. + +## Prerequisites + +The code was tested on **Kubernetes cluster** (v1.21.11) with **Istio** (1.12.6) + > Istio is installed with Istio Ingress Gateway + +- Kubernetes cluster version can be checked with the command: + + `kubectl version --short | grep Server` + + The output will be similar to the following: + + ```console + Server Version: v1.21.11-gke.1100 + ``` + +- Istio version can be checked in different ways, it is out of scope for this README. You can find more information [here](https://istio.io/latest/docs/setup/install/). + + The following command shows how to check version if Anthos Service Mesh is used: + + `kubectl -n istio-system get pods -lapp=istiod -o=jsonpath='{.items[0].metadata.labels.istio\.io/rev}'` + + The output will be similar to the following: + + ```console + asm-1132-5 + ``` + +> It is possible to use other versions, but it hasn't been tested + +This example describes installation in **Development mode**: + +- In this mode helm chart is installed to the namespace **not labeled with Istio**. + > More information about labeling can be found [here](https://istio.io/latest/docs/setup/additional-setup/sidecar-injection) (Istio) or [here](https://cloud.google.com/service-mesh/docs/managed/select-a-release-channel#default-injection-labels) (Anthos Service Mesh) + + You can find all labels for your namespace with the command: + + `kubectl get namespace <namespace> -o jsonpath={.metadata.labels}` + + The output shows that there are no any labels related to Istio: + + ```console + {"kubernetes.io/metadata.name":"default"} + ``` + + When the namespace is labeled with Istio, the output could be: + + ```console + {"istio-injection":"enabled","kubernetes.io/metadata.name":"default"} + ``` + +### Operation system + +The code works in Debian-based Linux (Debian 10 and Ubuntu 20.04) and Windows WSL 2. Also, it works but is not guaranteed in Google Cloud Shell. All other operating systems, including macOS, are not verified and supported. + +### Packages + +Packages are only needed for installation from a local computer. + +- **HELM** (version: v3.7.1 or higher) [helm](https://helm.sh/docs/intro/install/) + + Helm version can be checked with the command: + + `helm version --short` + + The output will be similar to the following: + + ```console + v3.7.1+gd141386 + ``` + +- **Kubectl** (version: v1.21.0 or higher) [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) + + Kubectl version can be checked with the command: + + `kubectl version --short | grep Client` + + The output will be similar to the following: + + ```console + Client Version: v1.21.0 + ``` + +## Installation + +First you need to set variables in **values.yaml** file using any code editor. Some of the values are prefilled, but you need to specify some values as well. You can find more information about them below. + +### Global variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**global.domain** | your domain for the external endpoint, ex `example.com` | string | - | yes +**global.limitsEnabled** | whether CPU and memory limits are enabled | boolean | true | yes + +### Configmap variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**data.logLevel** | logging level | string | ERROR | yes +**data.acceptHttp** | accept Http traffic | string | true | yes +**data.dataPartitionId** | data partition id | string | - | yes +**data.entitlementsHost** | Entitlements host URL | string | <http://entitlements> | yes +**data.defaultLegalTag** | Default legal tag | string | default-data-tag| yes +**data.legalHost** | Legal host URL | string | <http://legal> | yes + +### Deployment variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**data.requestsCpu** | amount of requests CPU | string | 10m | yes +**data.requestsMemory** | amount of requests memory| string | 550Mi | yes +**data.limitsCpu** | CPU limit | string | 1 | only if `global.limitsEnabled` is true +**data.limitsMemory** | memory limit | string | 1G | only if `global.limitsEnabled` is true +**data.bootstrapServiceAccountName** | name of the service account used in cronjob | string | - | yes +**data.serviceAccountName** | name of your service account | string | legal | yes +**data.imagePullPolicy** | when to pull the image | string | IfNotPresent | yes +**data.image** | path to the image in a registry | string | - | yes + +### Configuration variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**conf.configmap** | configmap to be used | string | legal-config | yes +**conf.appName** | name of the app | string | legal | yes +**conf.minioSecretName** | Secret name for minio service | string | legal-minio-secret | yes +**conf.postgresSecretName** | Secret name for postgres service | string | legal-postgres-secret | yes +**conf.rabbitmqSecretName** | Secret name for rabbitmq service | string | rabbitmq-secret | yes +**conf.bootstrapSecretName** | Secret name for cronjob | string | datafier-secret | yes + +### Istio variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**istio.proxyCPU** | CPU request for Envoy sidecars | string | `10m` | yes +**istio.proxyCPULimit** | CPU limit for Envoy sidecars | string | `500m` | yes +**istio.proxyMemory** | memory request for Envoy sidecars | string | `100Mi` | yes +**istio.proxyMemoryLimit** | memory limit for Envoy sidecars | string | `512Mi` | yes + +### Install the helm chart + +Run this command from within this directory: + +```console +helm install core-plus-legal-deploy . +``` + +## Uninstalling the Chart + +To uninstall the helm deployment: + +```console +helm uninstall core-plus-legal-deploy +``` + +To delete secrets and PVCs: + +```console +kubectl delete secret --all; kubectl delete pvc --all +``` + +[Move-to-Top](#deploy-helm-chart) diff --git a/devops/core-plus/deploy/templates/legal-configmap.yaml b/devops/core-plus/deploy/templates/legal-configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a9516cb5f1d3437fa0a4e4c67f1242f0544558bd --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app: {{ .Values.conf.appName | quote }} + name: {{ .Values.conf.configmap | quote }} + namespace: {{ .Release.Namespace | quote }} +data: + ACCEPT_HTTP: {{ .Values.data.acceptHttp | quote }} + LOG_LEVEL: {{ .Values.data.logLevel | quote }} diff --git a/devops/core-plus/deploy/templates/legal-deploy.yaml b/devops/core-plus/deploy/templates/legal-deploy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a24f78e589d895b00854408e67fe8b53ade4abfb --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-deploy.yaml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: {{ .Values.conf.appName | quote }} + name: {{ .Values.conf.appName | quote }} + namespace: {{ .Release.Namespace | quote }} +spec: + selector: + matchLabels: + app: {{ .Values.conf.appName | quote }} + replicas: {{ .Values.conf.replicas }} + template: + metadata: + labels: + app: {{ .Values.conf.appName | quote }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} + sidecar.istio.io/proxyCPU: {{ .Values.istio.proxyCPU | quote }} + sidecar.istio.io/proxyMemory: {{ .Values.istio.proxyMemory | quote }} + sidecar.istio.io/proxyCPULimit: {{ .Values.istio.proxyCPULimit | quote }} + sidecar.istio.io/proxyMemoryLimit: {{ .Values.istio.proxyMemoryLimit | quote }} + spec: + containers: + - name: {{ .Values.conf.appName | quote }} + image: {{ .Values.data.image | quote }} + imagePullPolicy: {{ .Values.data.imagePullPolicy | quote }} + envFrom: + - configMapRef: + name: {{ .Values.conf.configmap | quote }} + - secretRef: + name: {{ .Values.conf.minioSecretName | quote }} + - secretRef: + name: {{ .Values.conf.postgresSecretName | quote }} + - secretRef: + name: {{ .Values.conf.rabbitmqSecretName | quote }} + securityContext: + allowPrivilegeEscalation: false + runAsNonRoot: true + ports: + - containerPort: 8080 + livenessProbe: + failureThreshold: 3 + httpGet: + path: api/legal/v1/_ah/liveness_check + port: 8080 + initialDelaySeconds: 120 + periodSeconds: 10 + resources: + requests: + cpu: {{ .Values.data.requestsCpu | quote }} + memory: {{ .Values.data.requestsMemory | quote }} + {{- if .Values.global.limitsEnabled }} + limits: + cpu: {{ .Values.data.limitsCpu | quote }} + memory: {{ .Values.data.limitsMemory | quote }} + {{- end }} + serviceAccountName: {{ .Values.data.serviceAccountName | quote }} diff --git a/devops/core-plus/deploy/templates/legal-service-account.yaml b/devops/core-plus/deploy/templates/legal-service-account.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3df3488af53132feab774393efdac29a6f6315ee --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-service-account.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.data.serviceAccountName | quote }} + namespace: {{ .Release.Namespace | quote }} diff --git a/devops/core-plus/deploy/templates/legal-service.yaml b/devops/core-plus/deploy/templates/legal-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..75c3ce6d96f5d98093e20531365242026a648e67 --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.conf.appName | quote }} + namespace: {{ .Release.Namespace | quote }} + labels: + app: {{ .Values.conf.appName | quote }} + service: {{ .Values.conf.appName | quote }} +spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + name: http + selector: + app: {{ .Values.conf.appName | quote }} diff --git a/devops/core-plus/deploy/templates/legal-status-update-configmap.yaml b/devops/core-plus/deploy/templates/legal-status-update-configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cbbab92737ccae739f5445cdca5dd78dc22ac4f4 --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-status-update-configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ printf "%s-status-update" .Values.conf.configmap | quote }} + namespace: {{ .Release.Namespace | quote }} +data: + LEGAL_HOST: {{ .Values.data.legalHost | quote }} + PARTITION_HOST: {{ .Values.data.partitionHost | quote }} diff --git a/devops/core-plus/deploy/templates/legal-virtual-service.yaml b/devops/core-plus/deploy/templates/legal-virtual-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8f4d3fbdf36095f3082bd5587e8287a42a387f15 --- /dev/null +++ b/devops/core-plus/deploy/templates/legal-virtual-service.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ .Values.conf.appName | quote }} + namespace: {{ .Release.Namespace | quote }} +spec: + hosts: + - {{ printf "osdu.%s" .Values.global.domain | quote }} + gateways: + - service-gateway + http: + - match: + - uri: + prefix: "/api/legal" + route: + - destination: + port: + number: 80 + host: {{ printf "%s.%s.svc.cluster.local" .Values.conf.appName .Release.Namespace | quote }} diff --git a/devops/core-plus/deploy/values.yaml b/devops/core-plus/deploy/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9246f51c4bd100f0dc998960fa52f7461860f948 --- /dev/null +++ b/devops/core-plus/deploy/values.yaml @@ -0,0 +1,41 @@ +# Default values for legal-deploy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + domain: "" + limitsEnabled: true + +data: + # configmaps + logLevel: "ERROR" + acceptHttp: "true" + entitlementsHost: "http://entitlements" + defaultLegalTag: "default-data-tag" + legalHost: "http://legal" + partitionHost: "http://partition" + # deployments + requestsCpu: "5m" + requestsMemory: "325Mi" + limitsCpu: "1" + limitsMemory: "1G" + legalStatusUpdateImage: "" + bootstrapServiceAccountName: "" + serviceAccountName: "legal" + imagePullPolicy: "IfNotPresent" + image: "" + +conf: + configmap: "legal-config" + appName: "legal" + minioSecretName: "legal-minio-secret" + postgresSecretName: "legal-postgres-secret" + rabbitmqSecretName: "rabbitmq-secret" + bootstrapSecretName: "datafier-secret" + replicas: 1 + +istio: + proxyCPU: "5m" + proxyCPULimit: "500m" + proxyMemory: "50Mi" + proxyMemoryLimit: "512Mi" diff --git a/devops/core-plus/pipeline/override-stages.yml b/devops/core-plus/pipeline/override-stages.yml index b2daee9715646f10ef80e50d6601ab1c5b442d8f..194b53214ebcf1fbe4fde7e7bf24722e6514ab3a 100644 --- a/devops/core-plus/pipeline/override-stages.yml +++ b/devops/core-plus/pipeline/override-stages.yml @@ -1,138 +1,52 @@ -.set_image_name: +variables: + CORE_SERVICE: legal + CORE_LEGALSTATUS_IMAGE_NAME: legal-status-update + +.core_set_image_name: script: - > if echo $CI_COMMIT_REF_NAME | grep -Eq "^release\/[0-9]{1,2}.[0-9]{1,2}$"; then - export IMAGE_NAME=$IMAGE_NAME-release; - export IMAGE_BOOTSTRAP_NAME=$IMAGE_BOOTSTRAP_NAME-release; - export GC_LEGALSTATUS_IMAGE_NAME=$GC_LEGALSTATUS_IMAGE_NAME-release; + export CORE_IMAGE_NAME=$CORE_IMAGE_NAME-release; + export CORE_IMAGE_BOOTSTRAP_NAME=$CORE_IMAGE_BOOTSTRAP_NAME-release; + export CORE_LEGALSTATUS_IMAGE_NAME=$CORE_LEGALSTATUS_IMAGE_NAME-release; fi - > if [[ "$CI_COMMIT_REF_NAME" == "$CI_DEFAULT_BRANCH" ]]; then - export IMAGE_NAME=$IMAGE_NAME-master; - export IMAGE_BOOTSTRAP_NAME=$IMAGE_BOOTSTRAP_NAME-master; - export GC_LEGALSTATUS_IMAGE_NAME=$GC_LEGALSTATUS_IMAGE_NAME-master; + export CORE_IMAGE_NAME=$CORE_IMAGE_NAME-master; + export CORE_IMAGE_BOOTSTRAP_NAME=$CORE_IMAGE_BOOTSTRAP_NAME-master; + export CORE_LEGALSTATUS_IMAGE_NAME=$CORE_LEGALSTATUS_IMAGE_NAME-master; fi - > if [[ "$CI_COMMIT_TAG" != "" ]]; then - IMAGE_TAG="$CI_COMMIT_TAG"; - EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_TAG"; - EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_TAG"; + CORE_IMAGE_TAG="$CI_COMMIT_TAG"; + CORE_EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_NAME:$CI_COMMIT_TAG"; + CORE_EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_TAG"; elif [[ "$CI_COMMIT_REF_NAME" == "$CI_DEFAULT_BRANCH" ]]; then - IMAGE_TAG="$CI_COMMIT_SHORT_SHA"; - HELM_TAG="latest" - EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest"; - EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/$IMAGE_BOOTSTRAP_NAME:latest"; + CORE_IMAGE_TAG="$CI_COMMIT_SHORT_SHA"; + CORE_HELM_TAG="latest" + CORE_EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_NAME:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/$CORE_IMAGE_NAME:latest"; + CORE_EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/$CORE_IMAGE_BOOTSTRAP_NAME:latest"; else - IMAGE_TAG="$CI_COMMIT_SHORT_SHA"; - HELM_TAG="gc$CI_COMMIT_SHORT_SHA" - EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA"; - EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_SHORT_SHA"; + CORE_IMAGE_TAG="$CI_COMMIT_SHORT_SHA"; + CORE_HELM_TAG="core$CI_COMMIT_SHORT_SHA" + CORE_EXTRA_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_NAME:$CI_COMMIT_SHORT_SHA"; + CORE_EXTRA_BOOTSTRAP_TAG="-t $CI_REGISTRY_IMAGE/$CORE_IMAGE_BOOTSTRAP_NAME:$CI_COMMIT_SHORT_SHA"; fi -.substitute_image_in_helm: +.core_substitute_image_in_helm: script: - wget -q https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq - - IMAGE="$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" yq -i '.data.image = env(IMAGE)' $GC_HELM_DEPLOYMENT_DIR/values.yaml - - yq -e '.data | has("bootstrapImage")' $GC_HELM_DEPLOYMENT_DIR/values.yaml &>/dev/null && BOOTSTRAP_IMAGE="$CI_REGISTRY_IMAGE/$IMAGE_BOOTSTRAP_NAME:$IMAGE_TAG" yq -i '.data.bootstrapImage = env(BOOTSTRAP_IMAGE)' $GC_HELM_DEPLOYMENT_DIR/values.yaml - - LEGALSTATUS_UPDATE_IMAGE="$CI_REGISTRY_IMAGE/$GC_LEGALSTATUS_IMAGE_NAME:$IMAGE_TAG" yq -i '.data.legalStatusUpdateImage = env(LEGALSTATUS_UPDATE_IMAGE)' $GC_HELM_DEPLOYMENT_DIR/values.yaml - - cat $GC_HELM_DEPLOYMENT_DIR/values.yaml | grep -i image - -gc-containerize-gitlab:core-plus: - stage: containerize - needs: - - "compile-and-unit-test" - - "download_plugins" - tags: ["osdu-small"] - image: docker:19.03 - cache: {} - variables: - BUILD_ARGS: "--build-arg PORT=$GC_PORT" - BUILD_PATH: "provider/legal-core-plus/cloudbuild/Dockerfile" - IMAGE_NAME: "legal-core-plus" - script: - - !reference [.set_image_name, script] - - docker build $EXTRA_TAG -f $BUILD_PATH $BUILD_ARGS . - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME - rules: - - if: "$CI_COMMIT_BRANCH =~ /^release/" - when: never - - if: "$CI_COMMIT_TAG" - when: never - - if: "$PROTECTED == '1'" - when: on_success - -gc-helm-charts-gitlab:core-plus: - stage: containerize - tags: ["osdu-small"] - needs: ["gc-containerize-gitlab:core-plus"] - image: - name: alpine/helm:3.11.2 - entrypoint: [""] - variables: - IMAGE_NAME: "legal-core-plus" - before_script: - - helm registry login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - !reference [.set_image_name, script] - - !reference [.substitute_image_in_helm, script] - script: - - !reference [.gc_define_app_version, script] - - helm package $GC_HELM_DEPLOYMENT_DIR -u --version $GC_HELM_PACKAGE_VERSION-$HELM_TAG --app-version $APP_VERSION - - helm push $GC_HELM_PACKAGE_NAME-$GC_HELM_PACKAGE_VERSION-$HELM_TAG.tgz oci://$CI_REGISTRY_IMAGE/core-plus-helm - rules: - - if: "$CI_COMMIT_BRANCH =~ /^release/" - when: never - - if: "$CI_COMMIT_TAG" - when: never - - if: "$PROTECTED == '1'" - when: on_success - -gc-baremetal-deploy: - environment: - name: Google_Cloud - extends: .gc-baremetal-variables - tags: ["osdu-small"] - image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine - stage: deploy - needs: - - "gc-containerize-gitlab:core-plus" - - "gc-helm-charts-gitlab:core-plus" - retry: 1 - variables: - IMAGE_NAME: "legal-core-plus" - script: - - gcloud auth activate-service-account --key-file $GC_BAREMETAL_DEPLOY_FILE - - !reference [.set_image_name, script] - - !reference [.gc_common_config, script] - - > - helm upgrade $GC_SERVICE-deploy oci://$CI_REGISTRY_IMAGE/core-plus-helm/$GC_HELM_PACKAGE_NAME - --version $GC_HELM_PACKAGE_VERSION-$HELM_TAG - --install - --create-namespace - --namespace=$GC_HELM_NAMESPACE - --wait - --history-max=3 - --set global.onPremEnabled=true - --set global.domain=$GC_DOMAIN - --set global.dataPartitionId=$GC_TENANT - --set data.serviceAccountName=$GC_SERVICE - --set data.bootstrapServiceAccountName=$GC_BOOTSTRAP_SA - --set data.logLevel=INFO - --set data.springProfilesActive=$GC_SPRING_PROFILES_ACTIVE - - !reference [.gc_verify_deploy, script] - - !reference [.gc_verify_bootstrap, script] - rules: - - if: "$CI_COMMIT_BRANCH =~ /^release/" - when: never - - if: "$CI_COMMIT_TAG" - when: never - - if: "$PROTECTED == '1'" - when: on_success + - IMAGE="$CI_REGISTRY_IMAGE/$CORE_IMAGE_NAME:$CORE_IMAGE_TAG" yq -i '.data.image = env(IMAGE)' $CORE_HELM_DEPLOYMENT_DIR/values.yaml + - yq -e '.data | has("bootstrapImage")' $CORE_HELM_DEPLOYMENT_DIR/values.yaml &>/dev/null && BOOTSTRAP_IMAGE="$CI_REGISTRY_IMAGE/$CORE_IMAGE_BOOTSTRAP_NAME:$CORE_IMAGE_TAG" yq -i '.data.bootstrapImage = env(BOOTSTRAP_IMAGE)' $CORE_HELM_DEPLOYMENT_DIR/values.yaml + - LEGALSTATUS_UPDATE_IMAGE="$CI_REGISTRY_IMAGE/$CORE_LEGALSTATUS_IMAGE_NAME:$CORE_IMAGE_TAG" yq -i '.data.legalStatusUpdateImage = env(LEGALSTATUS_UPDATE_IMAGE)' $CORE_HELM_DEPLOYMENT_DIR/values.yaml + - cat $CORE_HELM_DEPLOYMENT_DIR/values.yaml | grep -i image -gc-baremetal-test: +core-containerize-cronjob-gitlab: + extends: core-containerize-gitlab variables: - GC_VENDOR: baremetal + CORE_IMAGE_NAME: "$CORE_LEGALSTATUS_IMAGE_NAME" + CORE_BUILD_PATH: "devops/core-plus/bootstrap_legalstatus_update/Dockerfile" diff --git a/provider/legal-core-plus/README.md b/legal-core-plus/README.md similarity index 100% rename from provider/legal-core-plus/README.md rename to legal-core-plus/README.md diff --git a/provider/legal-core-plus/cloudbuild/Dockerfile b/legal-core-plus/build/Dockerfile similarity index 90% rename from provider/legal-core-plus/cloudbuild/Dockerfile rename to legal-core-plus/build/Dockerfile index 303f8d4d0dea3467d2d623b272a7306ccd5f3bdb..bd893b36e40a82debdac895ed45c7cfcbd81473b 100644 --- a/provider/legal-core-plus/cloudbuild/Dockerfile +++ b/legal-core-plus/build/Dockerfile @@ -10,7 +10,7 @@ COPY tmp/os-obm-minio-*.jar plugins/osm-minio.jar COPY tmp/os-osm-postgres-*.jar plugins/osm-postgres.jar # Copy the jar to the production image from the builder stage. -COPY provider/legal-${PROVIDER_NAME}/target/legal-${PROVIDER_NAME}-*-spring-boot.jar legal-${PROVIDER_NAME}.jar +COPY legal-${PROVIDER_NAME}/target/legal-${PROVIDER_NAME}-*-spring-boot.jar legal-${PROVIDER_NAME}.jar # Add a non-root user RUN groupadd -g 10001 -r nonroot \ && useradd -g 10001 -r -u 10001 nonroot diff --git a/provider/legal-core-plus/docs/baremetal/README.md b/legal-core-plus/docs/baremetal/README.md similarity index 100% rename from provider/legal-core-plus/docs/baremetal/README.md rename to legal-core-plus/docs/baremetal/README.md diff --git a/provider/legal-core-plus/docs/baremetal/pics/rabbit.PNG b/legal-core-plus/docs/baremetal/pics/rabbit.PNG similarity index 100% rename from provider/legal-core-plus/docs/baremetal/pics/rabbit.PNG rename to legal-core-plus/docs/baremetal/pics/rabbit.PNG diff --git a/provider/legal-core-plus/pom.xml b/legal-core-plus/pom.xml similarity index 99% rename from provider/legal-core-plus/pom.xml rename to legal-core-plus/pom.xml index 6744557a2b1cc6abf01df50ce458d361beb6acb3..479b8d846c9d55615b63b21e2c4b7d79f24abc74 100644 --- a/provider/legal-core-plus/pom.xml +++ b/legal-core-plus/pom.xml @@ -23,7 +23,7 @@ <artifactId>legal-service</artifactId> <groupId>org.opengroup.osdu.legal</groupId> <version>0.26.0-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> + <!-- <relativePath>../pom.xml</relativePath> --> </parent> <artifactId>legal-core-plus</artifactId> diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/LegalApplication.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/LegalApplication.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/LegalApplication.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/LegalApplication.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/AppServiceConfig.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/AppServiceConfig.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/AppServiceConfig.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/AppServiceConfig.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/CacheConfig.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/CacheConfig.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/CacheConfig.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/CacheConfig.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/PartitionPropertyNames.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/PartitionPropertyNames.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/PartitionPropertyNames.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/config/PartitionPropertyNames.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderFactoryImpl.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderImpl.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderImpl.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderImpl.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/countries/StorageReaderImpl.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagPublisherImpl.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagPublisherImpl.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagPublisherImpl.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/jobs/LegalTagPublisherImpl.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/mappers/osm/OsmTypeMapperImpl.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/mappers/osm/OsmTypeMapperImpl.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/mappers/osm/OsmTypeMapperImpl.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/mappers/osm/OsmTypeMapperImpl.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/security/GSuiteSecurityConfiguration.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/security/GSuiteSecurityConfiguration.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/security/GSuiteSecurityConfiguration.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/security/GSuiteSecurityConfiguration.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryGcpImpl.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryGcpImpl.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryGcpImpl.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryGcpImpl.java diff --git a/provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/dataaccess/OsmLegalTagRepository.java b/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/dataaccess/OsmLegalTagRepository.java similarity index 100% rename from provider/legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/dataaccess/OsmLegalTagRepository.java rename to legal-core-plus/src/main/java/org/opengroup/osdu/legal/tags/dataaccess/OsmLegalTagRepository.java diff --git a/provider/legal-core-plus/src/main/resources/application.properties b/legal-core-plus/src/main/resources/application.properties similarity index 100% rename from provider/legal-core-plus/src/main/resources/application.properties rename to legal-core-plus/src/main/resources/application.properties diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/InvalidCooRule.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/InvalidCooRule.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/InvalidCooRule.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/InvalidCooRule.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockRule.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockRule.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockRule.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockRule.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockValidationValidator.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockValidationValidator.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockValidationValidator.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/MockValidationValidator.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/PropertiesMock.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/PropertiesMock.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/PropertiesMock.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/PropertiesMock.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/StorageReaderImplTests.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/StorageReaderImplTests.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/StorageReaderImplTests.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/countries/StorageReaderImplTests.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryTest.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryTest.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryTest.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTagRepositoryFactoryTest.java diff --git a/provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTestUtils.java b/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTestUtils.java similarity index 100% rename from provider/legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTestUtils.java rename to legal-core-plus/src/test/java/org/opengroup/osdu/legal/tags/LegalTestUtils.java diff --git a/provider/legal-core-plus/src/test/resources/application.properties b/legal-core-plus/src/test/resources/application.properties similarity index 100% rename from provider/legal-core-plus/src/test/resources/application.properties rename to legal-core-plus/src/test/resources/application.properties diff --git a/pom.xml b/pom.xml index bb42e2c426610ead96fa8885a99fc4389c4cb8c2..f876a4bdbd012bff0e578efb993f81f3db07d791 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ <modules> <module>legal-core</module> - <module>provider/legal-core-plus</module> + <module>legal-core-plus</module> <module>provider/legal-gc</module> <module>provider/legal-byoc</module> <module>provider/legal-azure</module>