Apply ProviderAddr from options to cs3config

This commit is contained in:
Ilja Neumann
2020-10-06 17:43:19 +02:00
parent a852edc763
commit 4300f6a3cf
4 changed files with 19 additions and 6 deletions

View File

@@ -64,7 +64,12 @@ func NewUniqueIndexWithOptions(o ...option.Option) index.Index {
indexBaseDir: path.Join(opts.DataDir, "index.cs3"),
indexRootDir: path.Join(path.Join(opts.DataDir, "index.cs3"), strings.Join([]string{"unique", opts.TypeName, opts.IndexBy}, ".")),
cs3conf: &Config{
JWTSecret: opts.JWTSecret,
ProviderAddr: opts.ProviderAddr,
DataURL: opts.DataURL,
DataPrefix: opts.DataPrefix,
JWTSecret: opts.JWTSecret,
ServiceUserName: "",
ServiceUserUUID: "",
},
dataProvider: dataProviderClient{
baseURL: singleJoiningSlash(opts.DataURL, opts.DataPrefix),

View File

@@ -68,6 +68,7 @@ func (i Indexer) AddUniqueIndex(t interface{}, indexBy, pkName, entityDirName st
option.WithDataURL(i.newConfig.Repo.CS3.DataURL),
option.WithDataPrefix(i.newConfig.Repo.CS3.DataPrefix),
option.WithJWTSecret(i.newConfig.Repo.CS3.JWTSecret),
option.WithProviderAddr(i.newConfig.Repo.CS3.ProviderAddr),
)
}

View File

@@ -7,6 +7,7 @@ import (
. "github.com/owncloud/ocis/accounts/pkg/indexer/test"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
@@ -28,7 +29,7 @@ func TestIndexer_AddWithUniqueIndex(t *testing.T) {
}
func TestIndexer_AddWithUniqueIndexCS3(t *testing.T) {
_ = WriteIndexTestDataCS3(t, TestData, "Id")
dataDir := WriteIndexTestDataCS3(t, TestData, "Id")
indexer := CreateIndexer(&config.Config{
Repo: config.Repo{
CS3: config.CS3{
@@ -46,7 +47,7 @@ func TestIndexer_AddWithUniqueIndexCS3(t *testing.T) {
err := indexer.Add(u)
assert.NoError(t, err)
//_ = os.RemoveAll(dataDir)
_ = os.RemoveAll(dataDir)
}
func TestIndexer_FindByWithUniqueIndex(t *testing.T) {

View File

@@ -14,9 +14,10 @@ type Options struct {
EntityDirName string
// CS3 options
DataURL string
DataPrefix string
JWTSecret string
DataURL string
DataPrefix string
JWTSecret string
ProviderAddr string
}
// newOptions initializes the available default options.
@@ -83,3 +84,8 @@ func WithFilesDir(val string) Option {
o.FilesDir = val
}
}
func WithProviderAddr(val string) Option {
return func(o *Options) {
o.ProviderAddr = val
}
}