Skip to content

Commit bc906d5

Browse files
authored
Merge pull request #620 from overture-stack/rc/5.0.0
Release 5.0.0 upgrade spring boot upgrade spring cloud version fix profiles fix vault update to new spring data page-able interface
2 parents c5bbe9b + 8831029 commit bc906d5

File tree

9 files changed

+135
-40
lines changed

9 files changed

+135
-40
lines changed

Jenkinsfile

+8-7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spec:
2424
image: docker:18.06-dind
2525
securityContext:
2626
privileged: true
27+
runAsUser: 0
2728
volumeMounts:
2829
- name: docker-graph-storage
2930
mountPath: /var/lib/docker
@@ -35,14 +36,14 @@ spec:
3536
- name: docker
3637
image: docker:18-git
3738
tty: true
38-
volumeMounts:
39-
- mountPath: /var/run/docker.sock
40-
name: docker-sock
39+
env:
40+
- name: DOCKER_HOST
41+
value: tcp://localhost:2375
42+
- name: HOME
43+
value: /home/jenkins/agent
44+
securityContext:
45+
runAsUser: 1000
4146
volumes:
42-
- name: docker-sock
43-
hostPath:
44-
path: /var/run/docker.sock
45-
type: File
4647
- name: docker-graph-storage
4748
emptyDir: {}
4849
"""

docker-compose-all.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '3.7'
2+
services:
3+
api:
4+
build:
5+
context: ./
6+
dockerfile: Dockerfile
7+
restart: always
8+
environment:
9+
SERVER_PORT: 8080
10+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified
11+
SPRING_DATASOURCE_USERNAME: postgres
12+
SPRING_DATASOURCE_PASSWORD: password
13+
SPRING_FLYWAY_ENABLED: "true"
14+
SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration"
15+
SPRING_PROFILES: demo, auth
16+
expose:
17+
- "8080"
18+
ports:
19+
- "$API_HOST_PORT:8080"
20+
depends_on:
21+
- postgres
22+
postgres:
23+
image: postgres:12.6
24+
restart: always
25+
environment:
26+
- POSTGRES_DB=ego
27+
- POSTGRES_PASSWORD=password
28+
expose:
29+
- "5432"
30+
ports:
31+
- "8432:5432"

docker-compose.yml

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
version: '3.7'
22
services:
3-
api:
4-
build:
5-
context: ./
6-
dockerfile: Dockerfile
7-
restart: always
3+
ego-ui:
4+
image: overture/ego-ui:edge
5+
network_mode: host
86
environment:
9-
SERVER_PORT: 8080
10-
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified
11-
SPRING_DATASOURCE_USERNAME: postgres
12-
SPRING_DATASOURCE_PASSWORD: password
13-
SPRING_FLYWAY_ENABLED: "true"
14-
SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration"
15-
SPRING_PROFILES: demo, auth
16-
expose:
17-
- "8080"
18-
ports:
19-
- "$API_HOST_PORT:8080"
20-
depends_on:
21-
- postgres
7+
REACT_APP_API: http://localhost:8081
8+
REACT_APP_EGO_CLIENT_ID: ego-ui
9+
2210
postgres:
2311
image: postgres:12.6
2412
restart: always
@@ -28,4 +16,5 @@ services:
2816
expose:
2917
- "5432"
3018
ports:
31-
- "8432:5432"
19+
- "5432:5432"
20+

pom.xml

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
<groupId>bio.overture</groupId>
77
<artifactId>ego</artifactId>
8-
<version>4.5.2</version>
8+
<version>5.0.0</version>
99

1010
<name>ego</name>
1111
<description>OAuth 2.0 Authorization service that supports multiple OpenID Connect Providers</description>
1212

1313
<parent>
1414
<groupId>org.springframework.boot</groupId>
1515
<artifactId>spring-boot-starter-parent</artifactId>
16-
<version>2.1.8.RELEASE</version>
16+
<version>2.5.6</version>
1717
<relativePath/> <!-- lookup parent from repository -->
1818
</parent>
1919

@@ -87,6 +87,7 @@
8787
<artifactId>spring-boot-starter-test</artifactId>
8888
<scope>test</scope>
8989
</dependency>
90+
9091
<dependency>
9192
<groupId>org.springframework.security</groupId>
9293
<artifactId>spring-security-test</artifactId>
@@ -106,7 +107,10 @@
106107
<groupId>org.springframework.session</groupId>
107108
<artifactId>spring-session-core</artifactId>
108109
</dependency>
109-
110+
<dependency>
111+
<groupId>org.springframework.boot</groupId>
112+
<artifactId>spring-boot-starter-validation</artifactId>
113+
</dependency>
110114
<!-- JDBC -->
111115
<dependency>
112116
<groupId>com.h2database</groupId>
@@ -292,6 +296,12 @@
292296
<scope>test</scope>
293297
</dependency>
294298

299+
<dependency>
300+
<groupId>org.junit.vintage</groupId>
301+
<artifactId>junit-vintage-engine</artifactId>
302+
<scope>test</scope>
303+
</dependency>
304+
295305
<dependency>
296306
<groupId>org.springframework.boot</groupId>
297307
<artifactId>spring-boot-devtools</artifactId>
@@ -416,7 +426,7 @@
416426
<dependency>
417427
<groupId>org.springframework.cloud</groupId>
418428
<artifactId>spring-cloud-dependencies</artifactId>
419-
<version>Greenwich.SR2</version>
429+
<version>2020.0.4</version>
420430
<type>pom</type>
421431
<scope>import</scope>
422432
</dependency>

src/main/java/bio/overture/ego/controller/resolver/PageableResolver.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Sort getSort() {
9696
// TODO: this is a hack for now to provide default sort on id field
9797
// ideally we should not be making assumption about field name as "id" - it will break if
9898
// field doesn't exist
99-
return new Sort(direction, StringUtils.isEmpty(sort) ? "id" : sort);
99+
return Sort.by(direction, StringUtils.isEmpty(sort) ? "id" : sort);
100100
}
101101

102102
@Override
@@ -114,6 +114,11 @@ public Pageable first() {
114114
return null;
115115
}
116116

117+
@Override
118+
public Pageable withPage(int pageNumber) {
119+
throw new RuntimeException("Not implemented");
120+
}
121+
117122
@Override
118123
public boolean hasPrevious() {
119124
return false;

src/main/java/bio/overture/ego/grpc/ProtoUtils.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public Pageable first() {
8787
return null;
8888
}
8989

90+
@Override
91+
public Pageable withPage(int pageNumber) {
92+
throw new RuntimeException("Not implemented");
93+
}
94+
9095
@Override
9196
public boolean hasPrevious() {
9297
return false;
@@ -97,7 +102,7 @@ public boolean hasPrevious() {
97102
public static Sort parseSort(String sort) {
98103
if (sort.isEmpty()) {
99104
// Sort results by creation time, ensure static order for the page_token to refer to
100-
return new Sort(Sort.Direction.ASC, JavaFields.CREATEDAT);
105+
return Sort.by(Sort.Direction.ASC, JavaFields.CREATEDAT);
101106
} else {
102107
val orders =
103108
Arrays.stream(sort.split(","))

src/main/java/bio/overture/ego/model/exceptions/ExceptionHandlers.java

+18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import static java.lang.String.format;
44
import static org.springframework.http.HttpStatus.BAD_REQUEST;
5+
import static org.springframework.http.HttpStatus.NOT_FOUND;
56

67
import bio.overture.ego.utils.Joiners;
8+
import java.util.Date;
9+
import java.util.Map;
710
import javax.servlet.http.HttpServletRequest;
811
import javax.validation.ConstraintViolationException;
912
import lombok.extern.slf4j.Slf4j;
@@ -17,6 +20,21 @@
1720
@ControllerAdvice
1821
public class ExceptionHandlers {
1922

23+
@ExceptionHandler(NotFoundException.class)
24+
public ResponseEntity<Object> handleConstraintViolationException(
25+
HttpServletRequest req, NotFoundException ex) {
26+
val message = ex.getMessage();
27+
log.error(message);
28+
return new ResponseEntity<Object>(
29+
Map.of(
30+
"message", ex.getMessage(),
31+
"timestamp", new Date(),
32+
"path", req.getServletPath(),
33+
"error", NOT_FOUND.getReasonPhrase()),
34+
new HttpHeaders(),
35+
NOT_FOUND);
36+
}
37+
2038
@ExceptionHandler(ConstraintViolationException.class)
2139
public ResponseEntity<Object> handleConstraintViolationException(
2240
HttpServletRequest req, ConstraintViolationException ex) {

src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java

+26
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.springframework.util.StringUtils.isEmpty;
55

66
import java.util.Map;
7+
import java.util.Optional;
78
import lombok.NonNull;
89
import lombok.RequiredArgsConstructor;
910
import lombok.val;
@@ -29,11 +30,26 @@ public Sort getSort() {
2930
return Sort.by(orders);
3031
}
3132

33+
@Override
34+
public Sort getSortOr(Sort sort) {
35+
return delegate.getSortOr(sort);
36+
}
37+
3238
private String getSortField(String sort) {
3339
val mapValue = SORT_MAP.get(sort);
3440
return isEmpty(mapValue) ? sort : mapValue;
3541
}
3642

43+
@Override
44+
public boolean isPaged() {
45+
return delegate.isPaged();
46+
}
47+
48+
@Override
49+
public boolean isUnpaged() {
50+
return delegate.isUnpaged();
51+
}
52+
3753
/** Delegated methods */
3854
@Override
3955
public int getPageNumber() {
@@ -65,8 +81,18 @@ public Pageable first() {
6581
return delegate.first();
6682
}
6783

84+
@Override
85+
public Pageable withPage(int pageNumber) {
86+
return delegate.withPage(pageNumber);
87+
}
88+
6889
@Override
6990
public boolean hasPrevious() {
7091
return delegate.hasPrevious();
7192
}
93+
94+
@Override
95+
public Optional<Pageable> toOptional() {
96+
return Optional.of(delegate);
97+
}
7298
}

src/main/resources/application.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ spring.main.allow-bean-definition-overriding: true
3838
spring.datasource:
3939
driver-class-name: org.postgresql.Driver
4040
url: jdbc:postgresql://localhost:5432/ego?stringtype=unspecified
41-
4241
username: postgres
4342
password: password
4443
max-active: 10
4544
max-idle: 1
4645
min-idle: 1
4746

4847
spring:
48+
cloud:
49+
vault:
50+
enabled: false
4951
flyway:
5052
enabled: false
5153
placeholders:
@@ -198,7 +200,9 @@ initialization:
198200
# Profile - "jks"
199201
###############################################################################
200202
spring:
201-
profiles: jks
203+
config:
204+
activate:
205+
on-profile: jks
202206

203207
token:
204208
key-store: src/main/resources/ego-jwt.jks
@@ -210,8 +214,9 @@ token:
210214
# Profile - "auth"
211215
###############################################################################
212216
spring:
213-
profiles: auth
214-
profiles.include: secure
217+
config:
218+
activate:
219+
on-profile: auth
215220

216221
# security
217222
auth:
@@ -231,7 +236,9 @@ logging:
231236
# Profile - "demo"
232237
###############################################################################
233238
spring:
234-
profiles: grpc
239+
config:
240+
activate:
241+
on-profile: grpc
235242

236243
grpc:
237244
port: 50051
@@ -241,14 +248,17 @@ grpc:
241248
# Profile - "demo"
242249
###############################################################################
243250
spring:
244-
profiles: demo
245-
251+
config:
252+
activate:
253+
on-profile: demo
246254
---
247255
###############################################################################
248256
# Profile - "test"
249257
###############################################################################
250258
spring:
251-
profiles: test
259+
config:
260+
activate:
261+
on-profile: test
252262

253263
# To log the httpRequests and httpResponses for the controllers, set to true
254264
logging.test.controller.enable: false

0 commit comments

Comments
 (0)