botkube/test/resource_config.yaml
Jirka Kremser 86d2572e56
Add a support for ignoring the events from a namespace that matches regexp (#386)
Fixes issue #295

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Feature Pull Request

##### SUMMARY
<!--- Describe the change, including rationale and design decisions -->
This change allows to ignore whole sets of namespaces using the asterix expansion. It still does the exact match check for all the namespaces (separated by comma in config), but if it contains a `*`, it's actually replaced with `.*` and passed to `regexp.MatchString` to do the job.

PR also contains couple of very simple test cases.

<!---
If you are fixing an existing issue, please include "Fixes #nnn" in your
PR comment; and describe briefly what the change does.
-->

<!--- Please list dependencies added with your change also -->
deps:
`namespace_checker.go` now imports also `regexp`

Fixes #295

It's my very first golang code, so please let me know if it's not idiomatic go 🍪
2020-10-02 16:07:09 +00:00

243 lines
5.8 KiB
YAML

# Copyright (c) 2019 InfraCloud Technologies
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## test_config.yaml for Integration Testing
## Resources you want to watch
resources:
- name: v1/pods # Name of the resources e.g pod, deployment, ingress, etc.
namespaces: # List of namespaces, "all" will watch all the namespaces
include:
- all
ignore: # List of namespaces to be ignored (omitempty), used only with include: all, can contain a wildcard (*)
- # example : include [all], ignore [x,y,secret-ns-*]
events: # List of lifecycle events you want to receive, e.g create, update, delete, error OR all
- create
- delete
- error
- update
updateSetting:
includeDiff: true
fields:
- spec.containers[*].image
- name: v1/services
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: apps/v1/deployments
namespaces:
include:
- all
ignore:
-
events:
- create
- update
- delete
- error
updateSetting:
includeDiff: true
fields:
- spec.template.spec.containers[*].image
- status.availableReplicas
- name: apps/v1/statefulsets
namespaces:
include:
- all
ignore:
-
events:
- create
- update
- delete
- error
- name: networking.k8s.io/v1beta1/ingresses
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/nodes
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/namespaces
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/persistentvolumes
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/persistentvolumeclaims
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/secrets
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: v1/configmaps
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: apps/v1/daemonsets
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
updateSetting:
includeDiff: true
fields:
- spec.template.spec.containers[*].image
- status.numberReady
- name: batch/v1/jobs
namespaces:
include:
- all
ignore:
-
events:
- create
- update
- delete
- error
updateSetting:
includeDiff: true
fields:
- spec.template.spec.containers[*].image
- status.conditions[*].type
- name: rbac.authorization.k8s.io/v1/roles
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: rbac.authorization.k8s.io/v1/rolebindings
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: rbac.authorization.k8s.io/v1/clusterrolebindings
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
- name: samplecontroller.k8s.io/v1alpha1/foos
namespaces:
include:
- all
ignore:
-
events:
- create
- delete
- error
# Check true if you want to receive recommendations
# about the best practices for the created resource
recommendations: true
# Setting to support multiple clusters
settings:
# Cluster name to differentiate incoming messages
clustername: test-cluster-1
# Kubectl executor configs
kubectl:
# Set true to enable kubectl commands execution
enabled: true
# List of allowed commands
commands:
# method which are allowed
verbs: ["api-resources", "api-versions", "cluster-info", "describe", "diff", "explain", "get", "logs", "top", "auth"]
# resource configuration which is allowed
resources: ["deployments", "pods" , "namespaces", "daemonsets", "statefulsets", "storageclasses", "nodes"]
# set Namespace to execute botkube kubectl commands by default
defaultNamespace: default
# Set true to enable commands execution from configured channel only
restrictAccess: true
# Set true to enable config watcher
configwatcher: false
# Set false to disable upgrade notification
upgradeNotifier: false