Skip to content

Commit

Permalink
Set pushInsteadOf for HTTPS catalog repo
Browse files Browse the repository at this point in the history
We need to configure an additional `pushInsteadOf` for the `ssh://git@`
variant of a HTTPS catalog URL since Commodore will optimistically
rewrite all HTTPS Git URLs to have their `ssh://git@` equivalent as the
push URL to make local component development easier.
  • Loading branch information
simu committed Dec 18, 2024
1 parent 64c9c6b commit 7605012
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 16 additions & 3 deletions gitlab/commodore-compile.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,23 @@ local gitInsteadOf(cluster) =
else if https_catalog != null then
// set an insteadOf which injects credentials if we have a catalog URL
// that's already HTTPS in Lieutenant.
local replacement = 'https://%(catalog_user)s:%(access_token)s@%(https_catalog)s' % {
catalog_user: cluster_access_user,
access_token: cluster_access_token,
https_catalog: https_catalog,
};
[
'git config --global url."https://%(catalog_user)s:%(access_token)s@%(https_catalog)s".insteadOf https://%(https_catalog)s' % {
catalog_user: cluster_access_user,
access_token: cluster_access_token,
// for fetch/clone
'git config --global url."%(replacement)s".insteadOf https://%(https_catalog)s' % {
replacement: replacement,
https_catalog: https_catalog,
},
// We need to configure an additional pushInsteadOf for the ssh://git@
// variant of a HTTPS catalog URL since Commodore will optimistically
// rewrite all HTTPS Git URLs to have their ssh://git@ equivalent as
// the push URL to make local component development easier.
'git config --global url."%(replacement)s".pushInsteadOf ssh://git@%(https_catalog)s' % {
replacement: replacement,
https_catalog: https_catalog,
},
]
Expand Down
2 changes: 2 additions & 0 deletions gitlab/tests/golden/external-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"script": [
"git config --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}",
"git config --global url.\"https://${ACCESS_USER_c_cluster_id_1111:-token}:${ACCESS_TOKEN_c_cluster_id_1111}@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git\".insteadOf https://git.vshn.net/cluster-catalogs/c-cluster-id-1111.git",
"git config --global url.\"https://${ACCESS_USER_c_cluster_id_1111:-token}:${ACCESS_TOKEN_c_cluster_id_1111}@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git\".insteadOf ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git",
"/usr/local/bin/entrypoint.sh commodore catalog compile --tenant-repo-revision-override $CI_COMMIT_SHA c-cluster-id-1111",
"(cd catalog/ && git --no-pager diff --staged --output ../diff.txt)"
],
Expand Down Expand Up @@ -49,6 +50,7 @@
"script": [
"git config --global url.\"https://gitlab-ci-token:${CI_JOB_TOKEN}@git.vshn.net:80\".insteadOf ssh://git@${CI_SERVER_SHELL_SSH_HOST}",
"git config --global url.\"https://${ACCESS_USER_c_cluster_id_1111:-token}:${ACCESS_TOKEN_c_cluster_id_1111}@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git\".insteadOf https://git.vshn.net/cluster-catalogs/c-cluster-id-1111.git",
"git config --global url.\"https://${ACCESS_USER_c_cluster_id_1111:-token}:${ACCESS_TOKEN_c_cluster_id_1111}@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git\".insteadOf ssh://git@git.vshn.net/cluster-catalogs/c-cluster-id-1111.git",
"/usr/local/bin/entrypoint.sh commodore catalog compile --push c-cluster-id-1111"
],
"stage": "deploy",
Expand Down

0 comments on commit 7605012

Please sign in to comment.