style: prettier
This commit is contained in:
		
							parent
							
								
									ece7275743
								
							
						
					
					
						commit
						a7f008253c
					
				| @ -1,14 +1,14 @@ | |||||||
| const Docker = require("dockerode"); | const Docker = require('dockerode'); | ||||||
| const getStream = require("get-stream"); | const getStream = require('get-stream'); | ||||||
| const pRetry = require("p-retry"); | const pRetry = require('p-retry'); | ||||||
| const { initBareRepo, gitShallowClone } = require("./git-utils"); | const {initBareRepo, gitShallowClone} = require('./git-utils'); | ||||||
| 
 | 
 | ||||||
| const IMAGE = "pvdlg/docker-gitbox:latest"; | const IMAGE = 'pvdlg/docker-gitbox:latest'; | ||||||
| const SERVER_PORT = 80; | const SERVER_PORT = 80; | ||||||
| const HOST_PORT = 2080; | const HOST_PORT = 2080; | ||||||
| const SERVER_HOST = "localhost"; | const SERVER_HOST = 'localhost'; | ||||||
| const GIT_USERNAME = "integration"; | const GIT_USERNAME = 'integration'; | ||||||
| const GIT_PASSWORD = "suchsecure"; | const GIT_PASSWORD = 'suchsecure'; | ||||||
| const docker = new Docker(); | const docker = new Docker(); | ||||||
| let container; | let container; | ||||||
| 
 | 
 | ||||||
| @ -23,12 +23,12 @@ async function start() { | |||||||
|   container = await docker.createContainer({ |   container = await docker.createContainer({ | ||||||
|     Tty: true, |     Tty: true, | ||||||
|     Image: IMAGE, |     Image: IMAGE, | ||||||
|     PortBindings: { [`${SERVER_PORT}/tcp`]: [{ HostPort: `${HOST_PORT}` }] }, |     PortBindings: {[`${SERVER_PORT}/tcp`]: [{HostPort: `${HOST_PORT}`}]}, | ||||||
|   }); |   }); | ||||||
|   await container.start(); |   await container.start(); | ||||||
| 
 | 
 | ||||||
|   const exec = await container.exec({ |   const exec = await container.exec({ | ||||||
|     Cmd: ["ng-auth", "-u", GIT_USERNAME, "-p", GIT_PASSWORD], |     Cmd: ['ng-auth', '-u', GIT_USERNAME, '-p', GIT_PASSWORD], | ||||||
|     AttachStdout: true, |     AttachStdout: true, | ||||||
|     AttachStderr: true, |     AttachStderr: true, | ||||||
|   }); |   }); | ||||||
| @ -51,9 +51,9 @@ async function stop() { | |||||||
|  * @param {String} [description=`Repository ${name}`] The repository description. |  * @param {String} [description=`Repository ${name}`] The repository description. | ||||||
|  * @return {Object} The `repositoryUrl` (URL without auth) and `authUrl` (URL with auth). |  * @return {Object} The `repositoryUrl` (URL without auth) and `authUrl` (URL with auth). | ||||||
|  */ |  */ | ||||||
| async function createRepo(name, branch = "master", description = `Repository ${name}`) { | async function createRepo(name, branch = 'master', description = `Repository ${name}`) { | ||||||
|   const exec = await container.exec({ |   const exec = await container.exec({ | ||||||
|     Cmd: ["repo-admin", "-n", name, "-d", description], |     Cmd: ['repo-admin', '-n', name, '-d', description], | ||||||
|     AttachStdout: true, |     AttachStdout: true, | ||||||
|     AttachStderr: true, |     AttachStderr: true, | ||||||
|   }); |   }); | ||||||
| @ -63,10 +63,10 @@ async function createRepo(name, branch = "master", description = `Repository ${n | |||||||
|   const authUrl = `http://${gitCredential}@${SERVER_HOST}:${HOST_PORT}/git/${name}.git`; |   const authUrl = `http://${gitCredential}@${SERVER_HOST}:${HOST_PORT}/git/${name}.git`; | ||||||
| 
 | 
 | ||||||
|   // Retry as the server might take a few ms to make the repo available push
 |   // Retry as the server might take a few ms to make the repo available push
 | ||||||
|   await pRetry(() => initBareRepo(authUrl, branch), { retries: 5, minTimeout: 500, factor: 2 }); |   await pRetry(() => initBareRepo(authUrl, branch), {retries: 5, minTimeout: 500, factor: 2}); | ||||||
|   const cwd = await gitShallowClone(authUrl); |   const cwd = await gitShallowClone(authUrl); | ||||||
| 
 | 
 | ||||||
|   return { cwd, repositoryUrl, authUrl }; |   return {cwd, repositoryUrl, authUrl}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { start, stop, gitCredential, createRepo }; | module.exports = {start, stop, gitCredential, createRepo}; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user