Skip to content

Commit

Permalink
optimize pipline gates (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz authored Nov 4, 2024
1 parent cd6ae2c commit dabab73
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/open-policy-agent/gatekeeper/v3 v3.17.1
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/pkg/errors v0.9.1
github.com/pluralsh/console/go/client v1.22.2
github.com/pluralsh/console/go/client v1.22.3
github.com/pluralsh/controller-reconcile-helper v0.1.0
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
github.com/pluralsh/polly v0.1.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pluralsh/console/go/client v1.22.2 h1:mOWPel/oZ9vypJvF136/CWIl6P2Rj89uarHvoRJDnHI=
github.com/pluralsh/console/go/client v1.22.2/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/console/go/client v1.22.3 h1:5CUV4E/EH5G84ZVIIdr4NuUzM92AKUrZBLEh2SjLeEc=
github.com/pluralsh/console/go/client v1.22.3/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/controller-reconcile-helper v0.1.0 h1:BV3dYZFH5rn8ZvZjtpkACSv/GmLEtRftNQj/Y4ddHEo=
github.com/pluralsh/controller-reconcile-helper v0.1.0/go.mod h1:RxAbvSB4/jkvx616krCdNQXPbpGJXW3J1L3rASxeFOA=
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Client interface {
ParsePipelineGateCR(pgFragment *console.PipelineGateFragment, operatorNamespace string) (*v1alpha1.PipelineGate, error)
GateExists(id string) bool
GetClusterGate(id string) (*console.PipelineGateFragment, error)
GetClusterGates(after *string, first *int64) (*console.PagedClusterGates, error)
GetClusterGates(after *string, first *int64) (*console.PagedClusterGateIDs, error)
UpdateGate(id string, attributes console.GateUpdateAttributes) error
UpsertConstraints(constraints []*console.PolicyConstraintAttributes) (*console.UpsertPolicyConstraints, error)
GetNamespace(id string) (*console.ManagedNamespaceFragment, error)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func (c *client) UpdateGate(id string, attributes console.GateUpdateAttributes)
return err
}

func (c *client) GetClusterGates(after *string, first *int64) (*console.PagedClusterGates, error) {
resp, err := c.consoleClient.PagedClusterGates(c.ctx, after, first, nil, nil)
func (c *client) GetClusterGates(after *string, first *int64) (*console.PagedClusterGateIDs, error) {
resp, err := c.consoleClient.PagedClusterGateIDs(c.ctx, after, first, nil, nil)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/pipelinegates/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ func (s *GateReconciler) GetPollInterval() time.Duration {
return s.pollInterval
}

func (s *GateReconciler) ListGates(ctx context.Context) *algorithms.Pager[*console.PipelineGateEdgeFragment] {
func (s *GateReconciler) ListGates(ctx context.Context) *algorithms.Pager[*console.PipelineGateIDsEdgeFragment] {
logger := log.FromContext(ctx)
logger.Info("create pipeline gate pager")
fetch := func(page *string, size int64) ([]*console.PipelineGateEdgeFragment, *algorithms.PageInfo, error) {
fetch := func(page *string, size int64) ([]*console.PipelineGateIDsEdgeFragment, *algorithms.PageInfo, error) {
resp, err := s.consoleClient.GetClusterGates(page, &size)
if err != nil {
logger.Error(err, "failed to fetch gates")
Expand All @@ -101,7 +101,7 @@ func (s *GateReconciler) ListGates(ctx context.Context) *algorithms.Pager[*conso
}
return resp.PagedClusterGates.Edges, pageInfo, nil
}
return algorithms.NewPager[*console.PipelineGateEdgeFragment](common.DefaultPageSize, fetch)
return algorithms.NewPager[*console.PipelineGateIDsEdgeFragment](common.DefaultPageSize, fetch)
}

func (s *GateReconciler) Poll(ctx context.Context) error {
Expand Down
14 changes: 7 additions & 7 deletions pkg/test/mocks/Client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dabab73

Please sign in to comment.