form.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. Template *gojq.Query
  13. }
  14. // TemplateReader retrieves data from a target data source, registers a set of
  15. // queries against that data, and returns it via the Read() operation
  16. type TemplateReader interface {
  17. ValuesFromTarget() (map[string]interface{}, error)
  18. RegisterQuery(query *TemplateReaderQuery) error
  19. Read() (map[string]interface{}, error)
  20. ReadStream(
  21. on OnDataStream,
  22. stopCh <-chan struct{},
  23. ) error
  24. }
  25. // TemplateWriter transforms input data and writes to a deployment target
  26. type TemplateWriter interface {
  27. Transform() error
  28. Create(vals map[string]interface{}) (map[string]interface{}, error)
  29. Update(vals map[string]interface{}) (map[string]interface{}, error)
  30. }