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 Aug 2, 2019
@codenio
Copy link
Contributor Author

@codenio codenio commented Aug 2, 2019

rebased to develop

@PrasadG193
Copy link
Member

@PrasadG193 PrasadG193 commented Aug 5, 2019

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

@codenio codenio force-pushed the feature/annotation-filter branch from 5a39342 to 84d12fa Aug 5, 2019
@codenio
Copy link
Contributor Author

@codenio codenio commented Aug 5, 2019

@PrasadG193, Rebased to develop. thanks 👍

pkg/controller/controller.go Outdated Show resolved Hide resolved
@codenio codenio force-pushed the feature/annotation-filter branch 2 times, most recently from afca609 to b1c42ba Aug 7, 2019
@codenio
Copy link
Contributor Author

@codenio codenio commented Aug 7, 2019

Resolved requested changes.

@codenio codenio force-pushed the feature/annotation-filter branch from b1c42ba to 81e745e Aug 8, 2019
@codenio
Copy link
Contributor Author

@codenio 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 Aug 9, 2019
codenio added 2 commits Aug 9, 2019
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 Aug 9, 2019
Copy link
Contributor Author

@codenio codenio left a comment

Lets make sure we have unit tests around this scenario.

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

@codenio codenio Aug 12, 2019

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
Member

@sanketsudake sanketsudake commented Aug 12, 2019

@aananthraj Please rebase PR.

@codenio
Copy link
Contributor Author

@codenio codenio commented Aug 12, 2019

Sure, thanks

@PrasadG193 PrasadG193 merged commit 72f2f19 into infracloudio:develop Aug 12, 2019
1 check passed
@codenio codenio deleted the feature/annotation-filter branch Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants