Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
LEDfan committed Mar 14, 2023
2 parents ff3f75a + 399b3e8 commit c835240
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 60 deletions.
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pipeline {
agent {
kubernetes {
yamlFile 'kubernetesPod.yaml'
workspaceVolume dynamicPVC(accessModes: 'ReadWriteOnce', requestsSize: '40Gi')
}
}

Expand All @@ -20,7 +21,7 @@ pipeline {

configFileProvider([configFile(fileId: 'maven-settings-rsb', variable: 'MAVEN_SETTINGS_RSB')]) {

sh 'mvn -B -s $MAVEN_SETTINGS_RSB -U clean install deploy -DskipTests=true'
sh 'mvn -B -s $MAVEN_SETTINGS_RSB -Dmaven.repo.local=/home/jenkins/agent/m2 -U clean install deploy -DskipTests=true'

}
}
Expand Down
42 changes: 22 additions & 20 deletions kubernetesPod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ metadata:
labels:
ci: containerproxy-build
spec:
volumes:
- name: maven-repo
emptyDir: {}
securityContext:
fsGroup: 65534
containers:
- name: containerproxy-build
image: 196229073436.dkr.ecr.eu-west-1.amazonaws.com/openanalytics/containerproxy-build
securityContext:
privileged: true
command: ["sh"]
args: ["/usr/src/app/docker-entrypoint.sh"]
tty: true
volumeMounts:
- mountPath: ~/.m2
name: maven-repo
resources:
requests:
memory: "2Gi"
cpu: "1.0"
limits:
memory: "4Gi"
cpu: "1.5"
- name: containerproxy-build
image: 196229073436.dkr.ecr.eu-west-1.amazonaws.com/openanalytics/containerproxy-build
securityContext:
privileged: true
command: [ "sh" ]
args: [ "/usr/src/app/docker-entrypoint.sh" ]
tty: true
volumeMounts:
- name: workspace-volume
subPath: docker
mountPath: /var/lib/docker
resources:
requests:
ephemeral-storage: "20Gi"
memory: "2Gi"
cpu: "1.0"
limits:
memory: "4Gi"
cpu: "1.5"
ephemeral-storage: "20Gi"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>eu.openanalytics</groupId>
<artifactId>containerproxy</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<name>ContainerProxy</name>
<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
*/
package eu.openanalytics.containerproxy.auth.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

Expand Down Expand Up @@ -73,13 +75,24 @@ private SimpleUser loadUser(int index) {
String userName = environment.getProperty(String.format("proxy.users[%d].name", index));
if (userName == null) return null;
String password = environment.getProperty(String.format("proxy.users[%d].password", index));
String[] roles = environment.getProperty(String.format("proxy.users[%d].groups", index), String[].class);
if (roles == null) {
roles = new String[0];

// method 1: single property with comma seperated groups
String[] groups = environment.getProperty(String.format("proxy.users[%d].groups", index), String[].class);
if (groups != null) {
groups = Arrays.stream(groups).map(String::toUpperCase).toArray(String[]::new);
return new SimpleUser(userName, password, groups);
} else {
roles = Arrays.stream(roles).map(s -> s.toUpperCase()).toArray(i -> new String[i]);
// method 2: YAML array
List<String> groupsList = new ArrayList<>();
int groupIndex = 0;
String group = environment.getProperty(String.format("proxy.users[%d].groups[%d]", index, groupIndex));
while (group != null) {
groupsList.add(group.toUpperCase());
groupIndex++;
group = environment.getProperty(String.format("proxy.users[%d].groups[%d]", index, groupIndex));
}
return new SimpleUser(userName, password, groupsList.toArray(new String[0]));
}
return new SimpleUser(userName, password, roles);
}

private static class SimpleUser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
package eu.openanalytics.containerproxy.spec.expression;

import eu.openanalytics.containerproxy.ContainerProxyException;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
Expand All @@ -34,9 +33,7 @@
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionException;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeConverter;
Expand All @@ -48,6 +45,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Note: inspired by org.springframework.context.expression.StandardBeanExpressionResolver
Expand Down Expand Up @@ -136,11 +134,14 @@ public List<String> evaluateToList(List<String> expressions, SpecExpressionConte
if (expressions == null) return null;
return expressions.stream()
.flatMap((el) -> {
List<String> result = evaluate(el, context, List.class);
Object result = evaluate(el, context, Object.class);
if (result == null) {
result = new ArrayList<>();
}
return result.stream();
if (result instanceof List) {
return ((List<Object>) result).stream().map(Object::toString);
}
return Stream.of(result.toString());
})
.collect(Collectors.toList());
}
Expand Down

This file was deleted.

0 comments on commit c835240

Please sign in to comment.