mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 16:30:17 +02:00
upstream endpoints load balancer weights (#1830)
This commit is contained in:
parent
3567183ce5
commit
67f6030e1e
30 changed files with 1190 additions and 778 deletions
|
@ -3,19 +3,40 @@ package config
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
const (
|
||||
policyKey = "policy"
|
||||
toKey = "to"
|
||||
envoyOptsKey = "_envoy_opts"
|
||||
)
|
||||
|
||||
var (
|
||||
errKeysMustBeStrings = errors.New("cannot convert nested map: all keys must be strings")
|
||||
errKeysMustBeStrings = errors.New("cannot convert nested map: all keys must be strings")
|
||||
errZeroWeight = errors.New("zero load balancing weight not permitted")
|
||||
errEndpointWeightsSpec = errors.New("either no weights should be provided, or all endpoints must have non-zero weight specified")
|
||||
errHostnameMustBeSpecified = errors.New("endpoint hostname must be specified")
|
||||
errSchemeMustBeSpecified = errors.New("url scheme must be provided")
|
||||
errEmptyUrls = errors.New("url list is empty")
|
||||
errEitherToOrRedirectRequired = errors.New("policy should have either `to` or `redirect` defined")
|
||||
)
|
||||
|
||||
var (
|
||||
protoPartial = protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
// viperPolicyHooks are used to decode options and policy coming from YAML and env vars
|
||||
viperPolicyHooks = viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(
|
||||
mapstructure.StringToTimeDurationHookFunc(),
|
||||
mapstructure.StringToSliceHookFunc(","),
|
||||
// decode policy including all protobuf-native notations - i.e. duration as `1s`
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
||||
DecodePolicyHookFunc(),
|
||||
// parse base-64 encoded POLICY that is bound to environment variable
|
||||
DecodePolicyBase64Hook(),
|
||||
))
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue