-
Notifications
You must be signed in to change notification settings - Fork 2
baton-github: add DefaultCapabilitiesBuilder #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,6 @@ import ( | |
| "github.com/conductorone/baton-sdk/pkg/types/entitlement" | ||
| "github.com/conductorone/baton-sdk/pkg/types/grant" | ||
| resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource" | ||
| "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -37,23 +35,13 @@ func (l *licenseResourceType) List( | |
| parentID *v2.ResourceId, | ||
| opts resourceSdk.SyncOpAttrs, | ||
| ) ([]*v2.Resource, *resourceSdk.SyncOpResults, error) { | ||
| logger := ctxzap.Extract(ctx) | ||
|
|
||
| var ret []*v2.Resource | ||
| for _, enterprise := range l.enterprises { | ||
| // total_seats_purchased and total_seats_consumed are enterprise-wide | ||
| // aggregates that the API returns identically on every page, so the | ||
| // first page is enough. | ||
| consumedLicenses, _, err := l.customClient.ListEnterpriseConsumedLicenses(ctx, enterprise, 1) | ||
| if err != nil { | ||
| if isPermissionDenied(err) { | ||
| logger.Debug("baton-github: enterprise features (--enterprises) require a Personal Access Token. "+ | ||
| "GitHub App authentication cannot access the consumed-licenses API. "+ | ||
| "Either switch to PAT auth or remove the --enterprises flag.", | ||
| zap.String("enterprise", enterprise), | ||
| zap.Error(err)) | ||
| continue | ||
| } | ||
| return nil, nil, fmt.Errorf("baton-github: error listing enterprise consumed licenses for %s: %w", enterprise, err) | ||
|
Comment on lines
44
to
45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: The removed |
||
| } | ||
|
|
||
|
|
@@ -162,7 +150,7 @@ func licenseResource(enterprise string, purchasedSeats, consumedSeats int64, ent | |
| ) | ||
| } | ||
|
|
||
| func licenseBuilder( | ||
| func LicenseBuilder( | ||
| customClient *customclient.Client, | ||
| enterprises []string, | ||
| ) *licenseResourceType { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,7 +418,7 @@ func (o *orgResourceType) Revoke(ctx context.Context, grant *v2.Grant) (annotati | |
| return nil, nil | ||
| } | ||
|
|
||
| func orgBuilder(client, appClient *github.Client, orgCache *orgNameCache, orgs []string, syncSecrets bool) *orgResourceType { | ||
| func OrgBuilder(client, appClient *github.Client, orgCache *orgNameCache, orgs []string, syncSecrets bool) *orgResourceType { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: All exported builder functions (e.g. |
||
| orgMap := make(map[string]struct{}) | ||
|
|
||
| for _, o := range orgs { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion:
InvitationBuilderParamsis now exported, but all its fields (client,orgCache,orgs) are still unexported. External packages can reference the type but cannot construct a usable value. Either export the fields or keep the struct unexported.