Skip to content

Commit

Permalink
scyllaclient: extract hosts to parameters in default config
Browse files Browse the repository at this point in the history
  • Loading branch information
zimnx committed Dec 18, 2020
1 parent 3016c50 commit 012221a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pkg/controllers/sidecar/sidecar_controller.go
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/scylladb/scylla-operator/pkg/naming"
"github.com/scylladb/scylla-operator/pkg/scyllaclient"
"github.com/scylladb/scylla-operator/pkg/util/cfgutil"
"github.com/scylladb/scylla-operator/pkg/util/network"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -100,7 +101,12 @@ func New(ctx context.Context, mgr manager.Manager, logger log.Logger) (*MemberRe
return nil, errors.Wrap(err, "get dynamic client")
}

cfg := scyllaclient.DefaultConfig()
host, err := network.FindFirstNonLocalIP()
if err != nil {
return nil, errors.Wrap(err, "get scylla address")
}

cfg := scyllaclient.DefaultConfig(host.String())
if err := cfgutil.ParseYAML(&cfg, naming.ScyllaClientConfigDirName+"/"+naming.ScyllaClientConfigFileName); err != nil {
return nil, errors.Wrap(err, "parse scylla agent config")
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/scyllaclient/config.go
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/pkg/errors"
"github.com/scylladb/scylla-operator/pkg/util/network"
"go.uber.org/multierr"
)

Expand Down Expand Up @@ -48,10 +47,9 @@ type BackoffConfig struct {
}

// DefaultConfig returns a Config initialized with default values.
func DefaultConfig() Config {
host, _ := network.FindFirstNonLocalIP()
func DefaultConfig(hosts ...string) Config {
return Config{
Hosts: []string{host.String()},
Hosts: hosts,
Port: "10001",
Scheme: "https",
Timeout: 15 * time.Second,
Expand Down

0 comments on commit 012221a

Please sign in to comment.