feat: port apply command from influxdb (#160)

This commit is contained in:
Daniel Moran
2021-06-30 14:47:23 -04:00
committed by GitHub
parent d7b2983dd4
commit a3f36a9821
8 changed files with 1037 additions and 8 deletions

View File

@ -180,7 +180,7 @@ func SourceFromReader(r io.Reader, encoding TemplateEncoding) TemplateSource {
}
}
func (s TemplateSource) Read(ctx context.Context) ([]api.TemplateEntry, error) {
func (s TemplateSource) Read(ctx context.Context) (api.TemplateApplyTemplate, error) {
var entries []api.TemplateEntry
if err := func() error {
in, err := s.Open(ctx)
@ -210,8 +210,11 @@ func (s TemplateSource) Read(ctx context.Context) ([]api.TemplateEntry, error) {
}
return err
}(); err != nil {
return nil, fmt.Errorf("failed to read template(s) from %q: %w", s.Name, err)
return api.TemplateApplyTemplate{}, fmt.Errorf("failed to read template(s) from %q: %w", s.Name, err)
}
return entries, nil
return api.TemplateApplyTemplate{
Sources: []string{s.Name},
Contents: entries,
}, nil
}