Merge pull request #3072 from quay/joseph.schorr/QUAY-933/dockerfile-path
Fix lookup of Dockerfile in archives
This commit is contained in:
commit
babb7bb803
2 changed files with 4 additions and 3 deletions
|
@ -27,8 +27,8 @@ describe("DockerfileServiceImpl", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
file = "FROM quay.io/coreos/nginx:latest";
|
file = "FROM quay.io/coreos/nginx:latest";
|
||||||
validArchiveFile = [{name: 'Dockerfile', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue(file)}];
|
validArchiveFile = [{name: 'Dockerfile', path: 'Dockerfile', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue(file)}];
|
||||||
invalidArchiveFile = [{name: 'main.exe', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue("")}];
|
invalidArchiveFile = [{name: 'main.exe', path: 'main.exe', toBlob: jasmine.createSpy('toBlobSpy').and.returnValue("")}];
|
||||||
|
|
||||||
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
|
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
|
||||||
failure([]);
|
failure([]);
|
||||||
|
@ -131,6 +131,7 @@ describe("DockerfileServiceImpl", () => {
|
||||||
it("returns rejected promise if given archive file with invalid Dockerfile", (done) => {
|
it("returns rejected promise if given archive file with invalid Dockerfile", (done) => {
|
||||||
forDataSpy.and.returnValue(null);
|
forDataSpy.and.returnValue(null);
|
||||||
invalidArchiveFile[0].name = 'Dockerfile';
|
invalidArchiveFile[0].name = 'Dockerfile';
|
||||||
|
invalidArchiveFile[0].path = 'Dockerfile';
|
||||||
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
|
dataFileServiceMock.setup(mock => mock.readDataArrayAsPossibleArchive).is((buf, success, failure) => {
|
||||||
success(invalidArchiveFile);
|
success(invalidArchiveFile);
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,7 +61,7 @@ export class DockerfileServiceImpl implements DockerfileService {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var found: boolean = false;
|
var found: boolean = false;
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
if (file['name'] == 'Dockerfile') {
|
if (file['path'] == 'Dockerfile' || file['path'] == '/Dockerfile') {
|
||||||
this.DataFileService.blobToString(file.toBlob(), (contents: string) => {
|
this.DataFileService.blobToString(file.toBlob(), (contents: string) => {
|
||||||
var result: DockerfileInfoImpl | null = DockerfileInfoImpl.forData(contents, this.Config);
|
var result: DockerfileInfoImpl | null = DockerfileInfoImpl.forData(contents, this.Config);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
|
Reference in a new issue