Skip to content

Commit

Permalink
TSDB-115: Fix propagation of password and token. (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Topper authored and gshatz committed May 14, 2019
1 parent f0f77c7 commit cf521f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions backends/tsdb/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (b *Backend) newConfig(session *frames.Session) *config.V3ioConfig {
return config.WithDefaults(cfg)
}

func (b *Backend) newAdapter(session *frames.Session, path string) (*tsdb.V3ioAdapter, error) {
func (b *Backend) newAdapter(session *frames.Session, password string, token string, path string) (*tsdb.V3ioAdapter, error) {

session = frames.InitSessionDefaults(session, b.framesConfig)
containerName, newPath, err := v3ioutils.ProcessPaths(session, path, false)
Expand All @@ -86,8 +86,8 @@ func (b *Backend) newAdapter(session *frames.Session, path string) (*tsdb.V3ioAd

container, err := v3ioutils.NewContainer(
session,
"",
"",
password,
token,
b.logger,
cfg.Workers,
)
Expand All @@ -107,10 +107,10 @@ func (b *Backend) newAdapter(session *frames.Session, path string) (*tsdb.V3ioAd
}

// GetAdapter returns an adapter
func (b *Backend) GetAdapter(session *frames.Session, path string) (*tsdb.V3ioAdapter, error) {
func (b *Backend) GetAdapter(session *frames.Session, password string, token string, path string) (*tsdb.V3ioAdapter, error) {
// TODO: maintain adapter cache, for now create new per read/write request

adapter, err := b.newAdapter(session, path)
adapter, err := b.newAdapter(session, password, token, path)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (b *Backend) Delete(request *frames.DeleteRequest) error {

delAll := request.Proto.Start == "" && request.Proto.End == ""

adapter, err := b.GetAdapter(request.Proto.Session, request.Proto.Table)
adapter, err := b.GetAdapter(request.Proto.Session, request.Password.Get(), request.Token.Get(), request.Proto.Table)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion backends/tsdb/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (b *Backend) Read(request *frames.ReadRequest) (frames.FrameIterator, error
return nil, err
}
}
adapter, err := b.GetAdapter(request.Proto.Session, table)
adapter, err := b.GetAdapter(request.Proto.Session, request.Password.Get(), request.Token.Get(), table)
if err != nil {
return nil, errors.Wrap(err, "failed to create adapter")
}
Expand Down
2 changes: 1 addition & 1 deletion backends/tsdb/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

func (b *Backend) Write(request *frames.WriteRequest) (frames.FrameAppender, error) {
b.logger.InfoWith("write request", "request", request)
adapter, err := b.GetAdapter(request.Session, request.Table)
adapter, err := b.GetAdapter(request.Session, request.Password.Get(), request.Token.Get(), request.Table)
if err != nil {
return nil, errors.Wrap(err, "failed to create adapter")
}
Expand Down

0 comments on commit cf521f4

Please sign in to comment.