Skip to content

Commit

Permalink
query types
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu committed Mar 4, 2024
1 parent 4bd5fed commit b2d12c6
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 242 deletions.
12 changes: 10 additions & 2 deletions cspell.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"ignorePaths": ["node_modules/**", "dist/**", "mage_output_file.go"],
"ignoreRegExpList": ["import\\s*\\((.|[\r\n])*?\\)", "import\\s*.*\".*?\""],
"ignorePaths": [
"node_modules/**",
"dist/**",
"mage_output_file.go"
],
"ignoreRegExpList": [
"import\\s*\\((.|[\r\n])*?\\)",
"import\\s*.*\".*?\""
],
"words": [
"araddon",
"bmike",
Expand Down Expand Up @@ -32,6 +39,7 @@
"querytype",
"rgba",
"RUBYGEMS",
"sdkapi",
"shurcoo",
"stretchr",
"structs",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.3
require (
github.com/google/go-github/v53 v53.2.0
github.com/gorilla/mux v1.8.0
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240226055837-a09ab1213090
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240304051234-e7e1b68a000e
github.com/influxdata/tdigest v0.0.1
github.com/pkg/errors v0.9.1
github.com/shurcooL/githubv4 v0.0.0-20230305132112-efb623903184
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240226055837-a09ab1213090 h1:RSww9F4f+6nlL8beulC8rDHpytBGRBOtElC7QXOMWj4=
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240226055837-a09ab1213090/go.mod h1:moBIj6os2JtvWTMJb+e8RETljegmtxEubOJhXbqdCdY=
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240304051234-e7e1b68a000e h1:qT6DQJS52SMAqgXBPxfTbzzC4EUq+rZOu/7iCwyggtQ=
github.com/grafana/grafana-plugin-sdk-go v0.212.1-0.20240304051234-e7e1b68a000e/go.mod h1:l+qrlSQC34H5CF2XGKRlRpTRHp+hMWFzgw15u7ItKk0=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
Expand Down
116 changes: 58 additions & 58 deletions pkg/models/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"reflect"
"testing"

"github.com/grafana/grafana-plugin-sdk-go/experimental/resource"
"github.com/grafana/grafana-plugin-sdk-go/experimental/resource/schemabuilder"
"github.com/grafana/grafana-plugin-sdk-go/experimental/schemabuilder"
sdkapi "github.com/grafana/grafana-plugin-sdk-go/v0alpha1"
"github.com/shurcooL/githubv4"
"github.com/stretchr/testify/require"
)
Expand All @@ -29,96 +29,96 @@ func TestSchemaDefinitions(t *testing.T) {
require.NoError(t, err)
err = builder.AddQueries(schemabuilder.QueryTypeInfo{
GoType: reflect.TypeOf(&PullRequestsQuery{}),
Discriminators: resource.NewDiscriminators("queryType", QueryTypePullRequests),
Examples: []resource.QueryExample{
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypePullRequests),
Examples: []sdkapi.QueryExample{
{
Name: "Simple",
SaveModel: PullRequestsQuery{
SaveModel: sdkapi.AsUnstructured(PullRequestsQuery{
Query: common,
Options: ListPullRequestsOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeCommits),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeCommits),
GoType: reflect.TypeOf(&CommitsQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "CommitsQuery",
SaveModel: CommitsQuery{
SaveModel: sdkapi.AsUnstructured(CommitsQuery{
Query: common,
Options: ListCommitsOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeTags),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeTags),
GoType: reflect.TypeOf(&TagsQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "TagsQuery",
SaveModel: TagsQuery{
SaveModel: sdkapi.AsUnstructured(TagsQuery{
Query: common,
Options: ListTagsOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeLabels),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeLabels),
GoType: reflect.TypeOf(&LabelsQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "LabelsQuery",
SaveModel: LabelsQuery{
SaveModel: sdkapi.AsUnstructured(LabelsQuery{
Query: common,
Options: ListLabelsOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeReleases),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeReleases),
GoType: reflect.TypeOf(&ReleasesQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "ReleasesQuery",
SaveModel: ReleasesQuery{
SaveModel: sdkapi.AsUnstructured(ReleasesQuery{
Query: common,
Options: ListReleasesOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeContributors),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeContributors),
GoType: reflect.TypeOf(&ContributorsQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "ContributorsQuery",
SaveModel: ContributorsQuery{
SaveModel: sdkapi.AsUnstructured(ContributorsQuery{
Query: common,
Options: ListContributorsOptions{Owner: "yesoreyeram"},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeRepositories),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeRepositories),
GoType: reflect.TypeOf(&RepositoriesQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "RepositoriesQuery",
SaveModel: RepositoriesQuery{
SaveModel: sdkapi.AsUnstructured(RepositoriesQuery{
Query: Query{
Owner: "yesoreyeram",
},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeIssues),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeIssues),
GoType: reflect.TypeOf(&IssuesQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "IssuesQuery",
SaveModel: IssuesQuery{
SaveModel: sdkapi.AsUnstructured(IssuesQuery{
Query: common,
Options: ListIssuesOptions{
Filters: &githubv4.IssueFilters{
Expand All @@ -127,78 +127,78 @@ func TestSchemaDefinitions(t *testing.T) {
},
},
},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypePackages),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypePackages),
GoType: reflect.TypeOf(&PackagesQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "PackagesQuery",
SaveModel: PackagesQuery{
SaveModel: sdkapi.AsUnstructured(PackagesQuery{
Query: common,
Options: ListPackagesOptions{
PackageType: githubv4.PackageTypeDocker,
},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeMilestones),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeMilestones),
GoType: reflect.TypeOf(&MilestonesQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "MilestonesQuery",
SaveModel: MilestonesQuery{
SaveModel: sdkapi.AsUnstructured(MilestonesQuery{
Query: common,
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeVulnerabilities),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeVulnerabilities),
GoType: reflect.TypeOf(&VulnerabilityQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "VulnerabilityQuery",
SaveModel: VulnerabilityQuery{
SaveModel: sdkapi.AsUnstructured(VulnerabilityQuery{
Query: common,
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeStargazers),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeStargazers),
GoType: reflect.TypeOf(&StargazersQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "StargazersQuery",
SaveModel: StargazersQuery{
SaveModel: sdkapi.AsUnstructured(StargazersQuery{
Query: common,
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeWorkflows),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeWorkflows),
GoType: reflect.TypeOf(&WorkflowsQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "WorkflowsQuery",
SaveModel: WorkflowsQuery{
SaveModel: sdkapi.AsUnstructured(WorkflowsQuery{
Query: common,
Options: ListWorkflowsOptions{},
},
}),
},
},
}, schemabuilder.QueryTypeInfo{
Discriminators: resource.NewDiscriminators("queryType", QueryTypeWorkflowUsage),
Discriminators: sdkapi.NewDiscriminators("queryType", QueryTypeWorkflowUsage),
GoType: reflect.TypeOf(&WorkflowUsageQuery{}),
Examples: []resource.QueryExample{
Examples: []sdkapi.QueryExample{
{
Name: "WorkflowUsageQuery",
SaveModel: WorkflowUsageQuery{
SaveModel: sdkapi.AsUnstructured(WorkflowUsageQuery{
Query: common,
Options: WorkflowUsageOptions{},
},
}),
},
},
},
Expand Down
Loading

0 comments on commit b2d12c6

Please sign in to comment.