Commit c8fffa36 authored by Rostislav Dublin (EPAM)'s avatar Rostislav Dublin (EPAM)
Browse files

Merge branch 'GCP-default_data_partition_config' into 'master'

GCP make enum value ACCOUNT_ID_COMMON_PROJECT configurable (GONRG-854)

See merge request osdu/platform/system/schema-service!29
parents a4471bd6 eb927f31
......@@ -23,6 +23,11 @@ variables:
AWS_ENVIRONMENT: dev
AWS_MAVEN_TEST_COMMAND_OVERRIDE: verify
OSDU_GCP_SERVICE: schema
OSDU_GCP_VENDOR: gcp
OSDU_GCP_APPLICATION_NAME: os-schema
OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_URL,AUTHORIZE_API_KEY=$OSDU_GCP_AUTHORIZE_API_KEY,LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG,ACCOUNT_ID_COMMON_PROJECT=$TENANT --vpc-connector=$OSDU_GCP_VPC_CONNECTOR
include:
- project: "osdu/platform/ci-cd-pipelines"
......@@ -48,3 +53,19 @@ include:
- project: "osdu/platform/ci-cd-pipelines"
file: "cloud-providers/azure.yml"
- project: "osdu/platform/ci-cd-pipelines"
ref: 'master'
file: 'cloud-providers/osdu-gcp-cloudrun.yml'
osdu-gcp-test:
image: maven:3.3.9-jdk-8
extends:
- .osdu-gcp-variables
stage: integration
needs: ["osdu-gcp-deploy"]
script:
- echo 'GCP integrations tests - TBD'
only:
variables:
- $OSDU_GCP == 'true'
This diff is collapsed.
......@@ -44,6 +44,7 @@
<module>provider/schema-gcp</module>
<module>provider/schema-ibm</module>
<module>provider/schema-azure</module>
<module>testing/schema-test-core</module>
</modules>
<repositories>
<repository>
......@@ -62,4 +63,5 @@
<url>https://community.opengroup.org/api/v4/projects/26/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
......@@ -131,4 +131,4 @@
</distributionManagement>
</project>
\ No newline at end of file
</project>
# Use the official AdoptOpenJDK for a base image.
# https://hub.docker.com/_/openjdk
FROM openjdk:8-slim
WORKDIR /app
ARG PORT
ENV PORT $PORT
# Copy the jar to the production image from the builder stage.
COPY provider/schema-gcp/target/os-schema-gcp-*-spring-boot.jar schema.jar
# Run the web service on container startup.
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -jar /app/schema.jar
# Copyright 2020 Google LLC
# Copyright 2017-2019, Schlumberger
# Copyright 2020 EPAM
#
# 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.
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'--build-arg', 'PORT=${_PORT}',
'-t', 'gcr.io/$PROJECT_ID/os-schema/schema-gcp:${_SHORT_SHA}',
'-t', 'gcr.io/$PROJECT_ID/os-schema/schema-gcp:latest',
'-f', 'provider/schema-gcp/cloudbuild/Dockerfile.cloudbuild',
'.'
]
images:
- 'gcr.io/$PROJECT_ID/os-schema/schema-gcp'
......@@ -17,7 +17,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.105.0</version>
<version>1.108.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-datastore -->
......@@ -112,23 +112,4 @@
</plugins>
</build>
<repositories>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/26/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/26/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
\ No newline at end of file
</project>
service: os-schema
runtime: java
env: flex
resources:
cpu: 2
memory_gb: 6
automatic_scaling:
min_num_instances: 2
max_num_instances: 5
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7
env_variables:
SPRING_PROFILES_ACTIVE: 'ENVIRONMENT'
......@@ -27,6 +27,7 @@ import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore;
import org.opengroup.osdu.schema.util.VersionHierarchyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import com.google.cloud.Timestamp;
......@@ -65,6 +66,9 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
@Autowired
JaxRsDpsLog log;
@Value("${account.id.common.project}")
private String commonAccountId;
/**
* Method to get schemaInfo from google store
*
......@@ -305,11 +309,11 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
public boolean isUnique(String schemaId, String tenantId) throws ApplicationException {
Set<String> tenantList = new HashSet<>();
tenantList.add(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT);
tenantList.add(commonAccountId);
tenantList.add(tenantId);
// code to call check uniqueness
if (tenantId.equalsIgnoreCase(SchemaConstants.ACCOUNT_ID_COMMON_PROJECT)) {
if (tenantId.equalsIgnoreCase(commonAccountId)) {
List<String> privateTenantList = tenantFactory.listTenantInfo().stream().map(TenantInfo::getDataPartitionId)
.collect(Collectors.toList());
tenantList.addAll(privateTenantList);
......@@ -328,4 +332,12 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
}
return true;
}
public String getCommonAccountId() {
return commonAccountId;
}
public void setCommonAccountId(String commonAccountId) {
this.commonAccountId = commonAccountId;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.NotFoundException;
import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import com.google.cloud.storage.Blob;
......
......@@ -7,3 +7,4 @@ management.health.elasticsearch.enabled=false
management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=health
LOG_PREFIX=schema
account.id.common.project=common
......@@ -172,6 +172,7 @@ public class GoogleSchemaInfoStoreTest {
KeyFactory storageKeyFactory = mock(KeyFactory.class);
String schemaId = "schemaId";
String tenantId = "tenant";
schemaInfoStore.setCommonAccountId(tenantId);
Mockito.when(tenantFactory.getTenantInfo("tenant")).thenReturn(tenantInfo);
Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon);
Mockito.when(tenantInfo.getName()).thenReturn("tenant");
......
......@@ -121,4 +121,4 @@
</build>
</project>
\ No newline at end of file
</project>
......@@ -203,4 +203,4 @@
</plugins>
</build>
</project>
\ No newline at end of file
</project>
......@@ -40,4 +40,4 @@ public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlements
public Class<?> getObjectType() {
return IEntitlementsFactory.class;
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment