mirror of https://github.com/grafana/grafana
Kindsys: Target k8s style resource definitions (#67008)
Co-authored-by: sam boyer <sdboyer@grafana.com>pull/67329/head
parent
b71b778d0d
commit
ca1f79b9ba
@ -0,0 +1,118 @@ |
||||
package codegen |
||||
|
||||
import ( |
||||
"bytes" |
||||
"fmt" |
||||
"strings" |
||||
|
||||
"cuelang.org/go/cue" |
||||
"github.com/dave/dst/dstutil" |
||||
"github.com/grafana/codejen" |
||||
"github.com/grafana/kindsys" |
||||
"github.com/grafana/thema/encoding/gocode" |
||||
"github.com/grafana/thema/encoding/openapi" |
||||
) |
||||
|
||||
type ResourceGoTypesJenny struct { |
||||
ApplyFuncs []dstutil.ApplyFunc |
||||
ExpandReferences bool |
||||
} |
||||
|
||||
func (*ResourceGoTypesJenny) JennyName() string { |
||||
return "GoTypesJenny" |
||||
} |
||||
|
||||
func (ag *ResourceGoTypesJenny) Generate(kind kindsys.Kind) (*codejen.File, error) { |
||||
comm := kind.Props().Common() |
||||
sfg := SchemaForGen{ |
||||
Name: comm.Name, |
||||
Schema: kind.Lineage().Latest(), |
||||
IsGroup: comm.LineageIsGroup, |
||||
} |
||||
sch := sfg.Schema |
||||
|
||||
iter, err := sch.Underlying().Fields() |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
var subr []string |
||||
for iter.Next() { |
||||
subr = append(subr, typeNameFromKey(iter.Selector().String())) |
||||
} |
||||
|
||||
buf := new(bytes.Buffer) |
||||
mname := kind.Props().Common().MachineName |
||||
if err := tmpls.Lookup("core_resource.tmpl").Execute(buf, tvars_resource{ |
||||
PackageName: mname, |
||||
KindName: kind.Props().Common().Name, |
||||
SubresourceNames: subr, |
||||
}); err != nil { |
||||
return nil, fmt.Errorf("failed executing core resource template: %w", err) |
||||
} |
||||
|
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return codejen.NewFile(fmt.Sprintf("pkg/kinds/%s/%s_gen.go", mname, mname), buf.Bytes(), ag), nil |
||||
} |
||||
|
||||
type SubresourceGoTypesJenny struct { |
||||
ApplyFuncs []dstutil.ApplyFunc |
||||
ExpandReferences bool |
||||
} |
||||
|
||||
func (*SubresourceGoTypesJenny) JennyName() string { |
||||
return "GoResourceTypes" |
||||
} |
||||
|
||||
func (g *SubresourceGoTypesJenny) Generate(kind kindsys.Kind) (codejen.Files, error) { |
||||
comm := kind.Props().Common() |
||||
sfg := SchemaForGen{ |
||||
Name: comm.Name, |
||||
Schema: kind.Lineage().Latest(), |
||||
IsGroup: comm.LineageIsGroup, |
||||
} |
||||
sch := sfg.Schema |
||||
|
||||
// Iterate through all top-level fields and make go types for them
|
||||
// (this should consist of "spec" and arbitrary subresources)
|
||||
i, err := sch.Underlying().Fields() |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
files := make(codejen.Files, 0) |
||||
for i.Next() { |
||||
str := i.Selector().String() |
||||
|
||||
b, err := gocode.GenerateTypesOpenAPI(sch, &gocode.TypeConfigOpenAPI{ |
||||
// TODO will need to account for sanitizing e.g. dashes here at some point
|
||||
Config: &openapi.Config{ |
||||
Group: false, // TODO: better
|
||||
RootName: typeNameFromKey(str), |
||||
Subpath: cue.MakePath(cue.Str(str)), |
||||
}, |
||||
PackageName: sfg.Schema.Lineage().Name(), |
||||
ApplyFuncs: append(g.ApplyFuncs, PrefixDropper(sfg.Name)), |
||||
}) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
name := sfg.Schema.Lineage().Name() |
||||
files = append(files, codejen.File{ |
||||
RelativePath: fmt.Sprintf("pkg/kinds/%s/%s_%s_gen.go", name, name, strings.ToLower(str)), |
||||
Data: b, |
||||
From: []codejen.NamedJenny{g}, |
||||
}) |
||||
} |
||||
|
||||
return files, nil |
||||
} |
||||
|
||||
func typeNameFromKey(key string) string { |
||||
if len(key) > 0 { |
||||
return strings.ToUpper(key[:1]) + key[1:] |
||||
} |
||||
return strings.ToUpper(key) |
||||
} |
||||
@ -0,0 +1,79 @@ |
||||
package codegen |
||||
|
||||
import ( |
||||
"github.com/grafana/codejen" |
||||
"github.com/grafana/cuetsy/ts" |
||||
"github.com/grafana/cuetsy/ts/ast" |
||||
"github.com/grafana/thema/encoding/typescript" |
||||
) |
||||
|
||||
// TSResourceJenny is a [OneToOne] that produces TypeScript types and
|
||||
// defaults for a Thema schema.
|
||||
//
|
||||
// Thema's generic TS jenny will be able to replace this one once
|
||||
// https://github.com/grafana/thema/issues/89 is complete.
|
||||
type TSResourceJenny struct{} |
||||
|
||||
var _ codejen.OneToOne[SchemaForGen] = &TSResourceJenny{} |
||||
|
||||
func (j TSResourceJenny) JennyName() string { |
||||
return "TSResourceJenny" |
||||
} |
||||
|
||||
func (j TSResourceJenny) Generate(sfg SchemaForGen) (*codejen.File, error) { |
||||
// TODO allow using name instead of machine name in thema generator
|
||||
f, err := typescript.GenerateTypes(sfg.Schema, &typescript.TypeConfig{ |
||||
RootName: sfg.Name, |
||||
Group: sfg.IsGroup, |
||||
}) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
renameSpecNode(sfg.Name, f) |
||||
|
||||
return codejen.NewFile(sfg.Schema.Lineage().Name()+"_types.gen.ts", []byte(f.String()), j), nil |
||||
} |
||||
|
||||
func renameSpecNode(name string, tf *ast.File) { |
||||
specidx, specdefidx := -1, -1 |
||||
for idx, def := range tf.Nodes { |
||||
// Peer through export keywords
|
||||
if ex, is := def.(ast.ExportKeyword); is { |
||||
def = ex.Decl |
||||
} |
||||
|
||||
switch x := def.(type) { |
||||
case ast.TypeDecl: |
||||
if x.Name.Name == "spec" { |
||||
specidx = idx |
||||
x.Name.Name = name |
||||
tf.Nodes[idx] = x |
||||
} |
||||
case ast.VarDecl: |
||||
// Before:
|
||||
// export const defaultspec: Partial<spec> = {
|
||||
// After:
|
||||
/// export const defaultPlaylist: Partial<Playlist> = {
|
||||
if x.Names.Idents[0].Name == "defaultspec" { |
||||
specdefidx = idx |
||||
x.Names.Idents[0].Name = "default" + name |
||||
tt := x.Type.(ast.TypeTransformExpr) |
||||
tt.Expr = ts.Ident(name) |
||||
x.Type = tt |
||||
tf.Nodes[idx] = x |
||||
} |
||||
} |
||||
} |
||||
|
||||
if specidx != -1 { |
||||
decl := tf.Nodes[specidx] |
||||
tf.Nodes = append(append(tf.Nodes[:specidx], tf.Nodes[specidx+1:]...), decl) |
||||
} |
||||
if specdefidx != -1 { |
||||
if specdefidx > specidx { |
||||
specdefidx-- |
||||
} |
||||
decl := tf.Nodes[specdefidx] |
||||
tf.Nodes = append(append(tf.Nodes[:specdefidx], tf.Nodes[specdefidx+1:]...), decl) |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@ |
||||
package {{ .PackageName }} |
||||
|
||||
// Resource is the wire representation of {{ .KindName }}. (TODO be better) |
||||
type Resource struct { |
||||
{{- range .SubresourceNames }} |
||||
{{ . }} {{ . }} `json:"{{ . | ToLower }}"`{{end}} |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package dashboard |
||||
|
||||
// Resource is the wire representation of Dashboard. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package dashboard |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package dashboard |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -1,89 +0,0 @@ |
||||
package dashboard_test |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
"io/fs" |
||||
"os" |
||||
"path/filepath" |
||||
"strings" |
||||
"testing" |
||||
|
||||
"cuelang.org/go/cue/errors" |
||||
"github.com/grafana/grafana/pkg/cuectx" |
||||
"github.com/grafana/grafana/pkg/kinds/dashboard" |
||||
"github.com/stretchr/testify/require" |
||||
) |
||||
|
||||
func TestDevenvDashboardValidity(t *testing.T) { |
||||
path, err := filepath.Abs("../../../devenv/dev-dashboards") |
||||
require.NoError(t, err) |
||||
|
||||
m, err := themaTestableDashboards(os.DirFS(path)) |
||||
require.NoError(t, err) |
||||
dk, err := dashboard.NewKind(cuectx.GrafanaThemaRuntime()) |
||||
require.NoError(t, err) |
||||
|
||||
for path, b := range m { |
||||
t.Run(path, func(t *testing.T) { |
||||
// The path arg here only matters for error output
|
||||
cv, err := cuectx.JSONtoCUE(path, b) |
||||
require.NoError(t, err, "error while decoding dashboard JSON into a CUE value") |
||||
|
||||
_, err = dk.ConvergentLineage().TypedSchema().Validate(cv) |
||||
if err != nil { |
||||
// Testify trims errors to short length. We want the full text
|
||||
errstr := errors.Details(err, nil) |
||||
t.Log(errstr) |
||||
if strings.Contains(errstr, "null") { |
||||
t.Log("validation failure appears to involve nulls - see if scripts/stripnulls.sh has any effect?") |
||||
} |
||||
t.FailNow() |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
func themaTestableDashboards(in fs.FS) (map[string][]byte, error) { |
||||
m := make(map[string][]byte) |
||||
|
||||
err := fs.WalkDir(in, ".", func(path string, d fs.DirEntry, err error) error { |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
if d.IsDir() || filepath.Ext(d.Name()) != ".json" { |
||||
return nil |
||||
} |
||||
|
||||
// nolint:gosec
|
||||
f, err := in.Open(path) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
defer f.Close() //nolint:errcheck
|
||||
|
||||
b, err := io.ReadAll(f) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
jtree := make(map[string]interface{}) |
||||
err = json.Unmarshal(b, &jtree) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if oldschemav, has := jtree["schemaVersion"]; !has || !(oldschemav.(float64) > dashboard.HandoffSchemaVersion-1) { |
||||
return nil |
||||
} |
||||
|
||||
m[path] = b |
||||
return nil |
||||
}) |
||||
|
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return m, nil |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package librarypanel |
||||
|
||||
// Resource is the wire representation of LibraryPanel. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package librarypanel |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package librarypanel |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package playlist |
||||
|
||||
// Resource is the wire representation of Playlist. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package playlist |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package playlist |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package preferences |
||||
|
||||
// Resource is the wire representation of Preferences. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package preferences |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package preferences |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package publicdashboard |
||||
|
||||
// Resource is the wire representation of PublicDashboard. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package publicdashboard |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package publicdashboard |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount |
||||
|
||||
// Resource is the wire representation of ServiceAccount. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package team |
||||
|
||||
// Resource is the wire representation of Team. (TODO be better)
|
||||
type Resource struct { |
||||
Metadata Metadata `json:"metadata"` |
||||
Spec Spec `json:"spec"` |
||||
Status Status `json:"status"` |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package team |
||||
|
||||
import ( |
||||
"time" |
||||
) |
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct { |
||||
CreatedBy string `json:"createdBy"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package team |
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const ( |
||||
OperatorStateStateFailed OperatorStateState = "failed" |
||||
OperatorStateStateInProgress OperatorStateState = "in_progress" |
||||
OperatorStateStateSuccess OperatorStateState = "success" |
||||
) |
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"` |
||||
} |
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string |
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields"` |
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]OperatorState `json:"operatorStates,omitempty"` |
||||
} |
||||
@ -1,11 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
# Temporary - remove this script once the dashboard schema are mature |
||||
|
||||
# Remove the appropriate ellipses from the schema to check for unspecified |
||||
# fields in the artifacts (validating "open") |
||||
|
||||
# Run from root of grafana repo |
||||
CMD=${CLI:-bin/darwin-amd64/grafana-cli} |
||||
FILES=$(grep -rl '"schemaVersion": 30' devenv) |
||||
for DASH in ${FILES}; do echo "${DASH}"; ${CMD} cue validate-resource --dashboard "${DASH}"; done |
||||
Loading…
Reference in new issue