use centralized api

This commit is contained in:
Denis Mishin 2023-08-15 20:27:55 -04:00
parent aa7a187d53
commit a783f012a7
4 changed files with 7 additions and 11 deletions

2
go.mod
View file

@ -52,7 +52,7 @@ require (
github.com/pomerium/csrf v1.7.0
github.com/pomerium/datasource v0.18.2-0.20221108160055-c6134b5ed524
github.com/pomerium/webauthn v0.0.0-20221118023040-00a9c430578b
github.com/pomerium/zero-sdk v0.0.0-20230813022804-3bf1f871ab31
github.com/pomerium/zero-sdk v0.0.0-20230816000855-af1b8165df05
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.44.0

4
go.sum
View file

@ -657,8 +657,8 @@ github.com/pomerium/datasource v0.18.2-0.20221108160055-c6134b5ed524 h1:3YQY1sb5
github.com/pomerium/datasource v0.18.2-0.20221108160055-c6134b5ed524/go.mod h1:7fGbUYJnU8RcxZJvUvhukOIBv1G7LWDAHMfDxAf5+Y0=
github.com/pomerium/webauthn v0.0.0-20221118023040-00a9c430578b h1:oll/aOfJudnqFAwCvoXK9+WN2zVjTzHVPLXCggHQmHk=
github.com/pomerium/webauthn v0.0.0-20221118023040-00a9c430578b/go.mod h1:KswTenBBh4y1pmhU2dpm8VgJQCgSErCg7OOFTeebrNc=
github.com/pomerium/zero-sdk v0.0.0-20230813022804-3bf1f871ab31 h1:FUoy3dpWd0ECmFHmYVUCJd7lVhQjglZsnrfjvRsVj4w=
github.com/pomerium/zero-sdk v0.0.0-20230813022804-3bf1f871ab31/go.mod h1:cAyfEGM8blUzchYhOWrufuj/6lOF277meB4c/TjMS28=
github.com/pomerium/zero-sdk v0.0.0-20230816000855-af1b8165df05 h1:Rl2df8q+DAd3SsJn9MpXrbo7JRNCDHVaohOyUZ2IJik=
github.com/pomerium/zero-sdk v0.0.0-20230816000855-af1b8165df05/go.mod h1:cAyfEGM8blUzchYhOWrufuj/6lOF277meB4c/TjMS28=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=

View file

@ -37,11 +37,9 @@ const (
func (svc *Source) Run(
ctx context.Context,
api *sdk.API,
mux *connect_mux.Mux,
fileCachePath string,
) error {
svc.clusterAPI = api
svc.connectMux = mux
svc.api = api
svc.fileCachePath = fileCachePath
svc.tryLoadInitial(ctx)
@ -54,7 +52,7 @@ func (svc *Source) Run(
}
func (svc *Source) watchUpdates(ctx context.Context) error {
return svc.connectMux.Watch(ctx,
return svc.api.Watch(ctx,
connect_mux.WithOnConnected(func(_ context.Context) {
svc.triggerUpdate(DefaultCheckForUpdateIntervalWhenConnected)
}),
@ -103,7 +101,7 @@ func (svc *Source) triggerUpdate(newUpdateInterval time.Duration) {
}
func (svc *Source) updateAndSave(ctx context.Context) error {
cfg, err := svc.clusterAPI.GetClusterBootstrapConfig(ctx)
cfg, err := svc.api.GetClusterBootstrapConfig(ctx)
if err != nil {
return fmt.Errorf("load bootstrap config from API: %w", err)
}

View file

@ -17,15 +17,13 @@ import (
"github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/pkg/netutil"
sdk "github.com/pomerium/zero-sdk"
connect_mux "github.com/pomerium/zero-sdk/connect-mux"
)
// Source is a base config layer for Pomerium
type Source struct {
source
clusterAPI *sdk.API
connectMux *connect_mux.Mux
api *sdk.API
fileCachePath string
fileCipher cipher.AEAD