Skip to content
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

[perf] - Leverage pgzip for Parallel decompression #3149

Merged
merged 14 commits into from
Aug 2, 2024
Prev Previous commit
Next Next commit
Export maps from permission generation (#3137)
* Adjust permission generation to make maps exportable

* fix bug and add twilio
  • Loading branch information
hxnyk authored and ahrav committed Aug 1, 2024
commit 6b6596ebac450198f69e028cbf3bcdb88e33aacf
16 changes: 8 additions & 8 deletions pkg/analyzer/analyzers/github/classic/classic_permissions.go

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

2 changes: 1 addition & 1 deletion pkg/analyzer/analyzers/github/classic/classictoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func hasPrivateRepoAccess(scopes map[Permission]bool) bool {
func processScopes(headerScopesSlice []analyzers.Permission) map[Permission]bool {
allScopes := make(map[Permission]bool)
for _, scope := range headerScopesSlice {
allScopes[stringToPermission[scope.Value]] = true
allScopes[StringToPermission[scope.Value]] = true
}
for scope := range allScopes {
if subScopes, ok := SCOPE_TO_SUB_SCOPE[scope]; ok {
Expand Down

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

16 changes: 8 additions & 8 deletions pkg/analyzer/analyzers/openai/permissions.go

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

16 changes: 8 additions & 8 deletions pkg/analyzer/analyzers/twilio/permissions.go

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

16 changes: 8 additions & 8 deletions pkg/analyzer/generate_permissions/generate_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ const (
)

var (
permissionStrings = map[Permission]string{
PermissionStrings = map[Permission]string{
{{- range $index, $permission := .Permissions }}
{{ ToCamelCase $permission }}: "{{ $permission }}",
{{- end }}
}

stringToPermission = map[string]Permission{
StringToPermission = map[string]Permission{
{{- range $index, $permission := .Permissions }}
"{{ $permission }}": {{ ToCamelCase $permission }},
{{- end }}
}

permissionIDs = map[Permission]int{
PermissionIDs = map[Permission]int{
{{- range $index, $permission := .Permissions }}
{{ ToCamelCase $permission }}: {{ $index }},
{{- end }}
}

idToPermission = map[int]Permission{
IdToPermission = map[int]Permission{
{{- range $index, $permission := .Permissions }}
{{ $index }}: {{ ToCamelCase $permission }},
{{- end }}
Expand All @@ -59,31 +59,31 @@ var (

// ToString converts a Permission enum to its string representation
func (p Permission) ToString() (string, error) {
if str, ok := permissionStrings[p]; ok {
if str, ok := PermissionStrings[p]; ok {
return str, nil
}
return "", errors.New("invalid permission")
}

// ToID converts a Permission enum to its ID
func (p Permission) ToID() (int, error) {
if id, ok := permissionIDs[p]; ok {
if id, ok := PermissionIDs[p]; ok {
return id, nil
}
return 0, errors.New("invalid permission")
}

// PermissionFromString converts a string representation to its Permission enum
func PermissionFromString(s string) (Permission, error) {
if p, ok := stringToPermission[s]; ok {
if p, ok := StringToPermission[s]; ok {
return p, nil
}
return 0, errors.New("invalid permission string")
}

// PermissionFromID converts an ID to its Permission enum
func PermissionFromID(id int) (Permission, error) {
if p, ok := idToPermission[id]; ok {
if p, ok := IdToPermission[id]; ok {
return p, nil
}
return 0, errors.New("invalid permission ID")
Expand Down