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

feat(kubernetes): added deployment name to pod resource id #4040

Merged
merged 7 commits into from Dec 13, 2022

Conversation

PelegLi
Copy link
Contributor

@PelegLi PelegLi commented Dec 11, 2022

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

concatenate the Deployment resource's name to the nested Pod's resource id and adding it to the Pod's config in _parent_resource

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@bo156 bo156 self-requested a review December 11, 2022 14:23
Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

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

nice work, but it would be better to add the actual resource ID for the parent reference 🙂

@@ -147,6 +147,9 @@ def _extract_nested_resources_recursive(conf: Dict[str, Any], all_resources: Lis
if not template or not isinstance(template, dict):
all_resources.append(conf)
return
if conf.get('kind') == 'Deployment':
# means this is a Pod resource nested in a Deployment resource
template[PARENT_RESOURCE_KEY_NAME] = conf.get('metadata', {}).get('name', "")
Copy link
Contributor

Choose a reason for hiding this comment

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

the idea was to add the resource ID of the parent, then it is easier to query it later.

template[PARENT_RESOURCE_ID_KEY_NAME] = ...

Copy link
Contributor

@gruebel gruebel left a comment

Choose a reason for hiding this comment

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

🎄

@@ -147,6 +147,10 @@ def _extract_nested_resources_recursive(conf: Dict[str, Any], all_resources: Lis
if not template or not isinstance(template, dict):
all_resources.append(conf)
return
if conf.get('kind') == 'Deployment':
# means this is a Pod resource nested in a Deployment resource
template[PARENT_RESOURCE_ID_KEY_NAME] = get_resource_id(conf)
Copy link
Contributor

Choose a reason for hiding this comment

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

🥇

@PelegLi PelegLi merged commit 6f5457c into main Dec 13, 2022
@PelegLi PelegLi deleted the change-pod-resource-id branch December 13, 2022 09:24
gruebel pushed a commit to gruebel/checkov that referenced this pull request Dec 13, 2022
…wio#4040)

* changed pod resource id

* use const for parent key name

* improve ut

* fixed ut

* removed empty dict

* added parent resource_id
gruebel pushed a commit to gruebel/checkov that referenced this pull request Dec 13, 2022
…wio#4040)

* changed pod resource id

* use const for parent key name

* improve ut

* fixed ut

* removed empty dict

* added parent resource_id
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.

None yet

4 participants