forked from vieter-v/vieter
				
			Fixed linting errors
							parent
							
								
									732b53b6ce
								
							
						
					
					
						commit
						4a4362c138
					
				
							
								
								
									
										14
									
								
								src/build.v
								
								
								
								
							
							
						
						
									
										14
									
								
								src/build.v
								
								
								
								
							|  | @ -2,7 +2,6 @@ module main | |||
| 
 | ||||
| import docker | ||||
| import encoding.base64 | ||||
| import rand | ||||
| import time | ||||
| import json | ||||
| import server | ||||
|  | @ -10,6 +9,7 @@ import env | |||
| import net.http | ||||
| 
 | ||||
| const container_build_dir = '/build' | ||||
| 
 | ||||
| const build_image_repo = 'vieter-build' | ||||
| 
 | ||||
| fn create_build_image() ?string { | ||||
|  | @ -83,13 +83,13 @@ fn build() ? { | |||
| 	for repo in repos { | ||||
| 		// TODO what to do with PKGBUILDs that build multiple packages? | ||||
| 		commands := [ | ||||
| 			"git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo" | ||||
| 			'cd repo' | ||||
| 			"makepkg --nobuild --nodeps" | ||||
| 			'source PKGBUILD' | ||||
| 			'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo', | ||||
| 			'cd repo', | ||||
| 			'makepkg --nobuild --nodeps', | ||||
| 			'source PKGBUILD', | ||||
| 			// The build container checks whether the package is already present on the server | ||||
| 			"curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0" | ||||
| 			'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done' | ||||
| 			'curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0', | ||||
| 			'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done', | ||||
| 		] | ||||
| 
 | ||||
| 		// We convert the list of commands into a base64 string, which then gets | ||||
|  |  | |||
|  | @ -20,8 +20,8 @@ pub struct NewContainer { | |||
| 	entrypoint []string [json: Entrypoint] | ||||
| 	cmd        []string [json: Cmd] | ||||
| 	env        []string [json: Env] | ||||
| 	work_dir   string   [json:  WorkingDir] | ||||
| 	user string [json: User] | ||||
| 	work_dir   string   [json: WorkingDir] | ||||
| 	user       string   [json: User] | ||||
| } | ||||
| 
 | ||||
| struct CreatedContainer { | ||||
|  |  | |||
|  | @ -14,6 +14,8 @@ pub fn pull_image(image string, tag string) ?http.Response { | |||
| 	return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?) | ||||
| } | ||||
| 
 | ||||
| // create_image_from_container creates a new image from a container with the | ||||
| // given repo & tag, given the container's ID. | ||||
| pub fn create_image_from_container(id string, repo string, tag string) ?Image { | ||||
| 	res := request('POST', urllib.parse('/v1.41/commit?container=$id&repo=$repo&tag=$tag') ?) ? | ||||
| 
 | ||||
|  | @ -24,6 +26,7 @@ pub fn create_image_from_container(id string, repo string, tag string) ?Image { | |||
| 	return json.decode(Image, res.text) or {} | ||||
| } | ||||
| 
 | ||||
| // remove_image removes the image with the given ID. | ||||
| pub fn remove_image(id string) ?bool { | ||||
| 	res := request('DELETE', urllib.parse('/v1.41/images/$id') ?) ? | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue