mirror of
				https://gitea.com/docker/build-push-action.git
				synced 2025-10-31 00:58:18 +07:00 
			
		
		
		
	Small refactor
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									ec2628bb21
								
							
						
					
					
						commit
						26b3a3b0cd
					
				| @ -16,6 +16,13 @@ describe('buildx', () => { | |||||||
|     expect(countBuilders).toBeGreaterThan(0); |     expect(countBuilders).toBeGreaterThan(0); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  |   it('platforms', async () => { | ||||||
|  |     const platforms = await buildx.platforms(); | ||||||
|  |     console.log(`platforms: ${platforms}`); | ||||||
|  |     expect(platforms).not.toBeUndefined(); | ||||||
|  |     expect(platforms).not.toEqual(''); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|   it('acquires v0.2.2 version of buildx', async () => { |   it('acquires v0.2.2 version of buildx', async () => { | ||||||
|     const buildxBin = await buildx.install('v0.2.2', tmpDir); |     const buildxBin = await buildx.install('v0.2.2', tmpDir); | ||||||
|     console.log(buildxBin); |     console.log(buildxBin); | ||||||
|  | |||||||
							
								
								
									
										29
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -2522,17 +2522,7 @@ function run() { | |||||||
|             core.info('🐳 Docker info'); |             core.info('🐳 Docker info'); | ||||||
|             yield exec.exec('docker', ['info'], false); |             yield exec.exec('docker', ['info'], false); | ||||||
|             core.info('🛒 Extracting available platforms...'); |             core.info('🛒 Extracting available platforms...'); | ||||||
|             yield exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => { |             core.setOutput('platforms', yield buildx.platforms()); | ||||||
|                 if (res.stderr != '' && !res.success) { |  | ||||||
|                     throw new Error(res.stderr); |  | ||||||
|                 } |  | ||||||
|                 for (const line of res.stdout.trim().split(os.EOL)) { |  | ||||||
|                     if (line.startsWith('Platforms')) { |  | ||||||
|                         core.setOutput('platforms', line.replace('Platforms: ', '').replace(/\s/g, '').trim()); |  | ||||||
|                         break; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             }); |  | ||||||
|         } |         } | ||||||
|         catch (error) { |         catch (error) { | ||||||
|             core.setFailed(error.message); |             core.setFailed(error.message); | ||||||
| @ -7239,7 +7229,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | |||||||
|     }); |     }); | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", { value: true }); | Object.defineProperty(exports, "__esModule", { value: true }); | ||||||
| exports.install = exports.countBuilders = exports.isAvailable = void 0; | exports.install = exports.platforms = exports.countBuilders = exports.isAvailable = void 0; | ||||||
| const fs = __importStar(__webpack_require__(747)); | const fs = __importStar(__webpack_require__(747)); | ||||||
| const os = __importStar(__webpack_require__(87)); | const os = __importStar(__webpack_require__(87)); | ||||||
| const path = __importStar(__webpack_require__(622)); | const path = __importStar(__webpack_require__(622)); | ||||||
| @ -7272,6 +7262,21 @@ function countBuilders() { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.countBuilders = countBuilders; | exports.countBuilders = countBuilders; | ||||||
|  | function platforms() { | ||||||
|  |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |         return yield exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => { | ||||||
|  |             if (res.stderr != '' && !res.success) { | ||||||
|  |                 throw new Error(res.stderr); | ||||||
|  |             } | ||||||
|  |             for (const line of res.stdout.trim().split(`\n`)) { | ||||||
|  |                 if (line.startsWith('Platforms')) { | ||||||
|  |                     return line.replace('Platforms: ', '').replace(/\s/g, '').trim(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  | exports.platforms = platforms; | ||||||
| function install(inputVersion, dockerConfigHome) { | function install(inputVersion, dockerConfigHome) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         const release = yield github.getRelease(inputVersion); |         const release = yield github.getRelease(inputVersion); | ||||||
|  | |||||||
| @ -28,6 +28,19 @@ export async function countBuilders(): Promise<number> { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export async function platforms(): Promise<String | undefined> { | ||||||
|  |   return await exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => { | ||||||
|  |     if (res.stderr != '' && !res.success) { | ||||||
|  |       throw new Error(res.stderr); | ||||||
|  |     } | ||||||
|  |     for (const line of res.stdout.trim().split(`\n`)) { | ||||||
|  |       if (line.startsWith('Platforms')) { | ||||||
|  |         return line.replace('Platforms: ', '').replace(/\s/g, '').trim(); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export async function install(inputVersion: string, dockerConfigHome: string): Promise<string> { | export async function install(inputVersion: string, dockerConfigHome: string): Promise<string> { | ||||||
|   const release: github.GitHubRelease | null = await github.getRelease(inputVersion); |   const release: github.GitHubRelease | null = await github.getRelease(inputVersion); | ||||||
|   if (!release) { |   if (!release) { | ||||||
|  | |||||||
| @ -50,21 +50,8 @@ async function run(): Promise<void> { | |||||||
|       await exec.exec('docker', ['buildx', 'install'], false); |       await exec.exec('docker', ['buildx', 'install'], false); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     core.info('🐳 Docker info'); |  | ||||||
|     await exec.exec('docker', ['info'], false); |  | ||||||
| 
 |  | ||||||
|     core.info('🛒 Extracting available platforms...'); |     core.info('🛒 Extracting available platforms...'); | ||||||
|     await exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => { |     core.setOutput('platforms', await buildx.platforms()); | ||||||
|       if (res.stderr != '' && !res.success) { |  | ||||||
|         throw new Error(res.stderr); |  | ||||||
|       } |  | ||||||
|       for (const line of res.stdout.trim().split(os.EOL)) { |  | ||||||
|         if (line.startsWith('Platforms')) { |  | ||||||
|           core.setOutput('platforms', line.replace('Platforms: ', '').replace(/\s/g, '').trim()); |  | ||||||
|           break; |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     core.setFailed(error.message); |     core.setFailed(error.message); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user