Skip to content

Commit

Permalink
feat(credential-operator): split operator from existing (#206)
Browse files Browse the repository at this point in the history
* feat: update values.schema.json to implement changes

* feat: set values according to operator.existing

* chore: incremental patch version increase

* chore: Update 'README.md's

* fix: un-revert changes

* fix: webdav log-handler for events incorrectly spaced

* chore: incremental increase of patch version (4allportal chart)

* chore: Update 'README.md's

---------

Co-authored-by: jpkraemer-mg <jpkraemer-mg@users.noreply.github.com>
  • Loading branch information
jpkraemer-mg and jpkraemer-mg authored Jan 29, 2024
1 parent a7b2ebb commit 4045df9
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 99 deletions.
2 changes: 1 addition & 1 deletion charts/4allportal/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "3.10.37"
description: A Helm chart for 4ALLPORTAL version 3.10.0 and up
name: 4allportal
version: 19.3.1
version: 19.3.2
icon: https://4allportal.com/wp-content/uploads/2022/07/cropped-4ap_logo.png
keywords:
- 4ALLPORTAL
Expand Down
2 changes: 1 addition & 1 deletion charts/4allportal/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 4allportal

![Version: 19.3.1](https://img.shields.io/badge/Version-19.3.1-informational?style=flat-square) ![AppVersion: 3.10.37](https://img.shields.io/badge/AppVersion-3.10.37-informational?style=flat-square)
![Version: 19.3.2](https://img.shields.io/badge/Version-19.3.2-informational?style=flat-square) ![AppVersion: 3.10.37](https://img.shields.io/badge/AppVersion-3.10.37-informational?style=flat-square)

A Helm chart for 4ALLPORTAL version 3.10.0 and up

Expand Down
24 changes: 24 additions & 0 deletions charts/4allportal/templates/4allportal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ spec:
value: {{ .Values.fourAllPortal.mail.security | quote }}
{{- end }}

{{- if .Values.fourAllPortal.database.operator.enabled }}
- name: DATABASE_USER
value: {{ required "You must set a database user when using the operator." .Values.fourAllPortal.database.operator.user | quote }}
- name: DATABASE_PASSWORD
value: {{ required "You must set a user password when using the operator." .Values.fourAllPortal.database.operator.password | quote }}
- name: DATABASE_TYPE
valueFrom:
configMapKeyRef:
name: {{ .Values.fourAllPortal.database.operator.databaseRef }}-configmap
key: "DATABASE_TYPE"
- name: DATABASE_HOST
valueFrom:
configMapKeyRef:
name: {{ .Values.fourAllPortal.database.operator.databaseRef }}-configmap
key: "DATABASE_HOST"
- name: DATABASE_PORT
valueFrom:
configMapKeyRef:
name: {{ .Values.fourAllPortal.database.operator.databaseRef }}-configmap
key: "DATABASE_PORT"
- name: DATABASE_DATABASE_NAME
value: {{ required "You must set a database name when using the operator." .Values.fourAllPortal.database.operator.databaseName | quote }}
{{ else }}
- name: DATABASE_USER
value: {{ include "4allportal.fourallportal.database.user" . | quote }}
- name: DATABASE_PASSWORD
Expand All @@ -157,6 +180,7 @@ spec:
value: {{ include "4allportal.fourallportal.database.port" . | quote }}
- name: DATABASE_DATABASE_NAME
value: {{ include "4allportal.fourallportal.database.name" . | quote }}
{{- end }}
- name: DATABASE_INITIAL_POOL_SIZE
value: {{ .Values.fourAllPortal.database.initialPoolSize | quote }}
- name: DATABASE_MAX_IDLE_TIME
Expand Down
148 changes: 74 additions & 74 deletions charts/4allportal/templates/webdav/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,81 +129,81 @@ data:
BrowserMatch "^gvfs" redirect-carefully
BrowserMatch "WebDAVLib" redirect-carefully
{{- if $.Values.webdav.events.enabled }}
log-handler.sh: |
#!/bin/ash
MOUNT_POINT="{{ $.Values.webdav.events.mountPath }}"
MOUNT_POINT_LEN=$(echo "$MOUNT_POINT" | awk '{print length($1) + 1;}')
while IFS= read -r line; do
status=$(echo "$line" | cut -d';' -f1)
type=$(echo "$line" | cut -d';' -f2)
path=$(echo "$line" | cut -d';' -f3)
dest=$(echo "$line" | cut -d';' -f4 | awk '{
i = index($1,"/webdav/");
out = substr($1, i);
for (i = 0x20; i < 0x40; ++i) {
repl = sprintf("%c", i);
if ((repl == "&") || (repl == "\\")) {
repl = "\\" repl;
}
out = gensub(sprintf("%%%02X", i), repl, "g", out);
out = gensub(sprintf("%%%02x", i), repl, "g", out);
};
out = gensub(/\"/, "\\\"", "g", out);
print out}')
matched=$(expr match "${path}" "$MOUNT_POINT.*")
if [ \( "${type}" == "PUT" -o "${type}" == "DELETE" -o "${type}" == "MKCOL" -o "${type}" == "MOVE" -o "${type}" == "COPY" \) -a ${matched} != 0 ]
then
path=$(echo "$path" | cut -c ${MOUNT_POINT_LEN}- )
if [ "${dest}" != "-" -a "${dest}" != "" ]
then
dest=$(echo "$dest" | cut -c ${MOUNT_POINT_LEN}- )
fi
lastChar=$(echo "$path" | awk '{print substr($0,length,1)}')
if [ "$lastChar" = "/" ]
then
path=$(echo "$path" | awk '{print substr($0,0,length($0)-1)}')
fi
OP="UNKNOWN"
if [ "${status}" == "201" -a "${type}" == "PUT" ]
then
OP="CREATE"
elif [ "${status}" == "201" -a "${type}" == "MKCOL" ]
then
OP="CREATE"
elif [ "${status}" == "201" -a "${type}" == "MOVE" ]
then
OP="MOVE"
elif [ "${status}" == "201" -a "${type}" == "COPY" ]
then
OP="CREATE"
elif [ "${status}" == "204" -a "${type}" == "PUT" ]
then
OP="UPDATE"
elif [ "${status}" == "204" -a "${type}" == "DELETE" ]
then
OP="DELETE"
fi
BODY="{}"
ENDPOINT="http://{{ include "common.names.fullname" . }}-backend/api/extensions/dam/mounts/${MOUNT_POINT}/events/${type}"
if [ "${dest}" == "-" -o "${dest}" == "" ]
log-handler.sh: |
#!/bin/ash
MOUNT_POINT="{{ $.Values.webdav.events.mountPath }}"
MOUNT_POINT_LEN=$(echo "$MOUNT_POINT" | awk '{print length($1) + 1;}')
while IFS= read -r line; do
status=$(echo "$line" | cut -d';' -f1)
type=$(echo "$line" | cut -d';' -f2)
path=$(echo "$line" | cut -d';' -f3)
dest=$(echo "$line" | cut -d';' -f4 | awk '{
i = index($1,"/webdav/");
out = substr($1, i);
for (i = 0x20; i < 0x40; ++i) {
repl = sprintf("%c", i);
if ((repl == "&") || (repl == "\\")) {
repl = "\\" repl;
}
out = gensub(sprintf("%%%02X", i), repl, "g", out);
out = gensub(sprintf("%%%02x", i), repl, "g", out);
};
out = gensub(/\"/, "\\\"", "g", out);
print out}')
matched=$(expr match "${path}" "$MOUNT_POINT.*")
if [ \( "${type}" == "PUT" -o "${type}" == "DELETE" -o "${type}" == "MKCOL" -o "${type}" == "MOVE" -o "${type}" == "COPY" \) -a ${matched} != 0 ]
then
BODY="{\"path\":\"${path}\"}"
echo "Send notification to ${ENDPOINT}: ${BODY}" > /proc/self/fd/1
else
BODY="{\"path\":\"${path}\",\"destination\":\"${dest}\"}"
echo "Send notification to ${ENDPOINT}: ${BODY}" > /proc/self/fd/1
path=$(echo "$path" | cut -c ${MOUNT_POINT_LEN}- )
if [ "${dest}" != "-" -a "${dest}" != "" ]
then
dest=$(echo "$dest" | cut -c ${MOUNT_POINT_LEN}- )
fi
lastChar=$(echo "$path" | awk '{print substr($0,length,1)}')
if [ "$lastChar" = "/" ]
then
path=$(echo "$path" | awk '{print substr($0,0,length($0)-1)}')
fi
OP="UNKNOWN"
if [ "${status}" == "201" -a "${type}" == "PUT" ]
then
OP="CREATE"
elif [ "${status}" == "201" -a "${type}" == "MKCOL" ]
then
OP="CREATE"
elif [ "${status}" == "201" -a "${type}" == "MOVE" ]
then
OP="MOVE"
elif [ "${status}" == "201" -a "${type}" == "COPY" ]
then
OP="CREATE"
elif [ "${status}" == "204" -a "${type}" == "PUT" ]
then
OP="UPDATE"
elif [ "${status}" == "204" -a "${type}" == "DELETE" ]
then
OP="DELETE"
fi
BODY="{}"
ENDPOINT="http://{{ include "common.names.fullname" . }}-backend/api/extensions/dam/mounts/${MOUNT_POINT}/events/${type}"
if [ "${dest}" == "-" -o "${dest}" == "" ]
then
BODY="{\"path\":\"${path}\"}"
echo "Send notification to ${ENDPOINT}: ${BODY}" > /proc/self/fd/1
else
BODY="{\"path\":\"${path}\",\"destination\":\"${dest}\"}"
echo "Send notification to ${ENDPOINT}: ${BODY}" > /proc/self/fd/1
fi
RES_CODE=$(curl -X POST -sw "%{http_code}\n" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer { {{ include "4allportal.fourAllPortal.systemApiKey" . }} }"
-d "$BODY" \
--connect-timeout 1 -o /dev/null ${ENDPOINT})
echo "Response status: ${RES_CODE}" > /proc/self/fd/1
fi
RES_CODE=$(curl -X POST -sw "%{http_code}\n" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer { {{ include "4allportal.fourAllPortal.systemApiKey" . }} }"
-d "$BODY" \
--connect-timeout 1 -o /dev/null ${ENDPOINT})
echo "Response status: ${RES_CODE}" > /proc/self/fd/1
fi
done
done
{{- end }}
{{- end }}
48 changes: 25 additions & 23 deletions charts/4allportal/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,35 @@
"existing": {
"type": "object"
}
},
{
"operator": {
"type": "object",
"description": "Options for the Credentials Operator",
"properties": {
"enabled": {
"type": "boolean",
"default": false
},
"user": {
"type": "string"
},
"password": {
"type": "string"
},
"databaseName": {
"type": "string"
},
"databaseRef": {
"type": "string"
}
}
}
}
]
},
{
"properties": {
"operator": {
"type": "object",
"description": "Options for the Credentials Operator",
"properties": {
"enabled": {
"type": "boolean",
"default": false
},
"user": {
"type": "string"
},
"password": {
"type": "string"
},
"databaseName": {
"type": "string"
},
"databaseRef": {
"type": "string"
}
}
},
"acquireIncrement": {
"type": "integer"
},
Expand Down Expand Up @@ -391,7 +393,7 @@
"maxscale": {
"type": "object",
"description": "Refer to https://raw.githubusercontent.com/4ALLPORTAL/helm-charts/main/charts/maxscale/values.schema.json",
"$ref": "https://raw.githubusercontent.com/4ALLPORTAL/helm-charts/main/charts/maxscale/values.schema.json"
"$ref": "https://raw.githubusercontent.com/4ALLPORTAL/helm-charts/main/charts/maxscale/values.schema.json"
},
"dreiDRenderer": {
"type": "object",
Expand Down

0 comments on commit 4045df9

Please sign in to comment.