-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
74483ea
to
e52c5a5
Compare
recheck |
ansible_builder/main.py
Outdated
@@ -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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
ansible_builder/main.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2578b6c
to
5ead3ef
Compare
test/test_main.py
Outdated
@@ -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') |
There was a problem hiding this comment.
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.
ansible_builder/main.py
Outdated
raise DefinitionError(textwrap.dedent( | ||
""" | ||
Error: Please specify a base image for the execution environment. | ||
""") |
There was a problem hiding this comment.
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.
put up revised suggestions in beeankha#2 |
Review suggestions for base image default handling
There was a problem hiding this 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 👍
59e4700
to
8467ce7
Compare
recheck |
Addressing Issue #119