plugin.template 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package {{.package}}
  2. import (
  3. "gopkg.in/src-d/go-git.v4"
  4. "gopkg.in/src-d/hercules.v3"
  5. )
  6. // {{.name}} contains the intermediate state which is mutated by Consume(). It should implement
  7. // hercules.LeafPipelineItem.
  8. type {{.name}} struct {
  9. }
  10. // {{.name}}Result is returned by Finalize() and represents the analysis result.
  11. type {{.name}}Result struct {
  12. }
  13. // Analysis' name in the graph is usually the same as the type's name, however, does not have to.
  14. func ({{.varname}} *{{.name}}) Name() string {
  15. return "{{.name}}"
  16. }
  17. // LeafPipelineItem-s normally do not act as intermediate nodes and thus we return an empty slice.
  18. func ({{.varname}} *{{.name}}) Provides() []string {
  19. return []string{}
  20. }
  21. // Requires returns the list of dependencies which must be supplied in Consume().
  22. func ({{.varname}} *{{.name}}) Requires() []string {
  23. arr := [...]string{/* insert dependencies here */}
  24. return arr[:]
  25. }
  26. func ({{.varname}} *{{.name}}) ListConfigurationOptions() []hercules.ConfigurationOption {
  27. return []hercules.ConfigurationOption{}
  28. }
  29. func ({{.varname}} *{{.name}}) Flag() string {
  30. return "{{.flag}}"
  31. }
  32. func ({{.varname}} *{{.name}}) Configure(facts map[string]interface{}) {
  33. }
  34. func ({{.varname}} *{{.name}}) Initialize(repository *git.Repository) {
  35. }
  36. func ({{.varname}} *{{.name}}) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
  37. return nil, nil
  38. }
  39. func ({{.varname}} *{{.name}}) Finalize() interface{} {
  40. result := {{.name}}Result{}
  41. // insert code here
  42. return result
  43. }
  44. func init() {
  45. hercules.Registry.Register(&{{.name}}{})
  46. }