Skip to content

baton-github: add DefaultCapabilitiesBuilder#168

Merged
Bencheng21 merged 5 commits into
mainfrom
ben/default_capabilities
May 28, 2026
Merged

baton-github: add DefaultCapabilitiesBuilder#168
Bencheng21 merged 5 commits into
mainfrom
ben/default_capabilities

Conversation

@Bencheng21
Copy link
Copy Markdown
Contributor

No description provided.

@Bencheng21 Bencheng21 requested a review from a team May 28, 2026 19:13
Comment thread pkg/connector/connector.go Outdated

// DefaultCapabilitiesBuilder returns all resource types unconditionally so that
// the generated capabilities are always complete regardless of connector configuration.
func DefaultCapabilitiesBuilder() connectorbuilder.ConnectorBuilderV2 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to use it in baton-github-enterprise.

@Bencheng21 Bencheng21 force-pushed the ben/default_capabilities branch from fe28f11 to 4dec331 Compare May 28, 2026 19:41
Comment on lines +523 to 527
type InvitationBuilderParams struct {
client *github.Client
orgCache *orgNameCache
orgs []string
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: InvitationBuilderParams is 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.

Comment thread pkg/connector/org.go
}

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: All exported builder functions (e.g. OrgBuilder, TeamBuilder, UserBuilder, etc.) accept the unexported *orgNameCache parameter, and return unexported concrete types (e.g. *orgResourceType). External callers cannot construct orgNameCache (constructor newOrgNameCache is also unexported) and cannot name the return type. If these are meant to be usable outside the package, the shared dependencies and return types (or their constructors) need to be exported too. If they're only meant for internal use, consider keeping them unexported.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Connector PR Review: baton-github: add DefaultCapabilitiesBuilder

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Review mode: incremental since 1f85c53
View review run

Review Summary

The new commits remove redundant SkipEntitlementsAndGrants annotation logic from EnterpriseRoleBuilder and LicenseBuilder. This code was dead — connector.go already guards enterprise builder registration with len(gh.enterprises) > 0, so the len(enterprises) == 0 branch inside the builders could never execute. The cleanup and unused import removal are correct. No new issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Comment thread pkg/connector/license.go
Comment on lines 44 to 45
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: The removed isPermissionDenied guard provided graceful degradation for GitHub App auth users who configure --enterprises (the consumed-licenses API requires a PAT). Without it, the entire sync will now fail instead of skipping license data. Per R7, consider keeping the graceful degradation or gating this behind a config flag.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Comment thread pkg/connector/enterprise_role.go Outdated

func enterpriseRoleBuilder(client *github.Client, appClient *github.Client, customClient *customclient.Client, enterprises []string) *enterpriseRoleResourceType {
func EnterpriseRoleBuilder(client *github.Client, appClient *github.Client, customClient *customclient.Client, enterprises []string) *enterpriseRoleResourceType {
annos := annotations.Annotations(resourceTypeLicense.GetAnnotations())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Bug: Copy-paste error — this reads annotations from resourceTypeLicense instead of resourceTypeEnterpriseRole. This gives the enterprise role resource type a V1Identifier with Id: "license" instead of "enterprise_role".

Suggested change
annos := annotations.Annotations(resourceTypeLicense.GetAnnotations())
annos := annotations.Annotations(resourceTypeEnterpriseRole.GetAnnotations())

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issues found — see review comments.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Comment thread pkg/connector/license.go Outdated
Comment on lines +159 to +162
if len(enterprises) == 0 {
annos.Append(&v2.SkipEntitlementsAndGrants{})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I meant we should do this for users resource type. specifically if resource type license is not enabled

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@Bencheng21 Bencheng21 merged commit 8fd15da into main May 28, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants