2018-08-28 19:53:20 +00:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-04-03 17:39:20 +00:00
|
|
|
platform "github.com/influxdata/influxdb/v2"
|
|
|
|
"github.com/influxdata/influxdb/v2/http"
|
|
|
|
"github.com/influxdata/influxdb/v2/http/influxdb"
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/tenant"
|
2018-08-28 19:53:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewBucketService creates a bucket service from a source.
|
|
|
|
func NewBucketService(s *platform.Source) (platform.BucketService, error) {
|
|
|
|
switch s.Type {
|
|
|
|
case platform.SelfSourceType:
|
|
|
|
// TODO(fntlnz): this is supposed to call a bucket service directly locally,
|
|
|
|
// we are letting it err for now since we have some refactoring to do on
|
|
|
|
// how services are instantiated
|
|
|
|
return nil, fmt.Errorf("self source type not implemented")
|
|
|
|
case platform.V2SourceType:
|
2019-12-07 18:54:03 +00:00
|
|
|
httpClient, err := http.NewHTTPClient(s.URL, s.Token, s.InsecureSkipVerify)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
return &tenant.BucketClientService{Client: httpClient}, nil
|
2018-08-28 19:53:20 +00:00
|
|
|
case platform.V1SourceType:
|
2019-12-07 18:54:03 +00:00
|
|
|
return &influxdb.BucketService{Source: s}, nil
|
2018-08-28 19:53:20 +00:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unsupported source type %s", s.Type)
|
|
|
|
}
|