Skip to content

Conversation

@sosiouxme
Copy link
Contributor

@sosiouxme sosiouxme commented May 31, 2018

Introduce add_lines and add_lines_at methods for simpler manipulation.
Scope most existing properties to only the final stage.
Add parent_images property for getting and setting a list of images from the stages.
Introduce is_multistage property for convenience.

@twaugh @lcarva @mlangsdorf @rcerven PTAL
/cc @peterkline @adammhaile does this help...

@adammhaile
Copy link

I knew I was going to like having you on my team @sosiouxme
Looks good :)

@lcarva lcarva requested review from lcarva, rcerven and twaugh May 31, 2018 11:23
@twaugh
Copy link
Member

twaugh commented May 31, 2018

Travis CI test fails due to lack of #59.

@sosiouxme
Copy link
Contributor Author

That's what I get for skipping the python 2.6 testing. Got an actual test failure to fix.

@adammhaile
Copy link

@sosiouxme Python 2.6 only came out 10 years ago. Clearly it should be still tested :P

for stage in range(len(froms)-2, -1, -1): # e.g. 0 for single or 2, 1, 0 for 3 stages
start, finish = froms[stage], froms[stage+1]
linenum = start['endline'] + 1 if at_start else finish['startline']
df_lines[linenum:linenum] = [_endline(line) for line in lines]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we're calculating _endline() repeatedly for the same values. Can we move that out of the loop?


parents = dfparser.parent_images
for img in FROM:
assert img in parents
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we're not specifying the order they should appear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't update this with the implementation

matches = [index for index, text in enumerate(df_lines) if text == anchor]
if not matches:
raise RuntimeError("Cannot find line in the build file:\n" + anchor)
anchor = matches[-1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the last match? Can we have a test case that checks this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified test_add_lines_at to cover this

if instr['instruction'] != 'FROM':
continue
image, _ = image_from(instr['value'])
if image is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have testing that covers this not being the case.

Copy link
Contributor Author

@sosiouxme sosiouxme May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one. And actually setting parent_images would have been broken in that case (I fixed it). Well, the build would be broken anyway, but we can at least do no further harm.

Scope most existing properties to only the final stage.
Add parent_images property for getting and setting a list of images from the stages.
Introduce add_lines and add_lines_at methods for simpler manipulation.
Introduce is_multistage property for convenience.
@lcarva lcarva merged commit 548a928 into containerbuildsystem:master Jun 4, 2018
@lcarva
Copy link
Contributor

lcarva commented Jun 4, 2018

Updated release notes draft:

  • Improve capabilities for multistage Dockerfiles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants