-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add --tags and --skip-tags options #81
Conversation
Codecov Report
@@ Coverage Diff @@
## master #81 +/- ##
==========================================
+ Coverage 84.85% 84.97% +0.11%
==========================================
Files 12 12
Lines 1182 1211 +29
==========================================
+ Hits 1003 1029 +26
- Misses 179 182 +3
Continue to review full report at Codecov.
|
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.
Good, but some comments. Changes up to you.
k8s_handle/templating.py
Outdated
@@ -113,6 +116,40 @@ def generate_by_context(self, context): | |||
raise TemplateRenderingError('Unable to render {}, due to: {}'.format(template, e)) | |||
return output | |||
|
|||
def _filter_tagged_templates(self, templates, only_tags, skip_tags): | |||
return [i for i in templates if self._evaluate_tags(i, only_tags, skip_tags)] |
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.
More idiomatic way:
return templates.filter(lambda i: self._evaluate_tags(i, only_tags, skip_tags))
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.
So, maybe def _filter_tagged_templates(self, templates, only_tags, skip_tags)
, not required at all.
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.
Ok, I replaced _filter_tagged_templates()
to filter()
+ lambda
:
templates = filter(
lambda i: self._evaluate_tags(self._get_template_tags(i),
settings.ONLY_TAGS,
settings.SKIP_TAGS),
templates
)
k8s_handle/templating.py
Outdated
def _filter_tagged_templates(self, templates, only_tags, skip_tags): | ||
return [i for i in templates if self._evaluate_tags(i, only_tags, skip_tags)] | ||
|
||
def _evaluate_tags(self, template, only_tags, skip_tags): |
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.
The method return true
or false
, maybe _is_template_tagged(...)
more accurate name?
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 like both names actually (especially after moving "template" part into separate function). 🙁
Please let me know if _is_template_tagged(self, tags, only_tags, skip_tags)
still looks better for you after last changes.
k8s_handle/templating.py
Outdated
return [i for i in templates if self._evaluate_tags(i, only_tags, skip_tags)] | ||
|
||
def _evaluate_tags(self, template, only_tags, skip_tags): | ||
if 'tags' in template: |
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 think we need to separate template tags analysis and skipping logic to 2 different functions.
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 moved first part into _get_template_tags()
.
Also, don't forget to add description about this feature in README.md |
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.
LGTM
Иллюстрация к #80.