diff --git a/.fossa.yml b/.fossa.yml index 89c2e1567c052053bf4004dda479132d25ad5eae..e569ea2e63e61d1c6080c8539d808da5c6a049b1 100644 --- a/.fossa.yml +++ b/.fossa.yml @@ -16,10 +16,6 @@ analyze: type: mvn target: unit-core/pom.xml path: . - - name: unit-gae - type: mvn - target: provider/unit-gcp/unit-gae/pom.xml - path: . - name: unit-gke type: mvn target: provider/unit-gcp/unit-gke/pom.xml diff --git a/devops/gke-unit-cicd.yml b/devops/gke-unit-cicd.yml index b95f29f46c3e334675449e9e967fa872e65c24e8..f1bb0ae3e7d67ddd20c379078b9e6f6e34eea0e3 100644 --- a/devops/gke-unit-cicd.yml +++ b/devops/gke-unit-cicd.yml @@ -146,7 +146,7 @@ stages: set -e pushd $(integrationTestsDir) chmod +x run-integration-tests.sh - ./run-integration-tests.sh $(INTEGRATION_TESTER) $(GOOGLE_AUDIENCES) + ./run-integration-tests.sh $(INTEGRATION_TESTER) popd displayName: "Run integration tests" @@ -233,6 +233,6 @@ stages: # pushd $(integrationTestsDir) # chmod +x run-integration-tests.sh -# ./run-integration-tests.sh $(INTEGRATION_TESTER) $(GOOGLE_AUDIENCES) +# ./run-integration-tests.sh $(INTEGRATION_TESTER) # popd -# displayName: "Run integration tests" \ No newline at end of file +# displayName: "Run integration tests" diff --git a/docs/v2/api_spec/unit_service_openapi_v2.json b/docs/v2/api_spec/unit_service_openapi_v2.json index b59d13c2da7aface986de9f7aca145ff2d8b815d..10b948a4bf8c8b8a4b05d9e7f07d9f241445917d 100644 --- a/docs/v2/api_spec/unit_service_openapi_v2.json +++ b/docs/v2/api_spec/unit_service_openapi_v2.json @@ -1530,7 +1530,6 @@ "type": "oauth2", "x-google-issuer": "https://accounts.google.com", "x-google-jwks_uri": "https://www.googleapis.com/oauth2/v3/certs", - "x-google-audiences": "245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com,245464679631-u44eh98vq4t2ajc2quc8b0kgojsmd3gp.apps.googleusercontent.com", "scopes": {} } }, diff --git a/provider/unit-gcp/unit-gae/README.md b/provider/unit-gcp/unit-gae/README.md deleted file mode 100644 index 2563ded0ca50508b00236421a616a7ff93a50c62..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/README.md +++ /dev/null @@ -1,212 +0,0 @@ -# Unit-gcp - -The Unit service provides dimension/measurement and unit definitions. Given two unit definitions, the service also offers conversion parameters in two different parameterizations. - -## Getting Started - -These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. - -### Prerequisites - -- [Maven 3.6.0+](https://maven.apache.org/download.cgi) -- [AdoptOpenJDK8](https://adoptopenjdk.net/) -- [Lombok 1.16 or later](https://projectlombok.org/setup/maven) -- [GCloud SDK with java (latest version)](https://cloud.google.com/sdk/docs/install) - -### Installation - -- Setup Apache Maven -- Setup AdoptOpenJDK -- Setup GCloud SDK -- Install Eclipse (or other IDE) to run applications -- Set up environment variables for Apache Maven and AdoptOpenJDK. For example M2_HOME, JAVA_HOME, etc. -- Add a configuration for build project in Eclipse(or other IDE) - -### Run Locally - -| `PARTITION_API` | ex `http://localhost:8081/api/partition/v1` | Partition service endpoint | no | - | -| `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | - - -Check that maven is installed: - -```bash -$ mvn --version -Apache Maven 3.6.0 -Maven home: /usr/share/maven -Java version: 1.8.0_212, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u212-b04/jre -... -``` - -You may need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within `~/.mvn/community-maven.settings.xml`: - -```bash -$ cat ~/.m2/settings.xml -<?xml version="1.0" encoding="UTF-8"?> -<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> - <servers> - <server> - <id>community-maven-via-private-token</id> - <!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. --> - <!-- The generated token expires on or before 11/14/2019 --> - <configuration> - <httpHeaders> - <property> - <name>Private-Token</name> - <value>${env.COMMUNITY_MAVEN_TOKEN}</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> -</settings> -``` - -* Update the Google cloud SDK to the latest version: - -```bash -gcloud components update -``` -* Set Google Project Id: - -```bash -gcloud config set project <YOUR-PROJECT-ID> -``` - -* Perform a basic authentication in the selected project: - -```bash -gcloud auth application-default login -``` - -## Testing -* Navigate to unit service's root folder and run: - -```bash -mvn clean install -``` - -* If you wish to build the project without running tests - -```bash -mvn clean install -DskipTests -``` - -After configuring your environment as specified above, you can follow these steps to build and run the application. These steps should be invoked from the *repository root.* - -```bash -cd provider/unit-gcp/unit-gae && mvn spring-boot:run -``` - -## Testing - -### Running E2E Tests - -#### Folder structure -testing/ -* unit_test_core/ - * ... -* unit_test_$PROVIDER_NAME/ - * jwt_client.py - * run_test.py - -This integration test uses a swagger generated Python client to test a -deployed unit-service. The source is located in this repository -```./api_spec/unit_service_openapi.json```. - -The python client code is automatically generated. The latest online version (May 2018) -created incorrect impost statements for cyclic class references. Therefore the current -code is generated using [swagger-codegen-cli-2.2.3.jar](https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.3/swagger-codegen-cli-2.2.3.jar). -The command to create the python code is: -Linux -```bash -cd testing -java -jar ~/swagger-codegen-cli-2.2.3.jar generate -i unit_test_core/api_spec/unit_service_openapi.json -l python -o unit_test_core/v2 -``` -Windows -```bat -cd testing -java -jar %UserProfile%\swagger-codegen-cli-2.2.3.jar generate -i unit_test_core\api_spec\unit_service_openapi_v2.json -l python -o unit_test_core\v2 -``` - -#### Environment -The following parameters are expected as environment variables: - -**Google Cloud auth provider (catalog_test_gcp/jwt_client.py)** - -| Variable | Contents | -|----------|----------| -| INTEGRATION_TESTER | go to the google IAM & admin console, navigate to Service accounts to create a key and download the account info file. | - -**Tests core (unit_test_core/constants.py)** - -| Variable | Contents | -|----------|----------| -| BASE_URL | e.g. /api/unit | -| VIRTUAL_SERVICE_HOST_NAME | e.g. az-osdu1.evd.csp.slb.com | -| MY_TENANT | e.g. opendes | - -**Entitlements configuration for integration accounts** - -| INTEGRATION_TESTER | -| --- | -| users<br/>service.entitlements.user<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{domain}.com | - -#### Building/running -Go to the provider folder: -```bash -cd unit_test_$PROVIDER_NAME/ # e.g. unit_test_gcp -``` -To set up a virtual environment: -```bash -virtualenv venv -``` -To activate the venv: -```bash -venv\Scripts\activate (on Windows) -source venv/bin/activate (on Linux) -``` - -Install runtime dependencies in venv -```bash -python3 -m pip install -r requirements.txt -``` - -To run: -```bash -python3 run_test.py -``` - -## Deployment - -* Data-Lake unit Google Cloud Endpoints on App Engine Flex environment - * Deploy - ```sh - mvn appengine:deploy -pl org.opengroup.osdu.unit:unit -amd - ``` - - * If you wish to deploy the unit service without running tests - ```sh - mvn appengine:deploy -pl org.opengroup.osdu.unit:unit -amd -DskipTests - ``` - -or -* Google Documentation: https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-appengine - -## Licence -Copyright © Google LLC -Copyright © EPAM Systems - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/provider/unit-gcp/unit-gae/pom.xml b/provider/unit-gcp/unit-gae/pom.xml deleted file mode 100644 index 30a99d75db872188860d65d418b99b2ca933ffad..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <packaging>jar</packaging> - - <parent> - <groupId>org.opengroup.osdu.unit-service</groupId> - <artifactId>unit-service</artifactId> - <version>0.19.0-SNAPSHOT</version> - <relativePath>../../../pom.xml</relativePath> - </parent> - - <artifactId>unit-gae</artifactId> - <version>0.19.0-SNAPSHOT</version> - <name>unit-gae</name> - <description>Unit service Google App Engine deployment</description> - - <properties> - <appengine.app.version>1</appengine.app.version> - <app.version>1</app.version> - <app.id>unit-gae</app.id> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <appengine.plugin.version>1.9.73</appengine.plugin.version> - <appengine.maven.plugin.version>1.3.2</appengine.maven.plugin.version> - <lucene.version>8.0.0</lucene.version> - <resteasy.version>3.6.2.Final</resteasy.version> - <objectify.version>5.1.22</objectify.version> - <slf4j.version>1.7.25</slf4j.version> - <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> - </properties> - - <prerequisites> - <maven>3.1.0</maven> - </prerequisites> - - <dependencies> - <dependency> - <groupId>org.opengroup.osdu.unit-service</groupId> - <artifactId>unit-core</artifactId> - <version>${project.version}</version> - </dependency> - <!-- https://mvnrepository.com/artifact/com.google.appengine/appengine-api-1.0-sdk --> - <dependency> - <groupId>com.google.appengine</groupId> - <artifactId>appengine-api-1.0-sdk</artifactId> - <version>1.9.79</version> - </dependency> - <dependency> - <groupId>com.google.cloud</groupId> - <artifactId>google-cloud-storage</artifactId> - <version>1.70.0</version> - </dependency> - - <!-- Compile/runtime dependencies --> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.9.1</version> - </dependency> - - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <version>1.18.2</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>1.2.3</version> - </dependency> - <dependency> - <groupId>org.opengroup.osdu</groupId> - <artifactId>core-lib-gcp</artifactId> - <version>0.16.0</version> - </dependency> - - <dependency> - <groupId>ch.qos.logback.contrib</groupId> - <artifactId>logback-json-classic</artifactId> - <version>0.1.5</version> - </dependency> - </dependencies> - - <build> - <!-- for hot reload of the web application--> - <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>2.7.4</version> - </plugin> - <plugin> - <groupId>com.google.cloud.tools</groupId> - <artifactId>appengine-maven-plugin</artifactId> - <version>${appengine.maven.plugin.version}</version> - <configuration> - <!-- deploy configuration --> - <stage.enableJarSplitting>true</stage.enableJarSplitting> - <deploy.stopPreviousVersion>true</deploy.stopPreviousVersion> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>versions-maven-plugin</artifactId> - <version>2.7</version> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>display-dependency-updates</goal> - <goal>display-plugin-updates</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <version>3.7.0</version> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.21.0</version> - <configuration> - <redirectTestOutputToFile>true</redirectTestOutputToFile> - </configuration> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>0.7.7.201606060606</version> - <executions> - <execution> - <goals> - <goal>prepare-agent</goal> - </goals> - </execution> - <execution> - <id>report</id> - <phase>prepare-package</phase> - <goals> - <goal>report</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/provider/unit-gcp/unit-gae/scripts/config.sh b/provider/unit-gcp/unit-gae/scripts/config.sh deleted file mode 100644 index 102b1bc9b5e86f5a8d93cc5697a7dd0739fbeb5e..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/scripts/config.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -if [ "$PROJECT_ID" = "" ] -then - export PROJECT_ID=$(gcloud config get-value project) -fi diff --git a/provider/unit-gcp/unit-gae/scripts/deploy.sh b/provider/unit-gcp/unit-gae/scripts/deploy.sh deleted file mode 100644 index 05b88e65c9ec9c6f09ef220b2c5cade7b863e311..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/scripts/deploy.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# deploy script - -# Exit as soon as a command fails -set -e - -SCRIPTS_DIR=$(dirname $0) -DROP_DIR=$(dirname $SCRIPTS_DIR) - -# Go to drop directory -cd $DROP_DIR -# convert to full path -DROP_DIR=`pwd` -echo "Current working directory: $DROP_DIR" - -DEPLOY_DIR=$DROP_DIR/deploy - -if [ -s $DEPLOY_DIR ]; then - rm -rf $DEPLOY_DIR/* -else - mkdir $DEPLOY_DIR -fi - -DEPLOY_SCRIPTS_DIR=$DEPLOY_DIR/scripts - -mkdir -p $DEPLOY_SCRIPTS_DIR - -echo "Copy artifacts to folder: $DEPLOY_DIR" -cp $DROP_DIR/app.yaml $DEPLOY_DIR -cp $DROP_DIR/unit-gae-*.jar $DEPLOY_DIR -cp $DROP_DIR/testing.zip $DEPLOY_DIR -cp $SCRIPTS_DIR/* $DEPLOY_SCRIPTS_DIR -chmod a+x $DEPLOY_SCRIPTS_DIR/*.sh - -# Go to deploy directory -cd $DEPLOY_DIR -echo "Current working directory: $DEPLOY_DIR" - -source $DEPLOY_SCRIPTS_DIR/config.sh - -echo "Deploying to gcp" -$DEPLOY_SCRIPTS_DIR/deploy2gcp.sh -echo "Deployed to gcp" diff --git a/provider/unit-gcp/unit-gae/scripts/deploy2gcp.sh.tmpl b/provider/unit-gcp/unit-gae/scripts/deploy2gcp.sh.tmpl deleted file mode 100644 index b442fb2974ac8aafafade8df6830c0defa2e2b0c..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/scripts/deploy2gcp.sh.tmpl +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -# Exit as soon as a command fails -set -e - -{{$definitionName := getenv "BUILD_DEFINITIONNAME" -}} -{{$sourceBranchName := getenv "BUILD_SOURCEBRANCHNAME" -}} -{{$buildNumber := getenv "BUILD_BUILDNUMBER" -}} - -BUILD_DEFINITIONNAME={{$definitionName}} -BUILD_SOURCEBRANCHNAME={{$sourceBranchName}} -BUILD_BUILDNUMBER={{$buildNumber}} - -SCRIPTS_DIR=$(dirname $0) -DEPLOY_DIR=$(dirname $SCRIPTS_DIR) - -# Go to deploy directory -cd $DEPLOY_DIR -# convert to full path -DEPLOY_DIR=`pwd` -echo "Current working directory: $DEPLOY_DIR" - -source $SCRIPTS_DIR/config.sh - -echo "This script will deploy the app to $PROJECT_ID" - -if [ "$REGION" = "" ] -then - REGION=$(gcloud config get-value compute/region) -fi - -echo "Environment" -echo " Project = $PROJECT_ID" -echo " Compute zone = $CLOUDSDK_COMPUTE_ZONE" -echo " Build definition = $BUILD_DEFINITIONNAME" -echo " Source branch = $BUILD_SOURCEBRANCHNAME" -echo " Build number = $BUILD_BUILDNUMBER" -echo " Directory = $DEPLOY_DIR" - -VERSION_NUMBER=$BUILD_BUILDNUMBER -VERSION_NUMBER=$(echo "$VERSION_NUMBER" | tr _ - | tr . - | tr '[:upper:]' '[:lower:]') - -count=$(gcloud app services list --project $PROJECT_ID | grep os-unit-gae | wc -l) -if [ $count -gt 0 ]; then - CURRENT_VERSION=$(gcloud app services describe os-unit-gae --project $PROJECT_ID --format=json | jq --raw-output '.split.allocations | keys[0]') -else - CURRENT_VERSION="" -fi - -echo "Current version = $CURRENT_VERSION" -echo "Version to be deployed = $VERSION_NUMBER" - -if [ "$VERSION_NUMBER" != "$CURRENT_VERSION" -o "$BUILD_FORCE_DEPLOY" = "true" ] -then - SERVICE_NAME="os-unit-gae" - # If the version $VERSION_NUMBER already exists, but not serving traffic, gcloud app deploy will fail. In this case, simply start that version and migrate traffic to it - doesVersionExist=`gcloud app versions list --service=$SERVICE_NAME --project=$PROJECT_ID | grep $VERSION_NUMBER | wc -l` - if [ "$doesVersionExist" -eq "1" ] - then - echo "Starting version $VERSION_NUMBER" - gcloud app versions start $VERSION_NUMBER --service=$SERVICE_NAME --project=$PROJECT_ID --quiet - echo "Migrating all traffic to version $VERSION_NUMBER" - gcloud app services set-traffic $SERVICE_NAME --splits $VERSION_NUMBER=1 --project=$PROJECT_ID --quiet - else - export UNIT_HOSTNAME="os-unit-gae-dot-$PROJECT_ID.appspot.com" - - echo "Replacing ENTITLEMENT_URL_PLACE_HOLDER with $ENTITLEMENT_URL" - sed -i "s|ENTITLEMENT_URL_PLACE_HOLDER|$ENTITLEMENT_URL|g" app.yaml - echo "Content of app.yaml:" - cat app.yaml - - echo "Deploying $UNIT_HOSTNAME service" - gcloud app deploy --project=$PROJECT_ID --version=$VERSION_NUMBER --verbosity=debug app.yaml - echo "$UNIT_HOSTNAME service deployed successfully" - - fi -else - echo "Not deploying the application because $VERSION_NUMBER is already deployed and force deploy flag is not set to true" -fi diff --git a/provider/unit-gcp/unit-gae/scripts/stage-artifacts.sh b/provider/unit-gcp/unit-gae/scripts/stage-artifacts.sh deleted file mode 100644 index 18bdce2c7182f0e6a247e9424b28e4585bd283a8..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/scripts/stage-artifacts.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Exit as soon as a command fails -set -e - -if [ ! $# = 1 ]; then - echo "Usage: $0 dir" - exit 1 -fi - -STAGE_DIR=$1 - -cd $BUILD_REPOSITORY_LOCALPATH/provider/unit-gcp/unit-gae/scripts - -source ./config.sh - -#apply gomplate to deploy2gcp.sh.tmpl -gomplate -f ./deploy2gcp.sh.tmpl -o ./deploy2gcp.sh -chmod a+x ./*.sh -echo "Contents of deploy2gcp.sh:" -cat ./deploy2gcp.sh - -cd .. - -# Upload all build and deploy scripts as artifacts -cp -R ./scripts $STAGE_DIR -# Upload the build generated .war file as an artifact -cp ./target/unit-gae-*.jar $STAGE_DIR - -echo "Staging deployment artifacts to folder: $STAGE_DIR" -cp ./src/main/appengine/app.yaml $STAGE_DIR - -# set current directory back to build repo root -cd $BUILD_REPOSITORY_LOCALPATH - -# Zip integration tests and upload it as artifact -pushd testing -zip -r testing.zip * -cp testing.zip $STAGE_DIR -popd - diff --git a/provider/unit-gcp/unit-gae/src/main/appengine/app.yaml b/provider/unit-gcp/unit-gae/src/main/appengine/app.yaml deleted file mode 100644 index 5c9d9373287d3d467006d9c94292c6ca999cb1eb..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/appengine/app.yaml +++ /dev/null @@ -1,45 +0,0 @@ -service: os-unit-gae - -runtime: java -env: flex - -runtime_config: - jdk: openjdk8 - -api_version: 1 -threadsafe: yes - -resources: - cpu: 2 - memory_gb: 2.4 - disk_size_gb: 20 - -automatic_scaling: - min_num_instances: 1 - max_num_instances: 3 - cool_down_period_sec: 120 - cpu_utilization: - target_utilization: 0.5 - -handlers: -- url: /.* - script: this field is required, but ignored - -# liveness_check: -# path: '/_ah/liveness_check' -# timeout_sec: 4 -# check_interval_sec: 10 -# failure_threshold: 3 -# success_threshold: 2 -# initial_delay_sec: 600 - -# readiness_check: -# path: '/_ah/readiness_check' -# timeout_sec: 4 -# check_interval_sec: 5 -# failure_threshold: 2 -# success_threshold: 2 -# app_start_timeout_sec: 600 - -env_variables: - ENTITLEMENT_URL: ENTITLEMENT_URL_PLACE_HOLDER diff --git a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UnitCatalogGaeConfiguration.java b/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UnitCatalogGaeConfiguration.java deleted file mode 100644 index 28a128e055a2a7538db451ee32d1a5ebe5257396..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UnitCatalogGaeConfiguration.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright 2020 Google LLC - Copyright 2020 EPAM Systems, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package org.opengroup.osdu.unitservice; - -import com.google.cloud.ServiceOptions; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.Storage; -import com.google.cloud.storage.StorageOptions; - -import org.opengroup.osdu.unitservice.model.CatalogImpl; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.StringUtils; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.logging.Level; -import java.util.logging.Logger; - -@Configuration -public class UnitCatalogGaeConfiguration { - - private static final Logger log = Logger.getLogger(UnitCatalogGaeConfiguration.class.getName()); - - @Bean - public CatalogImpl createV2Catalog(@Value("${osdu.unit.gae.catalog.bucket}") String bucketName, - @Value("${osdu.unit.gae.catalog.file}") String catalogFileName) throws Exception { - Storage storage = StorageOptions.getDefaultInstance().getService(); - if (StringUtils.isEmpty(bucketName)) { - log.info("UNIT_CATALOG_BUCKET is not provided"); - String projectId = ServiceOptions.getDefaultProjectId(); - bucketName = projectId + "-unit-catalogs"; - } - log.log(Level.INFO, "Loading unit catalogs from bucketName={0}", bucketName); - Blob blob = storage.get(bucketName, catalogFileName); - if (blob == null) { - throw new IOException("Unit catalog=" + catalogFileName + " not found at bucketName=" + bucketName); - } - Reader reader = new InputStreamReader(new ByteArrayInputStream(blob.getContent())); - log.info("Start creating the catalog"); - CatalogImpl catalogImpl = CatalogImpl.createCatalog(reader); - log.info("Finished creating the catalog"); - - return catalogImpl; - } - -} diff --git a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UomGaeApplication.java b/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UomGaeApplication.java deleted file mode 100644 index fa43d629d7b426c1464af336683ad580af8579a2..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/UomGaeApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright 2020 Google LLC - Copyright 2020 EPAM Systems, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package org.opengroup.osdu.unitservice; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - - -@ComponentScan({"org.opengroup.osdu"}) -@SpringBootApplication -public class UomGaeApplication { - - public static void main(String[] args) { - SpringApplication.run(UomGaeApplication.class, args); - } -} diff --git a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/security/SecurityConfiguration.java b/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/security/SecurityConfiguration.java deleted file mode 100644 index 929c886b11f9427b26386fbd693db64f8544e2bc..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/java/org/opengroup/osdu/unitservice/security/SecurityConfiguration.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright 2020 Google LLC - Copyright 2020 EPAM Systems, Inc - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -package org.opengroup.osdu.unitservice.security; - -import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS; - -import org.opengroup.osdu.unitservice.middleware.AuthenticationRequestFilter; -import org.opengroup.osdu.unitservice.middleware.AuthenticationService; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - -@EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class SecurityConfiguration extends WebSecurityConfigurerAdapter { - - private static final String[] ALLOWED_URLS = { - "/", - "/v2/api-docs", - "/v3/api-docs", - "/swagger", - "/swagger-resources/**", - "/swagger-ui.html", - "/info", - "/webjars/**", - "/_ah/**", - "/error", - "/favicon.ico", - "/csrf", - "/api/unit", - "/api/unit/v2/api-docs", - "/api/unit/v3/api-docs", - "/api/unit/swagger-resources/**", - "/api/unit/swagger-ui.html", - "/api/unit/webjars/**", - "/api/unit/_ah/**", - "/api/unit/error", - "/api/unit/favicon.ico", - "/api/unit/csrf" // Required to prevent errors in logs while Swagger is trying to discover a valid csrf token. Should be deleted after the issue on the Swagger's side https://github.com/springfox/springfox/issues/2578 is resolved - }; - - private final AuthenticationService authenticationService; - - public SecurityConfiguration(AuthenticationService authenticationService) { - this.authenticationService = authenticationService; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - AuthenticationRequestFilter authhenticationFilter = new AuthenticationRequestFilter(authenticationService); - http.csrf().disable() - .sessionManagement().sessionCreationPolicy(STATELESS) - .and() - .authorizeRequests() - .anyRequest().authenticated() - .and() - .addFilterBefore(authhenticationFilter, UsernamePasswordAuthenticationFilter.class); - } - - @Override - public void init(WebSecurity web) throws Exception { - web.ignoring().mvcMatchers(ALLOWED_URLS); - super.init(web); - } -} diff --git a/provider/unit-gcp/unit-gae/src/main/resources/application.properties b/provider/unit-gcp/unit-gae/src/main/resources/application.properties deleted file mode 100644 index 9d682978439370b2f052160c84ac39a01a316e3b..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/resources/application.properties +++ /dev/null @@ -1,24 +0,0 @@ -LOG_PREFIX=unit - -server.servlet.contextPath=/api/unit/ -logging.level.org.springframework.web=DEBUG -server.port=8080 - -spring.main.allow-bean-definition-overriding=true - -# Entitlement properties -# -# -# [Required] URL of the Entitlements Service -osdu.entitlement.url=${ENTITLEMENT_URL} - -# Other properties -# -# -# [Optional] [GAE] Specifies the name of the bucket which contains unit catalog -osdu.unit.gae.catalog.bucket=${UNIT_CATALOG_BUCKET:} -# [Optional] [GAE] Unit catalog file name in the bucket -osdu.unit.gae.catalog.file=${UNIT_CATALOG_FILENAME:UnitCatalog_V2.json} - -google.audiences=123.apps.googleusercontent.com -partition.api=http://localhost:8081/api/partition/v1 diff --git a/provider/unit-gcp/unit-gae/src/main/resources/logback.xml b/provider/unit-gcp/unit-gae/src/main/resources/logback.xml deleted file mode 100644 index e6bb61f96ec8c70237a16b73f2b6d2ede74a19fd..0000000000000000000000000000000000000000 --- a/provider/unit-gcp/unit-gae/src/main/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<configuration> - <include resource="org/springframework/boot/logging/logback/defaults.xml"/> - <springProfile name="local"> - <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>%yellow([%thread]) %highlight(| %-5level |) %green(%d) %cyan(| %logger{15} |) %highlight(%msg) %n</pattern> - <charset>utf8</charset> - </encoder> - </appender> - <root level="DEBUG"> - <appender-ref ref="CONSOLE"/> - </root> - </springProfile> - - <springProfile name="!local"> - <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> - <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> - <layout class="ch.qos.logback.contrib.json.classic.JsonLayout"> - <timestampFormat>yyyy-MM-dd HH:mm:ss.SSS</timestampFormat> - <timestampFormatTimezoneId>Etc/UTC</timestampFormatTimezoneId> - <appendLineSeparator>true</appendLineSeparator> - - <jsonFormatter class="org.opengroup.osdu.core.gcp.logging.formatter.GoogleJsonFormatter"> - <prettyPrint>false</prettyPrint> - </jsonFormatter> - </layout> - </encoder> - </appender> - - <root level="debug"> - <appender-ref ref="stdout"/> - </root> - </springProfile> - -</configuration> \ No newline at end of file diff --git a/provider/unit-gcp/unit-gke/README.md b/provider/unit-gcp/unit-gke/README.md index 9d62e088e425bc469edd825dc142f568406a8247..278f9a635467629a895ec124c3cab78006689be1 100644 --- a/provider/unit-gcp/unit-gke/README.md +++ b/provider/unit-gcp/unit-gke/README.md @@ -1,4 +1,4 @@ -# Unit-gcp +# Unit Service for Google Cloud The Unit service provides dimension/measurement and unit definitions. Given two unit definitions, the service also offers conversion parameters in two different parameterizations. @@ -180,8 +180,12 @@ python3 run_test.py ``` ## Deployment +Unit Service is compatible with Cloud Run and Google Kubernetes Engine. -See Google Documentation: https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-gke +* To deploy into Cloud run, please, use this documentation: + https://cloud.google.com/run/docs/quickstarts/build-and-deploy +* To deploy into GKE, please, use this documentation: + https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-gke ## Licence Copyright © Google LLC diff --git a/testing/unit_test_gcp/jwt_client.py b/testing/unit_test_gcp/jwt_client.py index 60bbe38cb562124d7a4c37769de3e8e0e70e5a90..eee5cad77645aa8d328f81741786c88fbb65eb8c 100644 --- a/testing/unit_test_gcp/jwt_client.py +++ b/testing/unit_test_gcp/jwt_client.py @@ -43,7 +43,7 @@ def generate_jwt(): 'iat': now, "exp": now + 3600, 'iss': integration_test_service_account, - "target_audience": str(os.getenv('GOOGLE_AUDIENCES')), + "target_audience": 'osdu', "aud": "https://www.googleapis.com/oauth2/v4/token" }