# README
Binding Context Generator
Binding Context Generator provides the ability to generate binding contexts for hooks testing purposes.
Usage example:
- Hook Config
config := `
configVersion: v1
schedule:
- name: every_minute
crontab: '* * * * *'
includeSnapshotsFrom:
- pod
kubernetes:
- apiVersion: v1
name: pod
kind: Pod
watchEvent:
- Added
- Modified
- Deleted
namespace:
nameSelector:
matchNames:
- default`
- Initial objects state
initialState := `
---
apiVersion: v1
kind: Pod
metadata:
name: pod-0
---
apiVersion: v1
kind: Pod
metadata:
name: pod-1
`
- New state
newState := `
---
apiVersion: v1
kind: Pod
metadata:
name: pod-0
`
- Create new binding context controller
c := context.NewBindingContextController(config, initialState)
- Register CRDs (if it is necessary) in format [Group, Version, Kind, isNamespaced]:
c.RegisterCRD("example.com", "v1", "Example", true)
c.RegisterCRD("example.com", "v1", "ClusterExample", false)
- Run controller to get initial binding context
contexts, err := c.Run()
if err != nil {
return err
}
testContexts(contexts)
- Change state to get new binding contexts
contexts, err = c.ChangeState(newState)
if err != nil {
return err
}
testNewContexts(contexts)
- Run schedule to get binding contexts for a cron task
contexts, err = c.RunSchedule("* * * * *")
if err != nil {
return err
}
testScheduleContexts(contexts)
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
NewStateController creates controller to apply state changes.
# Constants
TestQueueName is a name of the queue created by ContextCombiner.
TestTaskType is a type for tasks created by ContextCombiner.
# Structs
No description provided by the author
ContextCombiner is used to bring logic behind the combineBindingContextForHook method into tests.
No description provided by the author
StateController holds objects state for FakeCluster.