Merge pull request #3072 from quay/joseph.schorr/QUAY-933/dockerfile-path

Fix lookup of Dockerfile in archives
This commit is contained in:
josephschorr 2018-05-09 21:04:53 +03:00 committed by GitHub
commit babb7bb803
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -27,8 +27,8 @@ describe("DockerfileServiceImpl", () => {
beforeEach(() => {
file = "FROM quay.io/coreos/nginx:latest";
validArchiveFile = [{name: 'Dockerfile', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue(file)}];
invalidArchiveFile = [{name: 'main.exe', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue("")}];
validArchiveFile = [{name: 'Dockerfile', path: 'Dockerfile', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue(file)}];
invalidArchiveFile = [{name: 'main.exe', path: 'main.exe', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue("")}];
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
failure([]);
@ -131,6 +131,7 @@ describe("DockerfileServiceImpl", () => {
it("returns rejected promise if given archive file with invalid Dockerfile", (done) => {
forDataSpy.and.returnValue(null);
invalidArchiveFile[0].name = 'Dockerfile';
invalidArchiveFile[0].path = 'Dockerfile';
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
success(invalidArchiveFile);
});

View file

@ -61,7 +61,7 @@ export class DockerfileServiceImpl implements DockerfileService {
return new Promise((resolve, reject) => {
var found: boolean = false;
files.forEach((file) => {
if (file['name'] == 'Dockerfile') {
if (file['path'] == 'Dockerfile' || file['path'] == '/Dockerfile') {
this.DataFileService.blobToString(file.toBlob(), (contents: string) => {
var result: DockerfileInfoImpl | null = DockerfileInfoImpl.forData(contents, this.Config);
if (result == null) {