Skip to content

Commit

Permalink
Merge pull request #18 from ConductorOne/ggreer/pagesize
Browse files Browse the repository at this point in the history
Use a pagesize variable. Clean up CI.
  • Loading branch information
ggreer authored Aug 20, 2024
2 parents 02a825a + 31bfa1e commit fdd5123
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,8 @@ jobs:

test:
runs-on: ubuntu-latest
# Define any services needed for the test suite (or delete this section)
# services:
# postgres:
# image: postgres:16
# ports:
# - "5432:5432"
# env:
# POSTGRES_PASSWORD: secretpassword
env:
BATON_LOG_LEVEL: debug
# Add any environment variables needed to run baton-formal
# BATON_BASE_URL: 'http://localhost:8080'
# BATON_ACCESS_TOKEN: 'secret_token'
# The following parameters are passed to grant/revoke commands
# Change these to the correct IDs for your test data
BATON_FORMAL_API_KEY: ${{ secrets.BATON_FORMAL_API_KEY }}
CONNECTOR_GRANT: 'group:group_01hwv4ketae9vsa36rafvkn8mr:member:user:user_01hw3ydazpetds0xzgayvpc2vw'
CONNECTOR_ENTITLEMENT: 'group:group_01hwv4ketae9vsa36rafvkn8mr:member'
Expand All @@ -66,14 +53,6 @@ jobs:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
# Install any dependencies here (or delete this)
# - name: Install postgres client
# run: sudo apt install postgresql-client
# Run any fixture setup here (or delete this)
# - name: Import sql into postgres
# run: psql -h localhost --user postgres -f environment.sql
# env:
# PGPASSWORD: secretpassword
- name: Build baton-formal
run: go build ./cmd/baton-formal
- name: Run baton-formal
Expand All @@ -83,11 +62,9 @@ jobs:
run: ./scripts/get-baton.sh && mv baton /usr/local/bin

- name: Check for grant before revoking

run:
baton grants --entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --output-format=json | jq --exit-status ".grants[].principal.id.resource == \"${{ env.CONNECTOR_PRINCIPAL }}\""


- name: Revoke grants
run: ./baton-formal --revoke-grant="${{ env.CONNECTOR_GRANT }}"

Expand Down
8 changes: 5 additions & 3 deletions pkg/connector/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"go.uber.org/zap"
)

const PageSize = 100

type groupBuilder struct {
client *sdk.FormalSDK
}
Expand All @@ -27,7 +29,7 @@ func (o *groupBuilder) ResourceType(ctx context.Context) *v2.ResourceType {

func (o *groupBuilder) List(ctx context.Context, parentResourceID *v2.ResourceId, pToken *pagination.Token) ([]*v2.Resource, string, annotations.Annotations, error) {
request := connect.NewRequest(&corev1.ListGroupsRequest{
Limit: 100,
Limit: PageSize,
Cursor: pToken.Token,
})

Expand Down Expand Up @@ -72,7 +74,7 @@ func (o *groupBuilder) Entitlements(_ context.Context, resource *v2.Resource, _
func (o *groupBuilder) Grants(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Grant, string, annotations.Annotations, error) {
request := connect.NewRequest(&corev1.ListUserGroupLinksRequest{
GroupId: resource.Id.Resource,
Limit: 100,
Limit: PageSize,
Cursor: pToken.Token,
})

Expand Down Expand Up @@ -166,7 +168,7 @@ func (o *groupBuilder) Revoke(ctx context.Context, grant *v2.Grant) (annotations
for {
request := connect.NewRequest(&corev1.ListUserGroupLinksRequest{
GroupId: grant.Entitlement.Resource.Id.Resource,
Limit: 100,
Limit: PageSize,
Cursor: npt,
})

Expand Down

0 comments on commit fdd5123

Please sign in to comment.