Skip to content

Commit

Permalink
Fix setting env var (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanayotov authored Oct 22, 2019
1 parent 45db61e commit 0ed8b0e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/k8s/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ type Settings struct {
K8S *ClientConfiguration `mapstructure:"k8s"`
}

// DefaultSettings returns the default settings for the k8s agent
func DefaultSettings() *Settings {
return &Settings{
Settings: *sbproxy.DefaultSettings(),
K8S: DefaultClientConfiguration(),
}
}

// Validate validates the application settings
func (s *Settings) Validate() error {
if err := s.K8S.Validate(); err != nil {
Expand Down Expand Up @@ -132,15 +140,12 @@ func DefaultClientConfiguration() *ClientConfiguration {

// CreatePFlagsForK8SClient adds pflags relevant to the K8S client config
func CreatePFlagsForK8SClient(set *pflag.FlagSet) {
env.CreatePFlags(set, &Settings{K8S: DefaultClientConfiguration()})
env.CreatePFlags(set, DefaultSettings())
}

// NewConfig creates Settings from the provided environment
func NewConfig(env env.Environment) (*Settings, error) {
settings := &Settings{
Settings: *sbproxy.DefaultSettings(),
K8S: DefaultClientConfiguration(),
}
settings := DefaultSettings()

if err := env.Unmarshal(settings); err != nil {
return nil, err
Expand Down

0 comments on commit 0ed8b0e

Please sign in to comment.