Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Copyright 2017-2020, Schlumberger

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.

os-register-gcp

os-register-gcp is a Spring Boot service that hosts CRUD APIs that allows consumers to register a push endpoint that can be triggered when data change events happen within the OSDU R2 ecosystem.

Running locally

Requirements

  • Java 8
  • Maven 3.6.0+
  • GCloud command line tool
  • GCloud access to opendes project

General Tips

Environment Variable Management The following tools make environment variable configuration simpler

Lombok This project uses Lombok for code generation. You may need to configure your IDE to take advantage of this tool.

Environment Variables

In order to run the service locally, you will need to have the following environment variables defined.

System Environment required to run service

name value description sensitive? source
SPRING_PROFILES_ACTIVE local spring active profile no

System Properties required to run integration tests

name value description sensitive? source
DE_OPS_TESTER ******** A base64 encoded google service account json credentials with ops level authorization for OSDU services yes
DE_ADMIN_TESTER ******** A base64 encoded google service account json credentials with admin level authorization for OSDU services yes
DE_EDITOR_TESTER ******** A base64 encoded google service account json credentials with editor level authorization for OSDU services yes
DE_NO_ACCESS_TESTER ******** A base64 encoded google service account json credentials with no authorization for OSDU services yes

System Environment required to run integration tests

name value description sensitive? source
ENVIRONMENT local service running environment no

Configure Maven

Check that maven is installed:

$ 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 will need to configure access to the remote maven repository that holds the OSDU dependencies. This file should live within ~/.m2/settings.xml:

$ 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>os-core</id>
            <username>slb-des-ext-collaboration</username>
            <!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
            <password>${VSTS_FEED_TOKEN}</password>
        </server>
    </servers>
</settings>

Build and run the application

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.

# build + test + install core service code
$ cd register-core/ && mvn clean install

# build + test + package gcp service code
$ cd provider/register-gcp/ && mvn clean package

# run service
#
# Note: this assumes that the environment variables for running the service as outlined
#       above are already exported in your environment.
$ mvn spring-boot:run -Dspring-boot.run.profiles=local 

Test the application

After the service has started it should be accessible via a web browser by visiting http://localhost:8080/api/register/v1/swagger-ui.html. If the request does not fail, you can then run the integration tests.