-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: improve platform validation (#420)
- Loading branch information
Showing
7 changed files
with
163 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
curl -sSfL https://raw.githubusercontent.com/getsentry/sentry/master/src/sentry/models/project.py \ | ||
| awk '/GETTING_STARTED_DOCS_PLATFORMS = \[/ { platforms = 1; next } /\]/ { platforms = 0 } platforms { gsub(/[ ",]/, ""); print }' \ | ||
> platforms.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
android | ||
apple | ||
apple-ios | ||
apple-macos | ||
bun | ||
capacitor | ||
cordova | ||
dart | ||
deno | ||
dotnet | ||
dotnet-aspnet | ||
dotnet-aspnetcore | ||
dotnet-awslambda | ||
dotnet-gcpfunctions | ||
dotnet-maui | ||
dotnet-uwp | ||
dotnet-winforms | ||
dotnet-wpf | ||
dotnet-xamarin | ||
electron | ||
elixir | ||
flutter | ||
go | ||
go-echo | ||
go-fasthttp | ||
go-gin | ||
go-http | ||
go-iris | ||
go-martini | ||
go-negroni | ||
ionic | ||
java | ||
java-log4j2 | ||
java-logback | ||
java-spring | ||
java-spring-boot | ||
javascript | ||
javascript-angular | ||
javascript-astro | ||
javascript-ember | ||
javascript-gatsby | ||
javascript-nextjs | ||
javascript-react | ||
javascript-remix | ||
javascript-svelte | ||
javascript-sveltekit | ||
javascript-vue | ||
kotlin | ||
minidump | ||
native | ||
native-qt | ||
nintendo-switch | ||
node | ||
node-awslambda | ||
node-azurefunctions | ||
node-connect | ||
node-express | ||
node-fastify | ||
node-gcpfunctions | ||
node-hapi | ||
node-koa | ||
node-nestjs | ||
node-serverlesscloud | ||
php | ||
php-laravel | ||
php-symfony | ||
powershell | ||
python | ||
python-aiohttp | ||
python-asgi | ||
python-awslambda | ||
python-bottle | ||
python-celery | ||
python-chalice | ||
python-django | ||
python-falcon | ||
python-fastapi | ||
python-flask | ||
python-gcpfunctions | ||
python-pylons | ||
python-pymongo | ||
python-pyramid | ||
python-quart | ||
python-rq | ||
python-sanic | ||
python-serverless | ||
python-starlette | ||
python-tornado | ||
python-tryton | ||
python-wsgi | ||
react-native | ||
ruby | ||
ruby-rack | ||
ruby-rails | ||
rust | ||
unity | ||
unreal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sentryplatforms | ||
|
||
import ( | ||
_ "embed" | ||
"strings" | ||
) | ||
|
||
//go:generate bash ./generate.sh | ||
|
||
//go:embed platforms.txt | ||
var rawPlatforms string | ||
var platforms = strings.Split(strings.TrimSpace(rawPlatforms), "\n") | ||
|
||
// Validate checks if a platform is valid from the list loaded from platforms.txt. | ||
func Validate(platform string) bool { | ||
// "other" is a special case that is always valid | ||
if platform == "other" { | ||
return true | ||
} | ||
|
||
for _, p := range platforms { | ||
if p == platform { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package sentryplatforms | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestValidate(t *testing.T) { | ||
testCases := []struct { | ||
platform string | ||
want bool | ||
}{ | ||
{"android", true}, | ||
{"python", true}, | ||
{"javascript", true}, | ||
{"other", true}, | ||
{"bogus", false}, | ||
} | ||
for _, tc := range testCases { | ||
t.Run(fmt.Sprintf("platform=%s", tc.platform), func(t *testing.T) { | ||
got := Validate(tc.platform) | ||
if got != tc.want { | ||
t.Errorf("got %v; want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters