#!/bin/sh

src=$1
target=$2

git fetch
git switch 3layer-staging
git switch -c init-$target-configuration || git switch init-$target-configuration

git restore --source origin/3layer-prod -- ./versions/$src
cp -r ./versions/$src ./versions/$target
git restore -- ./versions/$src
git clean -f -- ./versions/$src
sed -i "1c\version: $target" ./versions/$target/meta.yaml

git add .
git commit -m"init $target configuration"
git push --set-upstream origin "init-$target-configuration"
gh pr create --base 3layer-staging --title "Init $target configurations" --body "<!-- Form for tenant / cluster config change (修改租户/集群配置时需要添加的表单) -->

## Reason
* Tenant: <!-- Please fill in the tenant name | 请填写租户名 -->
* Purpose: <!-- Use new feature FOO / FOO feature performance optimization in the new version / customer upgrade test / others (please explain) | 使用xx新功能 / xx功能在新版本性能优化 / 客户升级测试 / others (请说明) -->
* Ticket: <!-- Please fill the JIRA ticket URL (if any) | 请填写 JIRA 工单链接 (假如有的话) -->

## Affect prod dedicated cluster? <!-- whether this change should be applied to prod dedicated cluster -->
- [x] No
- [ ] Yes, please check if the target cluster shows "red" in this link: https://clinic.pingcap.com/grafana/d/Dcr3BpIVk/gitops-dryrun-for-support?orgId=1 If it is red, the red component will restart immediately after change updatepolicy, please contact @qqqdan for more info. 

init $target configurations
Default configurations are copied from $src prod
image tag @Ivy-YinSu "
