How to clone GIT repo from SCS mirror service
search cancel

How to clone GIT repo from SCS mirror service

book

Article ID: 297173

calendar_today

Updated On:

Products

Support Only for Spring

Issue/Introduction

Sometimes it might be necessary to clone the GIT repo from SCS mirror service to review the data which mirror service synchronizes from the remote repo. This article shows how to clone the GIT repo from SCS mirror service.

Environment

Product Version: 3.1

Resolution

1) Refer to this KB article to setup environment to access Credhub in TAS
2) Retrieve private key and clone path for accessing mirror service

  • Check config-server service instance bound to your app
$ cf services
Getting service instances in org test / space test as admin...

name                 offering          plan       bound apps   last operation     broker               upgrade available
cook-config-server   p.config-server   standard   cook         create succeeded   scs-service-broker   no
  • "cf target" to space of this config-server instance
$ cf t -o p-spring-cloud-services -s $(cf service cook-config-server --guid)
API endpoint:   https://api.example.com
API version:    3.134.0
user:           admin
org:            p-spring-cloud-services
space:          ecd0c403-5d74-480b-9b74-1f1194a4a998
  • Get credhub-ref for this mirror service
$ cf env config-server | grep credhub-ref
        "credhub-ref": "/c/p.spring-cloud-services-scs-mirror-service/1a4561e4-9d12-4dd0-88fd-7290c148aac4/credentials"
  • Retrieve private key from Credhub
$ credhub get -n /c/p.spring-cloud-services-scs-mirror-service/1a4561e4-9d12-4dd0-88fd-7290c148aac4/credentials -j | jq '.value.git.privateKey' | xargs echo -e > mirror-service-priv-key
$ chmod 400 mirror-service-priv-key
  • Retrieve clone path
$  credhub get -n /c/p.spring-cloud-services-scs-mirror-service/1a4561e4-9d12-4dd0-88fd-7290c148aac4/credentials -j | jq '.value.git.uri'
"ssh://[email protected]:22/var/vcap/store/mirror/00957ad15f043b124e46eb212e90c4c8/cook-config"

3) Clone repo from mirror service

$ mkdir 1; cd 1

~/1$ git -c core.sshCommand="ssh -i ../mirror-service-priv-key  -o UserKnownHostsFile=./hosts" clone ssh://[email protected]:22/var/vcap/store/mirror/00957ad15f043b124e46eb212e90c4c8/cook-config
Cloning into 'cook-config'...
The authenticity of host 'x.x.x.x (x.x.x.x)' can't be established.
ED25519 key fingerprint is SHA256:2Xc3trF9N7+qEKEsAhpteMV2lDWpRyq77afdzAq+ktw.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'x.x.x.x' (ED25519) to the list of known hosts.
Unauthorized use is strictly prohibited. All access and activity
is subject to logging and monitoring.
remote: Enumerating objects: 120, done.
remote: Counting objects: 100% (120/120), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 120 (delta 39), reused 119 (delta 38)
Receiving objects: 100% (120/120), 26.98 KiB | 6.74 MiB/s, done.
Resolving deltas: 100% (39/39), done.

~/1$ ls
cook-config  hosts