form.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package templater
  2. import (
  3. // "k8s.io/client-go/util/jsonpath"
  4. "github.com/itchyny/gojq"
  5. )
  6. // OnDataStream is a function that gets called when new data should be
  7. // streamed to the client. The data has the generic type map[string]interface{}.
  8. type OnDataStream func(val map[string]interface{}) error
  9. type TemplateReaderQuery struct {
  10. Key string
  11. QueryString string
  12. Default interface{}
  13. Template *gojq.Query
  14. }
  15. // TemplateReader retrieves data from a target data source, registers a set of
  16. // queries against that data, and returns it via the Read() operation
  17. type TemplateReader interface {
  18. ValuesFromTarget() (map[string]interface{}, error)
  19. RegisterQuery(query *TemplateReaderQuery) error
  20. Read() (map[string]interface{}, error)
  21. ReadStream(
  22. on OnDataStream,
  23. stopCh <-chan struct{},
  24. ) error
  25. }
  26. // TemplateWriter transforms input data and writes to a deployment target
  27. type TemplateWriter interface {
  28. Transform() error
  29. Create(vals map[string]interface{}) (map[string]interface{}, error)
  30. Update(vals map[string]interface{}) (map[string]interface{}, error)
  31. }