Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base image can now be specified in the definition file #129

Merged
merged 7 commits into from
Nov 30, 2020

Conversation

beeankha
Copy link
Contributor

Addressing Issue #119

@beeankha beeankha added enhancement New feature or request state: needs review labels Nov 19, 2020
@beeankha beeankha self-assigned this Nov 19, 2020
@beeankha
Copy link
Contributor Author

recheck

@@ -190,6 +198,15 @@ def validate(self):
if not os.path.exists(requirement_path):
raise DefinitionError("Dependency file {0} does not exist.".format(requirement_path))

ee_base_image = self.get_base_image()
Copy link
Member

Choose a reason for hiding this comment

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

I hate to see get_base_image as its own method when it's not the canonical way that the value gets set in practice. I'd prefer to lose the method and use the same self.definition.raw.get('base_image') here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

@@ -32,12 +32,13 @@ def __init__(self, action=None,
verbosity=0):
self.action = action
self.definition = UserDefinition(filename=filename)
self.base_image = self.definition.raw.get('base_image') or base_image
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 know about the precedence. If I provide the base image both in the definition file, and with the CLI option... I would think the CLI option should win. That tends to be how we want config processing to go. @shanemcd what do you think? Or else we could error if given both.

We would have to re-think how the kwarg default works, it might make more sense for None to be the value from the kwarg.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I provide the base image both in the definition file, and with the CLI option... I would think the CLI option should win.

Agreed, I'll switch those around and clarify the precedence in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have made some updates, will work on making sure integration tests pass next.

@@ -109,25 +105,29 @@ def test_definition_syntax_error(self, data_dir):
path = os.path.join(data_dir, 'definition_files/bad.yml')

with pytest.raises(DefinitionError) as error:
AnsibleBuilder(filename=path)
AnsibleBuilder(filename=path, base_image='my-custom-image')
Copy link
Member

Choose a reason for hiding this comment

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

these test changes shouldn't be needed, should they? I'd like to see if we can roll some of those back.

raise DefinitionError(textwrap.dedent(
"""
Error: Please specify a base image for the execution environment.
""")
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 know about this, I would prefer to keep the default behavior the same.

@AlanCoding
Copy link
Member

put up revised suggestions in beeankha#2

Review suggestions for base image default handling
Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

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

looks like behavior aligns with docs so 👍

@beeankha
Copy link
Contributor Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants