Skip to content

Commit

Permalink
Merge pull request #464 from Decathlon/feat/expose-swagger
Browse files Browse the repository at this point in the history
feat: expose swagger ui
  • Loading branch information
TroyonGuillaume authored Jul 16, 2021
2 parents 86ad7e2 + f89ff8c commit 27414e3
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 42 deletions.
2 changes: 1 addition & 1 deletion charts/candidate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ara
version: 9.1.1-rc.1
version: 9.2.0-rc.1
home: https://github.com/Decathlon/ara
description: |
ARA helps you to fight against regressions by letting it preanalyze your non-regression tests runs,
Expand Down
4 changes: 3 additions & 1 deletion charts/candidate/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ data:
database_type: {{ .Values.database.type }}
liquibase_active: {{ .Values.database.liquibaseActive | quote }}
app_url: {{ .Values.api.appUrl }}
api_url: {{ printf "%s-%s-api.%s.svc.cluster.local:%.0f" .Release.Name .Chart.Name .Release.Namespace .Values.api.port }}
api_host: {{ printf "%s-%s-api.%s.svc.cluster.local" .Release.Name .Chart.Name .Release.Namespace }}
api_port: {{ printf "%.0f" .Values.api.port | quote }}
api_management_port: {{ printf "%.0f" .Values.api.management.port | quote }}

{{- if not .Values.api.configExistingSecret.enabled }}
---
Expand Down
22 changes: 18 additions & 4 deletions charts/candidate/templates/deploy-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ spec:
imagePullPolicy: {{ .Values.api.image.imagePullPolicy }}
env:
- name: SERVER_PORT
value: "{{ .Values.api.port }}"
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: api_port
- name: MANAGEMENT_SERVER_PORT
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: api_management_port
- name: ARA_DATABASE_TARGET
valueFrom:
configMapKeyRef:
Expand Down Expand Up @@ -82,18 +90,20 @@ spec:
ports:
- containerPort: {{ .Values.api.port }}
name: http-port
- containerPort: {{ .Values.api.management.port }}
name: management-port
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: {{ .Values.api.port }}
port: {{ .Values.api.management.port }}
initialDelaySeconds: 40
timeoutSeconds: 2
periodSeconds: 3
failureThreshold: 2
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: {{ .Values.api.port }}
port: {{ .Values.api.management.port }}
initialDelaySeconds: 100
timeoutSeconds: 2
periodSeconds: 8
Expand Down Expand Up @@ -125,8 +135,12 @@ metadata:
spec:
type: ClusterIP
ports:
- port: {{ .Values.api.port }}
- name: http
port: {{ .Values.api.port }}
targetPort: http-port
- name: management
port: {{ .Values.api.management.port }}
targetPort: management-port
selector:
app.kubernetes.io/name: {{ include "ara.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
14 changes: 12 additions & 2 deletions charts/candidate/templates/deploy-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ spec:
image: "{{ .Values.ui.image.registry }}/{{ .Values.ui.image.repository }}:{{ default .Chart.Version .Values.ui.image.tag }}"
imagePullPolicy: {{ .Values.ui.image.imagePullPolicy }}
env:
- name: API_URL
- name: ARA_API_HOST
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: api_url
key: api_host
- name: ARA_API_PORT
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: api_port
- name: ARA_MANAGEMENT_PORT
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: api_management_port
ports:
- containerPort: {{ .Values.ui.port }}
name: http-port
Expand Down
6 changes: 3 additions & 3 deletions charts/candidate/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ spec:
path: /
- backend:
serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }}
servicePort: http-port
servicePort: http
path: /api
- backend:
serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }}
servicePort: http-port
servicePort: management
path: /actuator
- backend:
serviceName: {{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }}
servicePort: http-port
servicePort: http
path: /auth
{{- if .Values.ingress.tls }}
tls:
Expand Down
6 changes: 4 additions & 2 deletions charts/candidate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ api:
image:
registry: docker.io
repository: decathlon/ara-api
tag: 9.0.9
tag: 10.0.0
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand All @@ -24,6 +24,8 @@ api:
# cpu: 100m
# memory: 128Mi
port: 8080
management:
port: 9090
# Base url used to redirect on the app by email service among others
appUrl: ara.test
authConfig: ""
Expand All @@ -44,7 +46,7 @@ ui:
image:
registry: docker.io
repository: decathlon/ara-web-ui
tag: 8.7.0
tag: 9.0.0
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand Down
10 changes: 8 additions & 2 deletions code/api/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-api</artifactId>
<version>9.0.9</version>
<version>10.0.0</version>

<name>ARA API</name>
<description>
Expand All @@ -41,6 +41,7 @@
<ara.default.database>h2</ara.default.database>
<spring.profiles.active />
<mapstruct.version>1.4.2.Final</mapstruct.version>
<springdoc.version>1.5.9</springdoc.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<jacoco.phase.agent>initialize</jacoco.phase.agent>
Expand Down Expand Up @@ -176,8 +177,13 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.5</version>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>${springdoc.version}</version>
</dependency>

<!-- Mail Sending & Templating -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SecurityConfigurer extends WebSecurityConfigurerAdapter {

private final String[] swaggerResources = {
"/v3/api-docs/**",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/swagger-ui/**",
"/webjars/**"
};

@NonNull
private AuthenticationConfiguration authenticationConfiguration;

Expand All @@ -69,8 +59,8 @@ protected void configure(HttpSecurity http) throws Exception {
.and()
.authorizeRequests()//NOSONAR
.antMatchers("/actuator/info", "/actuator/health/**").permitAll()
.antMatchers("/actuator/swaggerui/**", "/actuator/swagger-ui/**", "/actuator/openapi/**").permitAll()
.antMatchers("/auth/**").permitAll()
.antMatchers(swaggerResources).permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
Expand Down
5 changes: 4 additions & 1 deletion code/api/api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ spring:
springdoc:
packagesToScan: com.decathlon.ara
pathsToMatch: /api/**
use-management-port: true

#
# Sensible default values, optionally customizable by clients
Expand Down Expand Up @@ -81,10 +82,12 @@ ara:
clientBaseUrl: http://localhost:8081/

management:
server:
port: 9090
endpoints:
web:
exposure:
include: health,info
include: health, info, openapi, swaggerui
# Metrics
metrics:
export:
Expand Down
2 changes: 1 addition & 1 deletion code/api/database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-database</artifactId>
<version>9.0.9</version>
<version>10.0.0</version>

<name>ARA Database</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion code/api/generated-cucumber-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-generated-cucumber-report</artifactId>
<version>9.0.9</version>
<version>10.0.0</version>

<name>ARA Cucumber</name>
<description>
Expand Down
4 changes: 2 additions & 2 deletions code/api/jacoco-aggregation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<artifactId>ara-parent</artifactId>
<groupId>com.decathlon.ara</groupId>
<version>9.0.9</version>
<version>10.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>com.decathlon.ara</groupId>
<artifactId>jacoco-aggregation</artifactId>
<packaging>pom</packaging>
<version>9.0.9</version>
<version>10.0.0</version>

<name>Jacoco Report Aggregation</name>

Expand Down
2 changes: 1 addition & 1 deletion code/api/lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-lib</artifactId>
<version>9.0.9</version>
<version>10.0.0</version>

<properties>
<java.version>16</java.version>
Expand Down
2 changes: 1 addition & 1 deletion code/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<groupId>com.decathlon.ara</groupId>
<artifactId>ara-parent</artifactId>
<packaging>pom</packaging>
<version>9.0.9</version>
<version>10.0.0</version>

<name>ARA Parent</name>
<description>
Expand Down
4 changes: 3 additions & 1 deletion code/docker-compose-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ services:
image: "decathlon/ara-web-ui:${WEB_UI_VERSION:-latest}"
restart: always
environment:
- API_URL=ara-mysql-api:8080
- ARA_API_HOST=ara-mysql-api
- ARA_API_PORT=8080
- ARA_MANAGEMENT_PORT=9090
ports:
- 8081:80
networks:
Expand Down
4 changes: 3 additions & 1 deletion code/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ services:
image: "decathlon/ara-web-ui:${WEB_UI_VERSION:-latest}"
restart: always
environment:
- API_URL=ara-api:8080
- ARA_API_HOST=ara-api
- ARA_API_PORT=8080
- ARA_MANAGEMENT_PORT=9090
ports:
- 8081:80
networks:
Expand Down
4 changes: 3 additions & 1 deletion code/web-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RUN npm run build

FROM nginx:1.19

ENV API_URL localhost
ENV ARA_API_HOST localhost
ENV ARA_API_PORT 8080
ENV ARA_MANAGEMENT_PORT 9090

COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
COPY config/default.conf.template /etc/nginx/templates/default.conf.template
Expand Down
6 changes: 3 additions & 3 deletions code/web-ui/config/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ server {
#access_log /var/log/nginx/host.access.log main;

location /auth {
proxy_pass http://${API_URL}/auth;
proxy_pass http://${ARA_API_HOST}:${ARA_API_PORT}/auth;
}

location /api {
proxy_pass http://${API_URL}/api;
proxy_pass http://${ARA_API_HOST}:${ARA_API_PORT}/api;
}

location /actuator {
proxy_pass http://${API_URL}/actuator;
proxy_pass http://${ARA_API_HOST}:${ARA_MANAGEMENT_PORT}/actuator;
}

location / {
Expand Down
4 changes: 3 additions & 1 deletion code/web-ui/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ var path = require('path')

var araAPIHost = process.env.ARA_API_HOST || 'localhost'
var araAPIPort = process.env.ARA_API_PORT || 8080
var araManagementPort = process.env.ARA_MANAGEMENT_PORT || 9090

var araAPIURL = 'http://' + araAPIHost + ':' + araAPIPort
var araManagementURL = 'http://' + araAPIHost + ':' + araManagementPort

var PACKAGE = require('../package.json')
var version = PACKAGE.version
Expand Down Expand Up @@ -60,7 +62,7 @@ module.exports = {
changeOrigin: true
},
'/actuator': {
target: araAPIURL,
target: araManagementURL,
changeOrigin: true
},
'/demo-files': {
Expand Down
2 changes: 1 addition & 1 deletion code/web-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/web-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ara-client",
"version": "8.7.0",
"version": "9.0.0",
"description": "Agile Regression Analyzer front app",
"author": "Decathlon <[email protected]>",
"private": true,
Expand Down

0 comments on commit 27414e3

Please sign in to comment.