Skip to content

Commit

Permalink
Merge branch 'master' into moveDittoHeaderToIngress
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeckle authored Nov 2, 2023
2 parents 7a27377 + e6f1636 commit 9bcf53a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<asm.version>9.2</asm.version>
<qpid-jms-client.version>1.10.0</qpid-jms-client.version>
<pjfanning-pekko-rabbitmq.version>7.0.0</pjfanning-pekko-rabbitmq.version>
<amqp-client.version>5.14.3</amqp-client.version>
<amqp-client.version>5.18.0</amqp-client.version>
<reactive-streams.version>1.0.4</reactive-streams.version>
<netty-bom.version>4.1.99.Final</netty-bom.version>
<cloudevents.version>2.3.0</cloudevents.version>
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ services:
restart: always

swagger-ui:
image: docker.io/swaggerapi/swagger-ui:v5.7.2
image: docker.io/swaggerapi/swagger-ui:v5.9.1
mem_limit: 32m
restart: always
environment:
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/sandbox/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ services:
restart: always

swagger-ui:
image: docker.io/swaggerapi/swagger-ui:v5.7.2
image: docker.io/swaggerapi/swagger-ui:v5.9.1
mem_limit: 32m
cpu_shares: 50
restart: always
Expand Down
30 changes: 15 additions & 15 deletions deployment/helm/ditto/templates/swaggerui-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ spec:
{{- end }}
initContainers:
- name: {{ .Chart.Name }}-swaggerui-init
image: "docker.io/boky/alpine-bootstrap:latest"
image: "docker.io/curlimages/curl:8.3.0"
imagePullPolicy: {{ .Values.swaggerui.image.pullPolicy }}
command:
- sh
- -ec
- |
mkdir -p /usr/share/nginx/html/openapi
curl -sL https://raw.githubusercontent.com/eclipse/ditto/{{ .Chart.AppVersion }}/documentation/src/main/resources/openapi/ditto-api-2.yml -o /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "\=- url: 'https://ditto.eclipseprojects.io/'=d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/description: online Ditto Sandbox/d" /usr/share/nginx/html/openapi/ditto-api-2.yml
mkdir -p ~/openapi
curl -sL https://raw.githubusercontent.com/eclipse/ditto/{{ .Chart.AppVersion }}/documentation/src/main/resources/openapi/ditto-api-2.yml -o ~/openapi/ditto-api-2.yml
sed --in-place "\=- url: 'https://ditto.eclipseprojects.io/'=d" ~/openapi/ditto-api-2.yml
sed --in-place "/description: online Ditto Sandbox/d" ~/openapi/ditto-api-2.yml
echo "removing Google auth from ditto-api-2.yml"
sed --in-place "/- Google:/,+1d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/ Google:/,+9d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/- Google:/,+1d" ~/openapi/ditto-api-2.yml
sed --in-place "/ Google:/,+9d" ~/openapi/ditto-api-2.yml
{{- if or (not .Values.gateway.config.authentication.enablePreAuthentication) .Values.global.jwtOnly }}
echo "removing NginxBasic auth from ditto-api-2.yml"
sed --in-place "/- NginxBasic: \[]/d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/ NginxBasic:/,+3d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/- NginxBasic: \[]/d" ~/openapi/ditto-api-2.yml
sed --in-place "/ NginxBasic:/,+3d" ~/openapi/ditto-api-2.yml
{{- end }}
{{- if eq .Values.gateway.config.authentication.devops.authMethod "oauth2" }}
echo "removing DevOpsBasic auth from ditto-api-2.yml"
sed --in-place "/- DevOpsBasic: \[]/d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/ DevOpsBasic:/,+3d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/- DevOpsBasic: \[]/d" ~/openapi/ditto-api-2.yml
sed --in-place "/ DevOpsBasic:/,+3d" ~/openapi/ditto-api-2.yml
{{- else }}
echo "removing DevOpsBearer auth from ditto-api-2.yml"
sed --in-place "/- DevOpsBearer: \[]/d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/ DevOpsBearer:/,+4d" /usr/share/nginx/html/openapi/ditto-api-2.yml
sed --in-place "/- DevOpsBearer: \[]/d" ~/openapi/ditto-api-2.yml
sed --in-place "/ DevOpsBearer:/,+4d" ~/openapi/ditto-api-2.yml
{{- end }}
sed --in-place "s=- url: /=- url: {{ .Values.global.proxyPart }}/=g" /usr/share/nginx/html/openapi/ditto-api-2.yml
cp -rv /usr/share/nginx/html/openapi/. /init-config/
sed --in-place "s=- url: /=- url: {{ .Values.global.proxyPart }}/=g" ~/openapi/ditto-api-2.yml
cp -rv ~/openapi/. /init-config/
volumeMounts:
- name: swagger-ui-init-config
mountPath: /init-config
Expand Down
2 changes: 1 addition & 1 deletion deployment/helm/ditto/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ swaggerui:
# repository for the swagger ui docker image
repository: docker.io/swaggerapi/swagger-ui
# tag for the swagger ui docker image
tag: v4.19.1
tag: v5.9.1
# pullPolicy for the swagger ui docker image
pullPolicy: IfNotPresent
# extraEnv to add arbitrary environment variable to swagger ui container
Expand Down
2 changes: 1 addition & 1 deletion deployment/kubernetes/deploymentFiles/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
spec:
containers:
- name: swagger-ui
image: docker.io/swaggerapi/swagger-ui:v5.7.2
image: docker.io/swaggerapi/swagger-ui:v5.9.1
env:
- name: QUERY_CONFIG_ENABLED
value: "true"
Expand Down
6 changes: 3 additions & 3 deletions documentation/src/main/resources/_layouts/swagger_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
{% include head.html %}

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.7.2/swagger-ui.css" >
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.9.1/swagger-ui.css" >
<link rel="stylesheet" type="text/css" href="css/swagger.css" >
<style>
html
Expand Down Expand Up @@ -34,8 +34,8 @@
{% include footer.html %}
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.7.2/swagger-ui-bundle.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.7.2/swagger-ui-standalone-preset.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.9.1/swagger-ui-bundle.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.9.1/swagger-ui-standalone-preset.js"> </script>
{{content}}

</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public final class ThingFieldSelector implements JsonFieldSelector {
.withoutUrlDecoding()
.build();
static final List<String> SELECTABLE_FIELDS = Arrays.asList("thingId", "policyId", "definition",
"_namespace", "_revision", "_created", "_modified", "_metadata", "_policy", "_context", "_context(/[^,]+)?",
"features(/[^,]+)?", "attributes(/[^,]+)?");
"_namespace", "_revision", "_created", "_modified", "_metadata(/[^,]+)?", "_policy", "_context",
"_context(/[^,]+)?", "features(/[^,]+)?", "attributes(/[^,]+)?");
private static final String KNOWN_FIELDS_REGEX = "/?(" + String.join("|", SELECTABLE_FIELDS) + ")";
private static final String FIELD_SELECTION_REGEX = "^" + KNOWN_FIELDS_REGEX + "(," + KNOWN_FIELDS_REGEX + ")*$";
private static final Pattern FIELD_SELECTION_PATTERN = Pattern.compile(FIELD_SELECTION_REGEX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,12 @@ public static JsonFieldSelector expandFeatureIdWildcards(final Collection<JsonKe
*/
public static Stream<JsonPointer> expandFeatureIdWildcard(final Collection<JsonKey> featureIds,
final JsonPointer jsonPointer) {
if (hasFeatureIdWildcard(jsonPointer)) {
if (hasMetadataFeatureIdWildcard(jsonPointer)) {
return featureIds.stream().map(fid -> Thing.JsonFields.METADATA.getPointer()
.append(Thing.JsonFields.FEATURES.getPointer())
.append(JsonPointer.of(fid))
.append(jsonPointer.getSubPointer(3).orElse(JsonPointer.empty())));
} else if (hasFeatureIdWildcard(jsonPointer)) {
return featureIds.stream().map(fid -> Thing.JsonFields.FEATURES.getPointer()
.append(JsonPointer.of(fid))
.append(jsonPointer.getSubPointer(2).orElse(JsonPointer.empty())));
Expand All @@ -806,11 +811,33 @@ public static Stream<JsonPointer> expandFeatureIdWildcard(final Collection<JsonK
}

private static boolean hasFeatureIdWildcard(final JsonPointer pointer) {
return pointer.getLevelCount() > 1
&& pointer.getRoot()
return pointer.getLevelCount() > 1 &&
isFeaturePath(pointer) && pointer.get(1).filter(FEATURE_ID_WILDCARD::equals).isPresent();
}

private static boolean isFeaturePath(final JsonPointer pointer) {
return pointer.getRoot()
.filter(root -> Thing.JsonFields.FEATURES.getPointer().equals(JsonPointer.of(root)))
.isPresent();
}

private static boolean hasMetadataFeatureIdWildcard(final JsonPointer pointer) {
return pointer.getLevelCount() > 2 &&
isMetadataFeaturePath(pointer) &&
pointer.get(2).filter(FEATURE_ID_WILDCARD::equals).isPresent();
}

private static boolean isMetadataFeaturePath(final JsonPointer pointer) {
return pointer.getRoot()
.filter(root -> Thing.JsonFields.METADATA.getPointer().equals(JsonPointer.of(root)))
.isPresent()
&& pointer.get(1).filter(FEATURE_ID_WILDCARD::equals).isPresent();
&&
pointer.getSubPointer(1)
.map(metadataRoot -> metadataRoot.getRoot()
.filter(subRoot -> Thing.JsonFields.FEATURES.getPointer()
.equals(JsonPointer.of(subRoot)))
.isPresent()
).orElse(false);
}

}

0 comments on commit 9bcf53a

Please sign in to comment.