-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit of initial state of the grafana-app-sdk.
- Loading branch information
1 parent
3db4ea5
commit 66a237b
Showing
203 changed files
with
24,279 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# https://help.github.com/articles/about-codeowners/ | ||
# https://git-scm.com/docs/gitignore#_pattern_format | ||
|
||
# See the following docs for more details about order in CODEOWNERS | ||
# https://github.community/t/order-of-owners-in-codeowners-file/143073 | ||
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax | ||
|
||
* @grafana/cloud-app-platform-squad | ||
|
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,24 @@ | ||
# Contributing guide | ||
|
||
All contributions are welcome. | ||
|
||
If there is something you're curious about with the SDK (project direction, functionality, etc.), please do not hesitate to visit our [Discussions](https://github.com/grafana/grafana-app-sdk/discussions) section. | ||
|
||
If you discover a bug, or think something should be included in the SDK, feel free to file an issue, or open a PR. | ||
|
||
## Releasing a new version | ||
|
||
In order to release a new version, you can use the `scripts/release.sh` script, like so: | ||
|
||
```sh | ||
# Release a new patch version, e.g. 1.0.1 | ||
./scripts/release.sh patch | ||
|
||
# Release a new minor version, e.g. 1.1.0 | ||
./scripts/release.sh minor | ||
|
||
# Release a new major version, e.g. 2.0.0 | ||
./scripts/release.sh major | ||
``` | ||
|
||
The script will make sure that you have the latest `main` version in your tree, will run linter / tests / build and it will create a semver-appropriate signed tag and push it to remote. Our CI automation will in turn create an appropriate Github release with artifacts. The script currently does not support pre-release versions. |
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,60 @@ | ||
SOURCES := $(shell find . -type f -name "*.go") | ||
BRANCH := $(shell git branch | sed -n -e 's/^\* \(.*\)/\1/p') | ||
COMMIT := $(shell git rev-parse HEAD) | ||
HOST := $(shell hostname) | ||
GOMOD := go.mod | ||
GOSUM := go.sum | ||
VENDOR := vendor | ||
COVOUT := coverage.out | ||
|
||
BIN_DIR := target | ||
|
||
all: deps lint test build drone | ||
|
||
deps: $(GOSUM) | ||
$(GOSUM): $(SOURCES) $(GOMOD) | ||
go mod tidy | ||
|
||
LINTER_VERSION := 1.51.2 | ||
LINTER_BINARY := $(BIN_DIR)/golangci-lint-$(LINTER_VERSION) $@ | ||
|
||
.PHONY: lint | ||
lint: $(LINTER_BINARY) | ||
$(LINTER_BINARY) run $(LINT_ARGS) | ||
|
||
$(LINTER_BINARY): | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) v$(LINTER_VERSION) | ||
@mv $(BIN_DIR)/golangci-lint $@ | ||
|
||
.PHONY: test | ||
test: | ||
go test -count=1 -cover -covermode=atomic -coverprofile=$(COVOUT) ./... | ||
|
||
.PHONY: coverage | ||
coverage: test | ||
go tool cover -html=$(COVOUT) | ||
|
||
DRONE_YAML := .drone.yml | ||
DRONE_JSONNET := .drone/drone.jsonnet | ||
DRONE_FILES := $(shell find .drone -type f) | ||
DRONE_DOCKER := @docker run --rm -e DRONE_SERVER -e DRONE_TOKEN -v ${PWD}:${PWD} -w "${PWD}" us.gcr.io/kubernetes-dev/drone-cli:1.4.0 drone | ||
|
||
$(JSONNET_FMT): $(DRONE_FILES) | ||
@jsonnetfmt -i $^ | ||
@touch $@ | ||
|
||
$(DRONE_YAML): $(DRONE_FILES) | ||
$(DRONE_DOCKER) jsonnet --format --stream --source $(DRONE_JSONNET) --target $@ | ||
$(DRONE_DOCKER) sign grafana/grafana-app-sdk --save | ||
|
||
drone: $(JSONNET_FMT) $(DRONE_YAML) | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -f $(COVOUT) | ||
@rm -f $(DRONE_YAML) | ||
@rm -rf $(VENDOR) | ||
|
||
.PHONY: build | ||
build: | ||
@go build -ldflags="-X 'main.version=dev-$(BRANCH)' -X 'main.source=$(HOST)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(shell date -u "+%FT%TZ")'" -o "$(BIN_DIR)/grafana-app-sdk" cmd/grafana-app-sdk/*.go |
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,113 @@ | ||
# grafana-app-sdk | ||
|
||
<hr/> | ||
|
||
**This repository is currently *experimental*, which means that interfaces and behavior may change as it evolves.** | ||
|
||
<hr/> | ||
|
||
The `grafana-app-sdk` is an SDK used for developing apps/extensions for grafana. It encompasses the following: | ||
* Code generation and project boilerplate generation from a CLI | ||
* Storage and version management of unique schemas (kinds) | ||
* An reconciler/event-based model for handling changes to data | ||
* Both simple building blocks and opinionated solutions for building operators and plugins | ||
* An interface layer over your storage system, allowing any compatible API-server-like system to be plugged in | ||
|
||
## Quickstart | ||
|
||
If you want to try out using the SDK, there is a [tutorial to build a simple issue tracker](docs/tutorials/issue-tracker/README.md) which starts you from zero and brings you through to deploying a simple app built using the SDK. | ||
|
||
## Installation of the CLI | ||
|
||
### go install | ||
The simplest way to install the CLI is with `go install`. To get the latest version, use: | ||
```bash | ||
go install github.com/grafana/grafana-app-sdk/cmd/grafana-app-sdk@latest | ||
``` | ||
(ensure that your `GOPATH/bin` (typically `$HOME/go/bin`) is in your `PATH`) | ||
|
||
### Binary | ||
If you prefer to download a binary and add it to your `PATH`, you can install a binary from the releases page: | ||
|
||
1. [Visit the latest release page](https://github.com/grafana/grafana-app-sdk/releases/latest) | ||
2. Find the appropriate artifact for your OS and architecture | ||
3. Download the artifact and untar it into your PATH | ||
|
||
Once you have a version of the CLI installed, you can test it with: | ||
``` | ||
grafana-app-sdk version | ||
``` | ||
Which will print the version of the CLI which you have installed. | ||
|
||
## App Design | ||
|
||
An agnotic view of an app using the SDK looks like: | ||
|
||
![Application Using SDK Diagram](docs/diagrams/app_logic.png) | ||
|
||
The SDK handles interaction with the storage system, and surfacing simple interfaces for performing normal operations on resources in storage, as well as creating controller/operator loops that react to changes in the resources in the storage system. | ||
|
||
A typical grafana app deployment might look more like: | ||
|
||
![Application Using SDK Diagram](docs/diagrams/design_pattern_simple.png) | ||
|
||
For more details on application design, see [App Design](docs/app_design.md). | ||
|
||
## CLI Usage | ||
|
||
Full CLI usage is covered in [CLI docs page](docs/cli.md), but for a brief overview of the commands: | ||
|
||
| Command | Description | | ||
|---------|-------------| | ||
| `version` | Prints the version (use `-v` for a verbose print) | | ||
| `generate` | Generates code from your CUE kinds (defaults to CUE in `schemas`, use `-c`/`--cuepath` to speficy a different CUE path) | | ||
| `project init <module name>` | Creates a project template, including directory structure, go module, CUE module, and Makefile | | ||
| `project component add <component>` | Add boilerplate code for a component to your project. `<component>` options are `frontend`, `backend`, and `operator` | | ||
| `project local init` | Initialize the `./local` directory for a local development environment (done automatically by `project init`) | | ||
| `project local generate` | Generate a YAML bundle for local deployment, based on your CUE kinds and `./local/config.yaml` | | ||
|
||
## Library Usage | ||
|
||
Read more about the library usage in the [docs](docs/README.md) directory. | ||
|
||
### `resource` | ||
|
||
Package exposing interfaces for resources and client, and the various kind of `Store` objects, which allow you to use key/value store-like objects for handling your data. | ||
|
||
See [Resource Objects](docs/resource-objects.md) and [Resource Stores](docs/resource-stores.md) for more information on how to work with resource `Objects` and use `Store` objects. | ||
|
||
### `operator` | ||
|
||
Package containing operator code, for building out event-based and/or reconciler-based operators. | ||
|
||
|
||
See [Operators & Event-Based Design](docs/operators.md) for more details on building operators. | ||
|
||
### `k8s` | ||
|
||
Implementation of a storage layer using a kubernetes-compatible API server. | ||
|
||
### `plugin` | ||
|
||
Wrapper for the grafana backend plugin go SDK which adds layers on top for dealing with lazy-loading, encoding kube configs in secure JSON data, and HTTP-like routing. | ||
|
||
See [Writing Back-End Plugins](docs/plugin-backend.md) for more details on using the `plugin` package. | ||
|
||
## Dependencies | ||
|
||
The grafana-app-sdk code generation uses [kindsys](https://github.com/grafana/kindsys) for it's CUE kind definitions, and [thema](https://github.com/grafana/thema) for the generated code's unmarshaling. | ||
|
||
If you use the generated code, you must take a project dependency on [thema](https://github.com/grafana/thema), as it is used as a depndency in the generated code (kindsys is only used in the generation process, and is not needed in your project). | ||
|
||
## Further Reading | ||
|
||
Please see the [/docs](docs/README.md) directory for full documentation, | ||
or take a look at the [SDK Use Cases](docs/use-cases.md), [Kubernetes Concepts](docs/kubernetes.md), or [FAQ](docs/faq.md) for high-level overviews. | ||
|
||
The `examples` directory contains runnable example projects that use different SDK components. | ||
|
||
Each package also contains a README.md detailing package usage and simple examples. | ||
|
||
## Contributing | ||
|
||
See our [contributing guide](CONTRIBUTING) for instructions on how to contribute to the development of the SDK. |
Oops, something went wrong.