Skip to content

Commit

Permalink
Remove error from tenancy.InitFromViper (#3838)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Aug 1, 2022
1 parent 4d62874 commit ea71bd1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
6 changes: 1 addition & 5 deletions cmd/collector/app/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@ func (opts *GRPCOptions) initFromViper(v *viper.Viper, logger *zap.Logger, cfg s
} else {
return fmt.Errorf("failed to parse gRPC TLS options: %w", err)
}
if tenancy, err := tenancy.InitFromViper(v); err == nil {
opts.Tenancy = tenancy
} else {
return fmt.Errorf("failed to parse Tenancy options: %w", err)
}
opts.Tenancy = tenancy.InitFromViper(v)

return nil
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/query/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ func (qOpts *QueryOptions) InitFromViper(v *viper.Viper, logger *zap.Logger) (*Q
} else {
qOpts.AdditionalHeaders = headers
}
if tenancy, err := tenancy.InitFromViper(v); err == nil {
qOpts.Tenancy = tenancy
} else {
return qOpts, fmt.Errorf("failed to parse Tenancy options: %w", err)
}
qOpts.Tenancy = tenancy.InitFromViper(v)
return qOpts, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/tenancy/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func AddFlags(flags *flag.FlagSet) {
}

// InitFromViper creates tenancy.Options populated with values retrieved from Viper.
func InitFromViper(v *viper.Viper) (Options, error) {
func InitFromViper(v *viper.Viper) Options {
var p Options
p.Enabled = v.GetBool(flagTenancyEnabled)
p.Header = v.GetString(flagTenancyHeader)
Expand All @@ -50,5 +50,5 @@ func InitFromViper(v *viper.Viper) (Options, error) {
p.Tenants = []string{}
}

return p, nil
return p
}
3 changes: 1 addition & 2 deletions pkg/tenancy/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func TestTenancyFlags(t *testing.T) {

err := command.ParseFlags(test.cmd)
require.NoError(t, err)
tenancyCfg, err := InitFromViper(v)
require.NoError(t, err)
tenancyCfg := InitFromViper(v)
assert.Equal(t, test.expected, tenancyCfg)
})
}
Expand Down

0 comments on commit ea71bd1

Please sign in to comment.