Skip to content

How to get the the event/binding context #361

Answered by nabokihms
sl4dy asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @sl4dy. It feels like BindingContextGenerator is what you want.

func Test_BindingContextGenerator_Print(t *testing.T) {
	c := NewBindingContextController(`
configVersion: v1
kubernetes:
- apiVersion: v1
  includeSnapshotsFrom:
  - pods
  kind: Pod
  name: pods
`)

	// Synchronization contexts
	contexts, _ := c.Run(``)
	fmt.Println("Sync: ", contexts.Rendered)

	// Object added
	contexts, _ = c.ChangeState(`
---
apiVersion: v1
kind: Pod
metadata:
  name: pod1
`)
	fmt.Println("Added: ", contexts.Rendered)

	// Object deleted
	contexts, _ = c.ChangeState(``)
	fmt.Println("Deleted: ", contexts.Rendered)
}

Response:

Sync:  [
  {
    "binding": "pods",
    "objects": [],
    "snapshots": …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sl4dy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants