Skip to content

Instantly share code, notes, and snippets.

View sdboyer's full-sized avatar

sam boyer sdboyer

View GitHub Profile
@sdboyer
sdboyer / dashboard_kind.json
Created July 31, 2023 19:09
dashboard kind as JSON+JSON Schema
{
"name": "Dashboard",
"maturity": "experimental",
"description": "A Grafana dashboard.",
"lineage": {
"schemas": [
{
"version": [
0,
0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sdboyer
sdboyer / lineage.cue
Created April 19, 2023 16:13
flattened lineages
import "github.com/grafana/thema"
thema.#Lineage
name: "trivial-two"
schemas: [{
version: [0, 0]
schema: {
firstfield: string
}
},
@sdboyer
sdboyer / panelcfg.cue
Created January 23, 2023 18:30
Starter file for writing a PanelCfg composable kind
// Copyright 2023 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,
@sdboyer
sdboyer / datasourcecfg.cue
Created January 23, 2023 18:29
Starter file for writing a DataSourceCfg composable kind
// Copyright 2023 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,
@sdboyer
sdboyer / dataquery.cue
Created January 23, 2023 18:28
Starter file for writing a dataquery composable kind
// Copyright 2023 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
@sdboyer
sdboyer / dashboard.crm.yaml
Last active December 14, 2022 09:58
errors in auto-converting dashboard kind to crd
# THIS FILE IS GENERATED. EDITING IS FUTILE.
#
# Generated by:
# kinds/gen.go
# Using jennies:
# YamlCRDJenny
#
# Run 'make gen-cue' from repository root to regenerate.
kind: CustomResourceDefinition

Personas

  • Grafana user - clickin dem boxes in dat browser
  • Plugin developer - someone writing a particular Grafana plugin, whether that plugin happens to be in core or external
  • Core developer - someone working on any subsystem in Grafana core other than the kind framework itself, frontend or backend
  • Kind framework developer - someone working on the kind framework - basically, what’s under pkg/kindsys

Things

  • Kind Category Schema - a meta-schema specifying how a particular category of kind and its contained schemas must be declared
@sdboyer
sdboyer / generators.go
Last active November 1, 2022 12:59
sketch of genericized modular generator framework
type Generator[T any] interface {
// dear go generics why do you have to suck so much (union not allowed because interfaces contain methods)
OneToOne[T] | OneToMany[T] | ManyToOne[T] | ManyToMany[T]
}
// Takes one T and makes one file
//
// replaces KindGenStep
type OneToOne[T any] interface {
// Name returns the name of the generator. For use in error output.
@sdboyer
sdboyer / lokicfg.cue
Last active October 3, 2022 14:56
rapidly prototyped demo of thema and codegen for loki config file
package lokicfg
import "github.com/grafana/thema"
// - MIGHT be helpful for them if there could be an init command that tries to start from Go structs
// - Probably need to generate YAML struct tags
thema.#Lineage
name: "lokicfg"
seqs: [