Skip to content

Commit

Permalink
fix: unexport func
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Oct 29, 2024
1 parent 858da17 commit 249099d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions scm/github/app_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

const (
acceptHeader = "application/vnd.github.v3+json"
apiBaseURL = "https://api.github.com"
)

// AppsTransport provides a http.RoundTripper by wrapping an existing
Expand Down Expand Up @@ -58,12 +57,12 @@ func (c *client) newGitHubAppTransport(appID int64, privateKey, baseURL string)
return nil, fmt.Errorf("failed to parse PEM block containing the key")
}

_privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
parsedPrivateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
if err != nil {
return nil, fmt.Errorf("failed to parse RSA private key: %w", err)
}

transport := c.newAppsTransportFromPrivateKey(http.DefaultTransport, appID, _privateKey)
transport := c.newAppsTransportFromPrivateKey(http.DefaultTransport, appID, parsedPrivateKey)
transport.BaseURL = baseURL

// apply tracing to the transport
Expand All @@ -82,7 +81,7 @@ func (c *client) newGitHubAppTransport(appID int64, privateKey, baseURL string)
// newAppsTransportFromPrivateKey returns an AppsTransport using a crypto/rsa.(*PrivateKey).
func (c *client) newAppsTransportFromPrivateKey(tr http.RoundTripper, appID int64, key *rsa.PrivateKey) *AppsTransport {
return &AppsTransport{
BaseURL: apiBaseURL,
BaseURL: defaultAPI,
Client: &http.Client{Transport: tr},
tr: tr,
signer: NewRSASigner(jwt.SigningMethodRS256, key),
Expand Down
6 changes: 3 additions & 3 deletions scm/github/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func (c *client) GetNetrcPassword(ctx context.Context, r *api.Repo, u *api.User,
}

for resource, perm := range perms {
ghPerms, err = WithGitHubInstallationPermission(ghPerms, resource, perm)
ghPerms, err = applyGitHubInstallationPermission(ghPerms, resource, perm)
if err != nil {
l.Errorf("unable to create github app installation token with permission %s:%s: %v", resource, perm, err)

Expand Down Expand Up @@ -817,8 +817,8 @@ func (c *client) SyncRepoWithInstallation(ctx context.Context, r *api.Repo) (*ap
return r, nil
}

// WithGitHubInstallationPermission takes permissions and applies a new permission if valid.
func WithGitHubInstallationPermission(perms *github.InstallationPermissions, resource, perm string) (*github.InstallationPermissions, error) {
// applyGitHubInstallationPermission takes permissions and applies a new permission if valid.
func applyGitHubInstallationPermission(perms *github.InstallationPermissions, resource, perm string) (*github.InstallationPermissions, error) {
// convert permissions from yaml string
switch strings.ToLower(perm) {
case constants.AppInstallPermissionNone:
Expand Down

0 comments on commit 249099d

Please sign in to comment.