21export const syncGitSshOcWeb = async (cfg) => { 23 repoName, sshHostAlias, sshKeyPath, authorizedPubKeyPaths, 24 codeservHostname, gitName, gitEmail, deployableEps, 27 gitsshName, gitsshNodePortNo, gitsshSizeGb, 28 codeservName, codeservSizeGb, 33 const gitsshCfg = {repoName, sshHostAlias, sshKeyPath, authorizedPubKeyPaths, 34 ...(gitsshName && {name: gitsshName}), 35 ...(gitsshNodePortNo && {nodePortNo: gitsshNodePortNo}), 36 ...(gitsshSizeGb && {sizeGb: gitsshSizeGb}), 40 const gitsshK8sName = gitsshName 43 gitsshRemoteUrl: `ssh://${sshHostAlias}/home/git/repos/${repoName}.git`, 48 ...(codeservName && {name: codeservName}), 49 ...(codeservSizeGb && {sizeGb: codeservSizeGb}), 50 ...(isThrowawayEp && {isThrowawayEp}), 57 // Register setup and setorigin actions for configuring local git 58 const setup = async () => gitsshCtx.run(gitsshCfg, () => setupGitSshLocal({cluster_name})) 59 setup.cliDescript = 'configure ~/.ssh/config and git remote (idempotent)' 61 setorigin.cliDescript = 'set origin remote to gitssh URL (idempotent)' 62 // Only register runtests for non-throwaway (throwaway registers its own destructive runtests) 64 runtestsAction.cliDescript = 'run healthcheck tests against deployed codeserv' 65 const runtests = isThrowawayEp ? null : runtestsAction 66 availActionsCtx.enterWith({...availActionsCtx.getStore(), setup, setorigin, ...(runtests && {runtests})}) 68 if (action === 'setup') { 72 if (action === 'setorigin') { 76 if (action === 'runtests' && runtests) { 81 // Skip log streaming - multiple sequential deploys would block forever 82 const skipGitsshActions = ['help', 'runtests'] // actions that only need codeserv 83 await multiDeployCtx.run({skipStreamLogs: true}, () => 84 pvcTypeCtx.run({pvcEncName}, async () => { 85 // Skip gitssh for actions that only need codeserv 86 if (!skipGitsshActions.includes(action)) { 87 // Deploy gitssh first (codeserv needs it to clone repo) 88 await gitsshCtx.run(gitsshCfg, k8sGitSsh) 90 // Init bare repo on gitssh after deploy (idempotent, needed before codeserv can clone) 93 if (action === 'apply') { 94 // Update SSH config before any git operations (handles LAN changes) 97 if (getLocalRepoPath) await gitsshCtx.run(gitsshCfg, async () => pushLocalRepoToGitssh({localRepoPath: await getLocalRepoPath(), cluster_name})) 102 await codeservCtx.run(codeservCfg, syncCodeserv) 108 * Throwaway codeserv+gitssh deployment for testing. 109 * Handles action dispatch, runtests/testdeploy registration, and hostname derivation. 111export const eptThrowawayOcWeb = async ({klusterCfg, ep, wcDomain, testGitsshName = 'test-gitssh', testCodeservName = 'test-codeserv', testCodeservHostname: testCodeservHostnameArg, gitsshNodePortNo = 30023, gitsshSizeGb = 1, codeservSizeGb = 3, getLocalRepoPath, ...syncCfg}) => { 113 const testCodeservHostname = testCodeservHostnameArg || await getDerivedHostname({name: testCodeservName, wcDomain}) 116 repoName: syncCfg.repoName, 117 sshHostAlias: syncCfg.sshHostAlias, 118 sshKeyPath: syncCfg.sshKeyPath, 119 authorizedPubKeyPaths: syncCfg.authorizedPubKeyPaths, 120 name: testGitsshName, 121 nodePortNo: gitsshNodePortNo, 122 sizeGb: gitsshSizeGb, 125 const syncWithAction = async (actionOverride) => { 126 actionCtx.enterWith({action: actionOverride}) // ctx:clear 128 await cliValidatedCtx.run({validated: true}, () => syncGitSshOcWeb({ 130 codeservHostname: testCodeservHostname, 131 gitsshName: testGitsshName, 134 codeservName: testCodeservName, 141 const setupFn = async () => { 143 await gitsshCtx.run(gitsshCfg, () => setupGitSshLocal({cluster_name: klusterCfg.cluster_name})) 144 return {passed: true, msg: 'SSH config setup completed'} 146 return {passed: false, msg: `setup failed: ${err}`} 152 const runtests = async () => runThrowawayCsTests({syncWithAction, cluster_name: klusterCfg.cluster_name, codeservName: testCodeservName, gitsshName: testGitsshName, codeservHostname: testCodeservHostname, ep, setupFn, password: getPassword()}) 153 runtests.cliDescript = 'delete + delpvcs + apply throwaway codeserv+gitssh, verify, cleanup' 154 runtests.cliSchema = baseRuntestsCli 156 const testdeploy = async () => runThrowawayCsTests({syncWithAction, cluster_name: klusterCfg.cluster_name, codeservName: testCodeservName, gitsshName: testGitsshName, codeservHostname: testCodeservHostname, ep, setupFn, includeCleanup: false, password: getPassword()}) 157 testdeploy.cliDescript = 'delete + delpvcs + apply throwaway codeserv+gitssh, verify (no cleanup)' 158 testdeploy.cliSchema = baseRuntestsCli 160 const customActions = {runtests, testdeploy} 161 availActionsCtx.enterWith({...availActionsCtx.getStore(), ...customActions}) 164 if (!action || action === 'help') { 165 const allActions = {...availActionsCtx.getStore(), ...customActions} 166 return cliBase({actionNames: Object.keys(allActions), actionsH: allActions}) 168 const customAction = customActions[action] 173 await syncWithAction(action)