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

[feature] Add Object Annotation filter, Fixes #132, #133 #138

Merged
merged 3 commits into from
Aug 12, 2019

Conversation

codenio
Copy link
Contributor

@codenio codenio commented Aug 1, 2019

ISSUE TYPE
  • Feature Pull Request
SUMMARY

This commit,

  • enables filtering of events based on annotations present in objects at run time.
  • annotation botkube.io/disable: true disables event notifications for the annotated object
  • annotation botkube.io/channel: <channel_name> sends events notifications of the annotated object to the mentioned channel.
  • adds func utils.ExtractAnnotations(). It extracts annotations from Event.InvolvedObject. Extracted Annotations are then added to the event.Metadata.Annotations
  • implements individual actions using internal functions.
  • adds unit tests for internal functions.
  • replaces utils.Init() with InitialiseKubeClient() to decouple config.yaml and KubeClinet dependencies from unit testing

Fixes #132

Adding botkube.io/channel: <channel_name> annotation to a kubenetes resources sends all the notifications of the annotated object to specified channel in the workspace.
This provides a way to classify notifications based on internal teams or workgroup by using the annotation data available in the resources.

Fixes #133

Adding botkube.io/disable: true annotation to a kubernetes resource, skips the notifications about the annotated object from being sent to the channels.
This provides us the control to enable or disable notifications of a particular object at run time.
Up

@codenio codenio force-pushed the feature/annotation-filter branch from 531b9e5 to 5a39342 Compare August 2, 2019 05:26
@codenio
Copy link
Contributor Author

codenio commented Aug 2, 2019

rebased to develop

@PrasadG193
Copy link
Collaborator

Thanks for the PR @aananthraj! Please rebase your branch with develop.

@codenio codenio force-pushed the feature/annotation-filter branch from 5a39342 to 84d12fa Compare August 5, 2019 12:47
@codenio
Copy link
Contributor Author

codenio commented Aug 5, 2019

@PrasadG193, Rebased to develop. thanks 👍

@codenio codenio force-pushed the feature/annotation-filter branch 2 times, most recently from afca609 to b1c42ba Compare August 7, 2019 19:42
@codenio
Copy link
Contributor Author

codenio commented Aug 7, 2019

Resolved requested changes.

@codenio codenio force-pushed the feature/annotation-filter branch from b1c42ba to 81e745e Compare August 8, 2019 13:01
@codenio
Copy link
Contributor Author

codenio commented Aug 8, 2019

Rebased onto develop

@codenio codenio force-pushed the feature/annotation-filter branch 2 times, most recently from b8ee76d to 273bbce Compare August 9, 2019 10:59
codenio added 2 commits August 9, 2019 23:20
This commit, 
- enables filtering of events based on annotations present in objects at run time.
- annotation `botkube.io/disable: true` disables event notifications for the annotated object
- annotation `botkube.io/channel: <channel_name>` sends events notifications of the annotated object to the mentioned channel.
- adds func `ExtractAnnotations()`. It extract annotations from Event.InvolvedObject and adds them to event.Metadata.Annotations
- implements individual actions using internal functions.
- adds unit tests for internal functions.
- replaces Init() with InitialiseKubeClient() to decouple config.yaml and KubeClinet dependencies from unit testing
@codenio codenio force-pushed the feature/annotation-filter branch from 273bbce to 88dbb3e Compare August 9, 2019 17:52
Copy link
Contributor Author

@codenio codenio left a comment

Choose a reason for hiding this comment

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

Lets make sure we have unit tests around this scenario.

expectedChannel string
expectedBool bool
}{
`Empty ObjectMeta`: {metaV1.ObjectMeta{}, "", false},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess, this covers the emty object use case as well as the object not available (object deleted) use case.
Do correct me, if am missing something.

pkg/utils/utils.go Show resolved Hide resolved
@sanketsudake
Copy link
Contributor

@aananthraj Please rebase PR.

@codenio
Copy link
Contributor Author

codenio commented Aug 12, 2019

Sure, thanks

@PrasadG193 PrasadG193 merged commit 72f2f19 into kubeshop:develop Aug 12, 2019
@codenio codenio deleted the feature/annotation-filter branch August 16, 2019 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants