Skip to content

Commit

Permalink
Merge pull request #43 from ggtakec/update_files
Browse files Browse the repository at this point in the history
Fixed due to changes in k2hr3 api/app
  • Loading branch information
ggtakec authored Sep 8, 2023
2 parents 036771f + d4d8b0b commit 247dc41
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 55 deletions.
71 changes: 52 additions & 19 deletions .github/workflows/helm_template.result
Original file line number Diff line number Diff line change
Expand Up @@ -763,26 +763,43 @@ data:

RUN_SCRIPT="${K2HR3_API_DIR}/bin/run.sh"
PRODUCTION_DIR="${K2HR3_API_DIR}/config"

# [NOTE]
# Configuration files accept json or json5 extensions.
#
PRODUCTION_FILE="${PRODUCTION_DIR}/production.json"
PRODUCTION5_FILE="${PRODUCTION_DIR}/production.json5"
CONFIGMAP_PRODUCTION_FILE="/configmap/k2hr3-api-production.json"
CONFIGMAP_PRODUCTION5_FILE="/configmap/k2hr3-api-production.json5"
LOCAL_FILE="${PRODUCTION_DIR}/local.json"
LOCAL5_FILE="${PRODUCTION_DIR}/local.json5"
CONFIGMAP_LOCAL_FILE="/configmap/k2hr3-api-local.json"
CONFIGMAP_LOCAL5_FILE="/configmap/k2hr3-api-local.json5"

if [ ! -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
exit 1
fi
if [ ! -d "${PRODUCTION_DIR}" ]; then
if ! mkdir -p "${PRODUCTION_DIR}"; then
exit 1
fi
fi
if ! cp "${CONFIGMAP_PRODUCTION_FILE}" "${PRODUCTION_FILE}"; then
if [ -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
if ! cp "${CONFIGMAP_PRODUCTION_FILE}" "${PRODUCTION_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_PRODUCTION5_FILE}" ]; then
if ! cp "${CONFIGMAP_PRODUCTION5_FILE}" "${PRODUCTION5_FILE}"; then
exit 1
fi
else
exit 1
fi
if [ -f "${CONFIGMAP_LOCAL_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL_FILE}" "${LOCAL_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_LOCAL5_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL5_FILE}" "${LOCAL5_FILE}"; then
exit 1
fi
fi

#----------------------------------------------------------
Expand Down Expand Up @@ -985,10 +1002,6 @@ data:
#----------------------------------------------------------
# Common variables
#----------------------------------------------------------
#PRGNAME=$(basename "$0")
#SCRIPTDIR=$(dirname "$0")
#SCRIPTDIR=$(cd "${SRCTOP}" || exit 1; pwd)

ANTPICKAX_ETC_DIR="/etc/antpickax"

RETRYCOUNT=60
Expand All @@ -1007,12 +1020,28 @@ data:

RUN_SCRIPT="${K2HR3_APP_DIR}/bin/run.sh"
PRODUCTION_DIR="${K2HR3_APP_DIR}/config"

# [NOTE]
# Configuration files accept json or json5 extensions.
#
PRODUCTION_FILE="${PRODUCTION_DIR}/production.json"
PRODUCTION5_FILE="${PRODUCTION_DIR}/production.json5"
TARGET_PRODUCTION_FILE=""
CONFIGMAP_PRODUCTION_FILE="/configmap/k2hr3-app-production.json"
CONFIGMAP_PRODUCTION5_FILE="/configmap/k2hr3-app-production.json5"
TARGET_CONFIGMAP_PRODUCTION_FILE=""
LOCAL_FILE="${PRODUCTION_DIR}/local.json"
LOCAL5_FILE="${PRODUCTION_DIR}/local.json5"
CONFIGMAP_LOCAL_FILE="/configmap/k2hr3-app-local.json"

if [ ! -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
CONFIGMAP_LOCAL5_FILE="/configmap/k2hr3-app-local.json5"

if [ -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
TARGET_PRODUCTION_FILE="${PRODUCTION_FILE}"
TARGET_CONFIGMAP_PRODUCTION_FILE="${CONFIGMAP_PRODUCTION_FILE}"
elif [ -f "${CONFIGMAP_PRODUCTION5_FILE}" ]; then
TARGET_PRODUCTION_FILE="${PRODUCTION5_FILE}"
TARGET_CONFIGMAP_PRODUCTION_FILE="${CONFIGMAP_PRODUCTION5_FILE}"
else
exit 1
fi

Expand Down Expand Up @@ -1054,15 +1083,19 @@ data:
-e "s#%%K2HR3_APP_EXTERNAL_PORT%%#${K2HR3APP_EXTERNAL_PORT}#g" \
-e "s#%%K2HR3_API_EXTERNAL_HOST%%#${K2HR3API_EXTERNAL_HOST}#g" \
-e "s#%%K2HR3_API_EXTERNAL_PORT%%#${K2HR3API_EXTERNAL_PORT}#g" \
"${CONFIGMAP_PRODUCTION_FILE}" \
> "${PRODUCTION_FILE}"; then
"${TARGET_CONFIGMAP_PRODUCTION_FILE}" \
> "${TARGET_PRODUCTION_FILE}"; then
exit 1
fi

if [ -f "${CONFIGMAP_LOCAL_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL_FILE}" "${LOCAL_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_LOCAL5_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL5_FILE}" "${LOCAL5_FILE}"; then
exit 1
fi
fi

#----------------------------------------------------------
Expand Down Expand Up @@ -1114,7 +1147,7 @@ data:
# Wait for api server up
#
if [ -z "${K2HR3APP_RUN_ON_MINIKUBE}" ] || [ "${K2HR3APP_RUN_ON_MINIKUBE}" != "true" ]; then
API_SCHEMA=$(grep 'apischeme' "${PRODUCTION_FILE}" 2>/dev/null | sed -e "s/['|,]//g" -e 's/^[[:space:]]*apischeme:[[:space:]]*//g' 2>/dev/null)
API_SCHEMA=$(grep 'apischeme' "${TARGET_PRODUCTION_FILE}" 2>/dev/null | sed -e "s/['|,]//g" -e 's/^[[:space:]]*apischeme:[[:space:]]*//g' 2>/dev/null)
API_UP=0
while [ "${API_UP}" -eq 0 ]; do
if HTTP_CODE=$("${CURL_COMMAND}" -s -S -w '%{http_code}' -o /dev/null --insecure -X GET "${API_SCHEMA}://${K2HR3API_EXTERNAL_HOST}:${K2HR3API_EXTERNAL_PORT}/" 2>&1); then
Expand Down Expand Up @@ -2049,7 +2082,7 @@ data:
# for server / slave nodes
#

k2hr3-api-production.json: |-
k2hr3-api-production.json5: |-
/*
*
* K2HR3 Helm Chart
Expand Down Expand Up @@ -2141,7 +2174,7 @@ data:
* vim<600: noexpandtab sw=4 ts=4
*/

k2hr3-app-production.json: |-
k2hr3-app-production.json5: |-
/*
*
* K2HR3 Helm Chart
Expand Down Expand Up @@ -2353,8 +2386,8 @@ spec:
path: k2hr3-app-wrap.sh
- key: k2hr3-setup-certificate.sh
path: k2hr3-setup-certificate.sh
- key: k2hr3-app-production.json
path: k2hr3-app-production.json
- key: k2hr3-app-production.json5
path: k2hr3-app-production.json5
- name: secret-k2hr3-ca-dummy
secret:
secretName: secret-k2hr3-ca-dummy
Expand Down Expand Up @@ -2622,8 +2655,8 @@ spec:
path: k2hr3-api-wrap.sh
- key: k2hr3-setup-certificate.sh
path: k2hr3-setup-certificate.sh
- key: k2hr3-api-production.json
path: k2hr3-api-production.json
- key: k2hr3-api-production.json5
path: k2hr3-api-production.json5
- name: secret-k2hr3-ca-dummy
secret:
secretName: secret-k2hr3-ca-dummy
Expand Down
6 changes: 4 additions & 2 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
# REVISION:
#

.DS_Store

# Git files/directories
.git/
.github/
Expand All @@ -40,6 +38,10 @@
# Project files
CHANGELOG.md

# Other
.DS_Store
s*.yaml

#
# Local variables:
# tab-width: 4
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ The following options/values are supported. See values.yaml for more detailed do
| `k2hr3.api.count` | optional | Specify the server count of K2HR3 REST API. | 2 |
| `k2hr3.api.extHostname` | optional | Specify the external hostname(FQDN) for K2HR3 REST API system, default is empty in which case internal hostanme will be used. | "" |
| `k2hr3.api.extPort` | optional | Specify the external port number for K2HR3 REST API system, default is 0 in which case 31443 will be used. | 0 |
| `k2hr3.api.customConf` | optional | Specify the custom configuration file content formatted by json string(config/local.json). | "" |
| `k2hr3.api.customConf` | optional | Specify the custom configuration file content formatted by json string(config/local.json(local.json5)). | "" |
| `k2hr3.api.localTenant` | optional | Specifies whether to support the LOCAL TENANT API. | true |
| `k2hr3.app.baseName` | optional | Specify the base name for K2HR3 Web Application, default is empty in which case "r3app" will be used. | "" |
| `k2hr3.app.count` | optional | Specify the server count of K2HR3 Web Application. | 2 |
| `k2hr3.app.extHostname` | optional | Specify the external hostname(FQDN) for K2HR3 Web Application system, default is empty in which case internal hostanme will be used.| "" |
| `k2hr3.app.extPort` | optional | Specify the external port number for K2HR3 Web Application system, default is 0 in which case 32443 will be used. | 0 |
| `k2hr3.app.customConf` | optional | Specify the custom configuration file content formatted by json string(config/local.json). | "" |
| `k2hr3.app.customConf` | optional | Specify the custom configuration file content formatted by json string(config/local.json(local.json5)). | "" |
| `k2hr3.app.localTenant` | optional | Specifies whether to support the LOCAL TENANT. | true |
| `k2hr3.env.httpProxy` | optional | Specify the HTTP PROXY(ex. "http://proxy.local:8080") for K2HR3 system, default is empty. | "" |
| `k2hr3.env.httpsProxy` | optional | Specify the HTTPS PROXY(ex. "http://proxy.local:8080") for K2HR3 system, default is empty. | "" |
Expand Down
File renamed without changes.
25 changes: 21 additions & 4 deletions files/k2hr3-api-wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,43 @@ fi

RUN_SCRIPT="${K2HR3_API_DIR}/bin/run.sh"
PRODUCTION_DIR="${K2HR3_API_DIR}/config"

# [NOTE]
# Configuration files accept json or json5 extensions.
#
PRODUCTION_FILE="${PRODUCTION_DIR}/production.json"
PRODUCTION5_FILE="${PRODUCTION_DIR}/production.json5"
CONFIGMAP_PRODUCTION_FILE="/configmap/k2hr3-api-production.json"
CONFIGMAP_PRODUCTION5_FILE="/configmap/k2hr3-api-production.json5"
LOCAL_FILE="${PRODUCTION_DIR}/local.json"
LOCAL5_FILE="${PRODUCTION_DIR}/local.json5"
CONFIGMAP_LOCAL_FILE="/configmap/k2hr3-api-local.json"
CONFIGMAP_LOCAL5_FILE="/configmap/k2hr3-api-local.json5"

if [ ! -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
exit 1
fi
if [ ! -d "${PRODUCTION_DIR}" ]; then
if ! mkdir -p "${PRODUCTION_DIR}"; then
exit 1
fi
fi
if ! cp "${CONFIGMAP_PRODUCTION_FILE}" "${PRODUCTION_FILE}"; then
if [ -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
if ! cp "${CONFIGMAP_PRODUCTION_FILE}" "${PRODUCTION_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_PRODUCTION5_FILE}" ]; then
if ! cp "${CONFIGMAP_PRODUCTION5_FILE}" "${PRODUCTION5_FILE}"; then
exit 1
fi
else
exit 1
fi
if [ -f "${CONFIGMAP_LOCAL_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL_FILE}" "${LOCAL_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_LOCAL5_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL5_FILE}" "${LOCAL5_FILE}"; then
exit 1
fi
fi

#----------------------------------------------------------
Expand Down
File renamed without changes.
34 changes: 25 additions & 9 deletions files/k2hr3-app-wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#----------------------------------------------------------
# Common variables
#----------------------------------------------------------
#PRGNAME=$(basename "$0")
#SCRIPTDIR=$(dirname "$0")
#SCRIPTDIR=$(cd "${SRCTOP}" || exit 1; pwd)

ANTPICKAX_ETC_DIR="/etc/antpickax"

RETRYCOUNT=60
Expand All @@ -43,12 +39,28 @@ fi

RUN_SCRIPT="${K2HR3_APP_DIR}/bin/run.sh"
PRODUCTION_DIR="${K2HR3_APP_DIR}/config"

# [NOTE]
# Configuration files accept json or json5 extensions.
#
PRODUCTION_FILE="${PRODUCTION_DIR}/production.json"
PRODUCTION5_FILE="${PRODUCTION_DIR}/production.json5"
TARGET_PRODUCTION_FILE=""
CONFIGMAP_PRODUCTION_FILE="/configmap/k2hr3-app-production.json"
CONFIGMAP_PRODUCTION5_FILE="/configmap/k2hr3-app-production.json5"
TARGET_CONFIGMAP_PRODUCTION_FILE=""
LOCAL_FILE="${PRODUCTION_DIR}/local.json"
LOCAL5_FILE="${PRODUCTION_DIR}/local.json5"
CONFIGMAP_LOCAL_FILE="/configmap/k2hr3-app-local.json"

if [ ! -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
CONFIGMAP_LOCAL5_FILE="/configmap/k2hr3-app-local.json5"

if [ -f "${CONFIGMAP_PRODUCTION_FILE}" ]; then
TARGET_PRODUCTION_FILE="${PRODUCTION_FILE}"
TARGET_CONFIGMAP_PRODUCTION_FILE="${CONFIGMAP_PRODUCTION_FILE}"
elif [ -f "${CONFIGMAP_PRODUCTION5_FILE}" ]; then
TARGET_PRODUCTION_FILE="${PRODUCTION5_FILE}"
TARGET_CONFIGMAP_PRODUCTION_FILE="${CONFIGMAP_PRODUCTION5_FILE}"
else
exit 1
fi

Expand Down Expand Up @@ -90,15 +102,19 @@ if ! sed -e "s#%%K2HR3_APP_EXTERNAL_HOST%%#${K2HR3APP_EXTERNAL_HOST}#g" \
-e "s#%%K2HR3_APP_EXTERNAL_PORT%%#${K2HR3APP_EXTERNAL_PORT}#g" \
-e "s#%%K2HR3_API_EXTERNAL_HOST%%#${K2HR3API_EXTERNAL_HOST}#g" \
-e "s#%%K2HR3_API_EXTERNAL_PORT%%#${K2HR3API_EXTERNAL_PORT}#g" \
"${CONFIGMAP_PRODUCTION_FILE}" \
> "${PRODUCTION_FILE}"; then
"${TARGET_CONFIGMAP_PRODUCTION_FILE}" \
> "${TARGET_PRODUCTION_FILE}"; then
exit 1
fi

if [ -f "${CONFIGMAP_LOCAL_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL_FILE}" "${LOCAL_FILE}"; then
exit 1
fi
elif [ -f "${CONFIGMAP_LOCAL5_FILE}" ]; then
if ! cp "${CONFIGMAP_LOCAL5_FILE}" "${LOCAL5_FILE}"; then
exit 1
fi
fi

#----------------------------------------------------------
Expand Down Expand Up @@ -150,7 +166,7 @@ fi
# Wait for api server up
#
if [ -z "${K2HR3APP_RUN_ON_MINIKUBE}" ] || [ "${K2HR3APP_RUN_ON_MINIKUBE}" != "true" ]; then
API_SCHEMA=$(grep 'apischeme' "${PRODUCTION_FILE}" 2>/dev/null | sed -e "s/['|,]//g" -e 's/^[[:space:]]*apischeme:[[:space:]]*//g' 2>/dev/null)
API_SCHEMA=$(grep 'apischeme' "${TARGET_PRODUCTION_FILE}" 2>/dev/null | sed -e "s/['|,]//g" -e 's/^[[:space:]]*apischeme:[[:space:]]*//g' 2>/dev/null)
API_UP=0
while [ "${API_UP}" -eq 0 ]; do
if HTTP_CODE=$("${CURL_COMMAND}" -s -S -w '%{http_code}' -o /dev/null --insecure -X GET "${API_SCHEMA}://${K2HR3API_EXTERNAL_HOST}:${K2HR3API_EXTERNAL_PORT}/" 2>&1); then
Expand Down
4 changes: 2 additions & 2 deletions questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ questions:
- variable: k2hr3.app.customConf
default: ""
label: "Custom configuration"
description: "Specify the custom configuration file content formatted by json string(config/local.json). Note: that the [,] character must be escaped."
description: "Specify the custom configuration file content formatted by json string(config/local.json(local.json5)). Note: that the [,] character must be escaped."
type: string
required: false
group: "K2HR3 Web Application"
Expand Down Expand Up @@ -226,7 +226,7 @@ questions:
- variable: k2hr3.api.customConf
default: ""
label: "Custom configuration"
description: "Specify the custom configuration file content formatted by json string(config/local.json). Note: that the [,] character must be escaped."
description: "Specify the custom configuration file content formatted by json string(config/local.json(local.json5)). Note: that the [,] character must be escaped."
type: string
required: false
group: "K2HR3 REST API"
Expand Down
4 changes: 2 additions & 2 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@

{{-
/*---------------------------------------------------------
* Set custom configration(local.json) for k2hr3 system.
* Set custom configration(local.json(local.json5)) for k2hr3 system.
*
*/}}
{{- define "k2hr3.r3apiCustomConf" -}}
Expand All @@ -176,7 +176,7 @@
{{- end }}

/*---------------------------------------------------------
* Set local tenant configration(local.json) for k2hr3 system.
* Set local tenant configration(local.json(local.json5)) for k2hr3 system.
*
*/}}
{{- define "k2hr3.r3apiLocalTenant" -}}
Expand Down
6 changes: 3 additions & 3 deletions templates/k2hr3-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* [NOTE]
* %%K2HR3_API(APP)_EXTERNAL(INTERNAL)_PORT%% are not converted here.
* Please note that in each pod, these NodePort is obtained from the
* environment variable and set to json.
* environment variable and set to json(json5).
*
*/ -}}
---
Expand Down Expand Up @@ -63,11 +63,11 @@ data:
{{- $files.Get .path | replace "%%K2HR3_TENANT_NAME%%" $k8sNamespace | replace "%%K2HDKC_DBAAS_CLUSTER_NAME%%" $clusterName | replace "%%K2HR3_API_INTERNAL_HOST%%" $apiIntHostname | replace "%%K2HR3_API_LOCALTENANT%%" $apiLocalTenant | replace "%%K2HR3_API_EXTERNAL_HOST%%" $apiExtHostname | replace "%%K2HR3_APP_EXTERNAL_HOST%%" $appExtHostname | replace "%%K2HR3_APP_LOCALTENANT%%" $appLocalTenant | replace "%%K8S_API_URL%%" $k8sApiUrl | replace "%%K8S_CA_CERT%%" $caCert | replace "%%K8S_SA_TOKEN%%" $saToken | replace "%%OIDC_CLIENT_ID%%" $clientId | replace "%%OIDC_CLIENT_SECRET%%" $clientSecret | replace "%%OIDC_COOKIE_EXPIRE%%" $cookieExpire | replace "%%OIDC_COOKIENAME%%" $cookieName | replace "%%OIDC_ISSUER_URL%%" $issuerUrl | replace "%%OIDC_USERNAME_KEY%%" $usernameKey | nindent 4 }}
{{- end }}
{{- if $apiCustomConf }}
k2hr3-api-local.json: |-
k2hr3-api-local.json5: |-
{{ printf "%s\n\n" $apiCustomConf }}
{{- end }}
{{- if $appCustomConf }}
k2hr3-app-local.json: |-
k2hr3-app-local.json5: |-
{{ printf "%s\n\n" $appCustomConf }}
{{- end }}

Expand Down
4 changes: 2 additions & 2 deletions templates/k2hr3-k2hr3api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ spec:
path: k2hr3-api-wrap.sh
- key: k2hr3-setup-certificate.sh
path: k2hr3-setup-certificate.sh
- key: k2hr3-api-production.json
path: k2hr3-api-production.json
- key: k2hr3-api-production.json5
path: k2hr3-api-production.json5
- name: secret-k2hr3-ca-{{ include "k2hr3.clusterName" . }}
secret:
secretName: secret-k2hr3-ca-{{ include "k2hr3.clusterName" . }}
Expand Down
4 changes: 2 additions & 2 deletions templates/k2hr3-k2hr3app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ spec:
path: k2hr3-app-wrap.sh
- key: k2hr3-setup-certificate.sh
path: k2hr3-setup-certificate.sh
- key: k2hr3-app-production.json
path: k2hr3-app-production.json
- key: k2hr3-app-production.json5
path: k2hr3-app-production.json5
- name: secret-k2hr3-ca-{{ include "k2hr3.clusterName" . }}
secret:
secretName: secret-k2hr3-ca-{{ include "k2hr3.clusterName" . }}
Expand Down
Loading

0 comments on commit 247dc41

Please sign in to comment.