mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
databroker: refactor databroker to sync all changes (#1879)
* refactor backend, implement encrypted store * refactor in-memory store * wip * wip * wip * add syncer test * fix redis expiry * fix linting issues * fix test by skipping non-config records * fix backoff import * fix init issues * fix query * wait for initial sync before starting directory sync * add type to SyncLatest * add more log messages, fix deadlock in in-memory store, always return server version from SyncLatest * update sync types and tests * add redis tests * skip macos in github actions * add comments to proto * split getBackend into separate methods * handle errors in initVersion * return different error for not found vs other errors in get * use exponential backoff for redis transaction retry * rename raw to result * use context instead of close channel * store type urls as constants in databroker * use timestampb instead of ptypes * fix group merging not waiting * change locked names * update GetAll to return latest record version * add method to grpcutil to get the type url for a protobuf type
This commit is contained in:
parent
b1871b0f2e
commit
5d60cff21e
66 changed files with 2762 additions and 2871 deletions
|
@ -109,9 +109,9 @@ func decodeJWTClaimHeadersHookFunc() mapstructure.DecodeHookFunc {
|
|||
// A StringSlice is a slice of strings.
|
||||
type StringSlice []string
|
||||
|
||||
// NewStringSlice creatse a new StringSlice.
|
||||
// NewStringSlice creates a new StringSlice.
|
||||
func NewStringSlice(values ...string) StringSlice {
|
||||
return StringSlice(values)
|
||||
return values
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -197,7 +197,7 @@ type WeightedURL struct {
|
|||
LbWeight uint32
|
||||
}
|
||||
|
||||
// Validate validates the WeightedURL.
|
||||
// Validate validates that the WeightedURL is valid.
|
||||
func (u *WeightedURL) Validate() error {
|
||||
if u.URL.Hostname() == "" {
|
||||
return errHostnameMustBeSpecified
|
||||
|
@ -227,6 +227,7 @@ func ParseWeightedURL(dst string) (*WeightedURL, error) {
|
|||
return &WeightedURL{*u, w}, nil
|
||||
}
|
||||
|
||||
// String returns the WeightedURL as a string.
|
||||
func (u *WeightedURL) String() string {
|
||||
str := u.URL.String()
|
||||
if u.LbWeight == 0 {
|
||||
|
@ -235,7 +236,7 @@ func (u *WeightedURL) String() string {
|
|||
return fmt.Sprintf("{url=%s, weight=%d}", str, u.LbWeight)
|
||||
}
|
||||
|
||||
// WeightedURLs is a slice of WeightedURL.
|
||||
// WeightedURLs is a slice of WeightedURLs.
|
||||
type WeightedURLs []WeightedURL
|
||||
|
||||
// ParseWeightedUrls parses
|
||||
|
@ -285,9 +286,9 @@ func (urls WeightedURLs) Validate() (HasWeight, error) {
|
|||
}
|
||||
|
||||
if noWeight {
|
||||
return HasWeight(false), nil
|
||||
return false, nil
|
||||
}
|
||||
return HasWeight(true), nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Flatten converts weighted url array into indidual arrays of urls and weights
|
||||
|
@ -311,7 +312,7 @@ func (urls WeightedURLs) Flatten() ([]string, []uint32, error) {
|
|||
return str, wghts, nil
|
||||
}
|
||||
|
||||
// DecodePolicyBase64Hook creates a mapstructure DecodeHookFunc.
|
||||
// DecodePolicyBase64Hook returns a mapstructure decode hook for base64 data.
|
||||
func DecodePolicyBase64Hook() mapstructure.DecodeHookFunc {
|
||||
return func(f, t reflect.Type, data interface{}) (interface{}, error) {
|
||||
if t != reflect.TypeOf([]Policy{}) {
|
||||
|
@ -332,7 +333,7 @@ func DecodePolicyBase64Hook() mapstructure.DecodeHookFunc {
|
|||
return nil, fmt.Errorf("base64 decoding policy data: %w", err)
|
||||
}
|
||||
|
||||
out := []map[interface{}]interface{}{}
|
||||
var out []map[interface{}]interface{}
|
||||
if err = yaml.Unmarshal(bytes, &out); err != nil {
|
||||
return nil, fmt.Errorf("parsing base64-encoded policy data as yaml: %w", err)
|
||||
}
|
||||
|
@ -341,7 +342,7 @@ func DecodePolicyBase64Hook() mapstructure.DecodeHookFunc {
|
|||
}
|
||||
}
|
||||
|
||||
// DecodePolicyHookFunc creates a mapstructure DecodeHookFunc.
|
||||
// DecodePolicyHookFunc returns a Decode Hook for mapstructure.
|
||||
func DecodePolicyHookFunc() mapstructure.DecodeHookFunc {
|
||||
return func(f, t reflect.Type, data interface{}) (interface{}, error) {
|
||||
if t != reflect.TypeOf(Policy{}) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue