Last active
August 23, 2022 20:06
-
-
Save sdboyer/4f79e228fd5c1e9924b970c8ba60510b to your computer and use it in GitHub Desktop.
Codegen output when prometheus gets a models.cue
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
package grafanaplugin | |
import "github.com/grafana/thema" | |
// Note - all fields in here SHOULD be well-commented. | |
Query: thema.#Lineage & { | |
name: "prometheus" | |
seqs: [ | |
{ | |
schemas: [ | |
{// 0.0 | |
expr: string | |
legendFormat: string | |
interval: string | |
intervalMS: int64 | |
stepMode: string | |
range: bool | *true | |
instant: !range | |
exemplar: bool | *false | |
intervalFactor: int64 | |
utcOffsetSec: int64 | |
}, | |
] | |
}, | |
] | |
} | |
DSOptions: thema.#Lineage & { | |
name: "prometheus" | |
seqs: [ | |
{ | |
schemas: [ | |
{// 0.0 | |
Options: { | |
timeInterval: string | *"15s" | |
httpMethod: "GET" | *"POST" | |
queryTimeout?: string | |
directUrl?: string | |
customQueryParameters?: string | |
disableMetricsLookup?: bool | |
} | |
SecureOptions: { | |
basicAuthUser?: string | |
basicAuthPassword?: string | |
} | |
}, | |
] | |
}, | |
] | |
} | |
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 is autogenerated. DO NOT EDIT. | |
// | |
// Generated by public/app/plugins/gen.go | |
// | |
// Derived from the Thema lineage declared in models.cue | |
// | |
// Run `make gen-cue` from repository root to regenerate. | |
export const DSOptionsModelVersion = Object.freeze([0, 0]); | |
export const QueryModelVersion = Object.freeze([0, 0]); | |
&{export interface Prometheus { | |
exemplar: boolean; | |
expr: string; | |
instant: false; | |
interval: string; | |
intervalFactor: number; | |
intervalMS: number; | |
legendFormat: string; | |
range: boolean; | |
stepMode: string; | |
utcOffsetSec: number; | |
} export const defaultPrometheus: Partial<Prometheus> = { | |
exemplar: false, | |
range: true, | |
};} |
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
// Copyright 2022 Grafana Labs | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
// This file is autogenerated. DO NOT EDIT. | |
// | |
// Generated by public/app/plugins/gen.go | |
// | |
// Run `make gen-cue` from repository root to regenerate. | |
package prometheus | |
import ( | |
"embed" | |
"fmt" | |
"sync" | |
"github.com/grafana/grafana/pkg/cuectx" | |
"github.com/grafana/grafana/pkg/plugins/pfs" | |
"github.com/grafana/thema" | |
) | |
var parseOnce sync.Once | |
var ptree *pfs.Tree | |
//go:embed plugin.json models.cue | |
var plugFS embed.FS | |
// PluginTree returns the plugin tree representing the statically analyzable contents of the prometheus plugin. | |
func PluginTree(lib *thema.Library) *pfs.Tree { | |
var err error | |
if lib == nil { | |
parseOnce.Do(func() { | |
ptree, err = pfs.ParsePluginFS(plugFS, cuectx.ProvideThemaLibrary()) | |
}) | |
} else { | |
ptree, err = pfs.ParsePluginFS(plugFS, cuectx.ProvideThemaLibrary()) | |
} | |
if err != nil { | |
// Even the most rudimentary testing in CI ensures this is unreachable | |
panic(fmt.Errorf("error parsing plugin fs tree: %w", err)) | |
} | |
return ptree | |
} | |
// DSOptionsLineage returns the Thema lineage for the prometheus datasource plugin's | |
// DSOptions ["github.com/grafana/grafana/pkg/framework/coremodel".Slot] implementation. | |
func DSOptionsLineage(lib *thema.Library, opts ...thema.BindOption) (thema.Lineage, error) { | |
t := PluginTree(lib) | |
lin, has := t.RootPlugin().SlotImplementations()["DSOptions"] | |
if !has { | |
panic("unreachable: lineage for DSOptions does not exist, but code is only generated for existing lineages") | |
} | |
return lin, nil | |
} | |
// The current schema version of the DSOptions slot implementation. | |
// | |
// Code generation ensures that this is always the version number for the latest schema | |
// in the DSOptions Thema lineage. | |
var currentVersionDSOptions = thema.SV(0, 0) | |
// QueryLineage returns the Thema lineage for the prometheus datasource plugin's | |
// Query ["github.com/grafana/grafana/pkg/framework/coremodel".Slot] implementation. | |
func QueryLineage(lib *thema.Library, opts ...thema.BindOption) (thema.Lineage, error) { | |
t := PluginTree(lib) | |
lin, has := t.RootPlugin().SlotImplementations()["Query"] | |
if !has { | |
panic("unreachable: lineage for Query does not exist, but code is only generated for existing lineages") | |
} | |
return lin, nil | |
} | |
// The current schema version of the Query slot implementation. | |
// | |
// Code generation ensures that this is always the version number for the latest schema | |
// in the Query Thema lineage. | |
var currentVersionQuery = thema.SV(0, 0) |
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
// Copyright 2022 Grafana Labs | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
// This file is autogenerated. DO NOT EDIT. | |
// | |
// Generated by public/app/plugins/gen.go | |
// | |
// Derived from the Thema lineage declared in models.cue at CUE path "DSOptions" | |
// | |
// Run `make gen-cue` from repository root to regenerate. | |
package prometheus |
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
// Copyright 2022 Grafana Labs | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
// This file is autogenerated. DO NOT EDIT. | |
// | |
// Generated by public/app/plugins/gen.go | |
// | |
// Derived from the Thema lineage declared in models.cue at CUE path "Query" | |
// | |
// Run `make gen-cue` from repository root to regenerate. | |
package prometheus | |
// Defines values for Instant. | |
const ( | |
InstantFalse Instant = false | |
) | |
// Query is the Go representation of a prometheus. | |
// | |
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. | |
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. | |
type Query struct { | |
Exemplar bool `json:"exemplar"` | |
Expr string `json:"expr"` | |
Instant Instant `json:"instant"` | |
Interval string `json:"interval"` | |
IntervalFactor int64 `json:"intervalFactor"` | |
IntervalMS int64 `json:"intervalMS"` | |
LegendFormat string `json:"legendFormat"` | |
Range bool `json:"range"` | |
StepMode string `json:"stepMode"` | |
UtcOffsetSec int64 `json:"utcOffsetSec"` | |
} | |
// Instant is the Go representation of a Query.Instant. | |
// | |
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. | |
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. | |
type Instant bool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment