form.go 1.0 KB

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