#!/bin/bash
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.

[ "$CCI_SRC" ] || export CCI_SRC=/c/cbs

. $CCI_SRC/container/defconfig.sh

load_service_config
load_cci_defaults

configmap_yaml=$CCI_SRC/container/configmap.yaml

sed -i \
    -e "s#https://omapi.test.osinfra.cn/oneid/public/key?community=openeuler#${PUBLIC_KEY_URL}#g" \
    -e "s#https://omapi.test.osinfra.cn/oneid/oidc/token#${OAUTH_TOKEN_URL}#g" \
    -e "s#https://omapi.test.osinfra.cn/oneid/oidc/user#${OAUTH_USER_URL}#g" \
    -e "s#https://eulermaker.compass-ci.openeuler.openatom.cn/oauth/#${OAUTH_REDIRECT_URL}#g" \
    -e "s#http://123.249.10.3:30108/repositories#${ENV_REPOS_URL}#g" \
    -e "s#http://ebsdemo.com/oauth/#${OAUTH_REDIRECT_URL}#g" \
    -e "s#proxy_set_header Host \$host:30108;#proxy_set_header Host \$host:$CBS_WEB_PORT;#g" \
    -e "s#SRV_HTTP_REPOSITORIES_HOST: SRV_HTTP_REPOSITORIES_HOST#SRV_HTTP_REPOSITORIES_HOST: $CBS_WEB_HOST#g" \
    -e "s#SRV_HTTP_REPOSITORIES_PORT: SRV_HTTP_REPOSITORIES_PORT#SRV_HTTP_REPOSITORIES_PORT: $CBS_WEB_PORT#g" \
    -e "s#SRV_HTTP_RESULT_HOST: SRV_HTTP_RESULT_HOST#SRV_HTTP_RESULT_HOST: $CBS_WEB_HOST#g" \
    -e "s#SRV_HTTP_RESULT_PORT: SRV_HTTP_RESULT_PORT#SRV_HTTP_RESULT_PORT: $CBS_WEB_PORT#g" \
    -e "s#GATEWAY_IP: GATEWAY_IP#GATEWAY_IP: $CBS_WEB_HOST#g" \
    -e "s#GATEWAY_PORT: GATEWAY_PORT#GATEWAY_PORT: $CBS_WEB_PORT#g" \
    $configmap_yaml
