There is a security vulnerability in SSH key-generation using GitKraken < v8.0.1. If you used this tool to create SSH keys, please update GitKraken and regenerate. If you need help with this, contact forum-support@opengroup.org

Commit 19456e1f authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Riabokon Stanislav(EPAM)[GCP]
Browse files

Added new version info endpoint (GONRG-2811)

parent cbcf638a
This diff is collapsed.
......@@ -14,7 +14,7 @@
</parent>
<properties>
<os-core-common.version>0.10.0</os-core-common.version>
<os-core-common.version>0.11.0-SNAPSHOT</os-core-common.version>
<openapi.version>1.4.8</openapi.version>
</properties>
......
/*
* Copyright 2021 Google LLC
* Copyright 2021 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
*
* https://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.backup.api;
import java.io.IOException;
import org.opengroup.osdu.core.common.info.VersionInfoBuilder;
import org.opengroup.osdu.core.common.model.info.VersionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class InfoApi {
@Autowired
private VersionInfoBuilder versionInfoBuilder;
@GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE)
public VersionInfo info() throws IOException {
return versionInfoBuilder.buildVersionInfo();
}
}
\ No newline at end of file
apiVersion: v2
name: gcp-backup-configmap
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.16.0"
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: "{{ .Values.conf.app_name }}"
name: "{{ .Values.conf.configmap }}"
namespace: "{{ .Release.Namespace }}"
data:
LOG_LEVEL: "{{ .Values.data.log_level }}"
OSDU_ENTITLEMENTS_URL: "{{ .Values.data.entitlements_url }}"
GCP_PROJECT_ID: "{{ .Values.data.project_id }}"
GCP_BACKUP_BUCKET: "{{ .Values.data.backup_bucket}}"
GCP_SQL_BACKUP_KIND: "{{ .Values.data.backup_kind}}"
GCP_SQL_RESTORE_BACKUP_KIND: "{{ .Values.data.sql_restore_backup_kind }}"
SPRING_CLOUD_GCP_SQL_DATABASENAME: "{{ .Values.data.sql_databasename }}"
SPRING_CLOUD_GCP_SQL_INSTANCECONNECTIONNAME: "{{ .Values.data.sql_instanceconnectionname }}"
SPRING_CLOUD_GCP_DATASTORE_NAMESPACE: "{{ .Values.data.datastore_namespace }}"
PARTITION_API: "{{ .Values.data.partition_api }}"
GOOGLE_AUDIENCES: "{{ .Values.data.google_audiences }}"
# Default values for backup-configmap.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
data:
log_level: ""
entitlements_url: ""
project_id:
backup_bucket:
sql_backup_kind:
sql_restore_backup_kind:
sql_databasename:
sql_instanceconnectionname:
datastore_namespace:
partition_api: ""
google_audiences: ""
conf:
configmap: "backup-config"
app_name: "backup"
apiVersion: v2
name: gcp-backup-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.16.0"
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: "{{ .Values.conf.app_name }}"
name: "{{ .Values.conf.app_name }}"
namespace: "{{ .Release.Namespace }}"
spec:
selector:
matchLabels:
app: "{{ .Values.conf.app_name }}"
replicas: 1
template:
metadata:
labels:
app: "{{ .Values.conf.app_name }}"
annotations:
rollme: {{ randAlphaNum 5 | quote }}
spec:
containers:
- name: "{{ .Values.conf.app_name }}"
image: "{{ .Values.data.image }}"
envFrom:
- configMapRef:
name: "{{ .Values.conf.configmap }}"
securityContext:
allowPrivilegeEscalation: false
runAsUser: 0
ports:
- containerPort: 8080
resources:
requests:
cpu: "{{ .Values.data.requests_cpu }}"
memory: "{{ .Values.data.requests_memory }}"
limits:
cpu: "{{ .Values.data.limits_cpu }}"
memory: "{{ .Values.data.limits_memory }}"
serviceAccountName: "{{ .Values.data.serviceAccountName }}"
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.conf.app_name }}"
annotations:
cloud.google.com/neg: '{"ingress": true}'
namespace: "{{ .Release.Namespace }}"
labels:
app: "{{ .Values.conf.app_name }}"
service: "{{ .Values.conf.app_name }}"
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
name: http
selector:
app: "{{ .Values.conf.app_name }}"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: "{{ .Values.conf.app_name }}"
namespace: "{{ .Release.Namespace }}"
spec:
hosts:
- "*"
gateways:
- service-gateway
http:
- match:
- uri:
prefix: "/api/backup"
route:
- destination:
port:
number: 80
host: "{{ .Values.conf.app_name }}.{{ .Release.Namespace }}.svc.cluster.local"
# Default values for backup-deploy.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
data:
requests_cpu: "0.25"
requests_memory: "128M"
limits_cpu: "1"
limits_memory: "256M"
serviceAccountName: ""
image: ""
conf:
configmap: "backup-config"
app_name: "backup"
......@@ -245,6 +245,21 @@ paths:
'*/*':
schema:
type: string
/info:
get:
tags:
- info
summary: "Version info"
description: "For deployment available public `/info` endpoint, \
\ which provides build and git related information."
operationId: "Version info"
produces:
- "application/json"
responses:
200:
description: "Version info."
schema:
$ref: "#/components/schemas/VersionInfo"
components:
schemas:
BackupCollection:
......@@ -323,6 +338,46 @@ components:
- SUCCESS
- PARTIAL_SUCCESS
- FAILED
VersionInfo:
type: "object"
properties:
groupId:
type: "string"
description: "Maven artifact group ID."
actifactId:
type: "string"
description: "Maven artifact ID."
version:
type: "string"
description: "Maven artifact version"
buildTime:
type: "string"
description: "Maven artifact build time"
branch:
type: "string"
description: "Current git branch"
commitId:
type: "string"
description: "Latest commit hash"
commitMessage:
type: "string"
description: "Latest commit message"
connectedOuterServices:
type: "array"
description: "Connected outer services information"
items:
$ref: "#/components/schemas/ConnectedOuterService"
description: "Version info."
ConnectedOuterService:
type: "object"
properties:
name:
type: "string"
description: "Connected outer service name."
version:
type: "string"
description: "Connected outer service version."
description: "Connected outer service information."
securitySchemes:
JWT:
type: http
......
......@@ -331,6 +331,27 @@
}
}
}
},
"/info": {
"get": {
"tags": [
"info"
],
"summary": "Version info",
"description": "For deployment available public `/info` endpoint, which provides build and git related information.",
"operationId": "Version info",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Version info.",
"schema": {
"$ref": "#/components/schemas/VersionInfo"
}
}
}
}
}
},
"components": {
......@@ -415,6 +436,61 @@
}
}
}
},
"VersionInfo": {
"type": "object",
"properties": {
"groupId": {
"type": "string",
"description": "Maven artifact group ID."
},
"artifactId": {
"type": "string",
"description": "Maven artifact ID."
},
"version": {
"type": "string",
"description": "Maven artifact version"
},
"buildTime": {
"type": "string",
"description": "Maven artifact build time"
},
"branch": {
"type": "string",
"description": "Current git branch"
},
"commitId": {
"type": "string",
"description": "Latest commit hash"
},
"commitMessage": {
"type": "string",
"description": "Latest commit message"
},
"connectedOuterServices": {
"type": "array",
"description": "Connected outer services information",
"items": {
"$ref": "#/components/schemas/ConnectedOuterService"
}
}
},
"description": "Version info."
},
"ConnectedOuterService": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Connected outer service name."
},
"version": {
"type": "string",
"description": "Connected outer service version."
}
},
"description": "Connected outer service information."
}
},
"securitySchemes": {
......
......@@ -90,3 +90,37 @@ curl --location --request POST 'localhost:8080/backup/v1/backup_import'
"asset":"DATASTORE"
}''
```
## Version info endpoint
For deployment available public `/info` endpoint, which provides build and git related information.
#### Example response:
```json
{
"groupId": "org.opengroup.osdu",
"artifactId": "storage-gcp",
"version": "0.10.0-SNAPSHOT",
"buildTime": "2021-07-09T14:29:51.584Z",
"branch": "feature/GONRG-2681_Build_info",
"commitId": "7777",
"commitMessage": "Added copyright to version info properties file",
"connectedOuterServices": [
{
"name": "elasticSearch",
"version":"..."
},
{
"name": "postgresSql",
"version":"..."
},
{
"name": "redis",
"version":"..."
}
]
}
```
This endpoint takes information from files, generated by `spring-boot-maven-plugin`,
`git-commit-id-plugin` plugins. Need to specify paths for generated files to matching
properties:
- `version.info.buildPropertiesPath`
- `version.info.gitPropertiesPath`
\ No newline at end of file
......@@ -52,6 +52,47 @@
</snapshotRepository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.5</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>Default</id>
......@@ -70,5 +111,5 @@
</properties>
</profile>
</profiles>
</project>
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