Skip to content

Commit

Permalink
Merge pull request #12 from projectsyn/fix/https-catalog
Browse files Browse the repository at this point in the history
Fix `insteadOf` for HTTPS catalog repo
  • Loading branch information
simu authored Dec 19, 2024
2 parents 64c9c6b + c4be731 commit 06004a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
24 changes: 21 additions & 3 deletions gitlab/commodore-compile.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,28 @@ 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,
// Overide the original https:// URL for fetch and clone. Note that we
// use `git config --add` here so we can configure two `insteadOf` for
// the same replacement URL.
'git config --add --global url."%(replacement)s".insteadOf https://%(https_catalog)s' % {
replacement: replacement,
https_catalog: https_catalog,
},
// We need to configure an additional insteadOf 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.
// Note that we can't use `pushInsteadOf` here, since Git ignores
// `pushInsteadOf` configs for remotes that have an explicit
// `pushurl`.
'git config --add --global url."%(replacement)s".insteadOf ssh://git@%(https_catalog)s' % {
replacement: replacement,
https_catalog: https_catalog,
},
]
Expand Down
6 changes: 4 additions & 2 deletions gitlab/tests/golden/external-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
],
"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 --add --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 --add --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 All @@ -48,7 +49,8 @@
],
"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 --add --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 --add --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 06004a1

Please sign in to comment.