Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feature SDK Dashboard As Code #1761

Merged
merged 27 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f9e99f5
[FEATURE] 1rst version of a CUE-based Dashboard-as-Code framework (#…
AntoineThebaud Jan 5, 2024
5ab1070
[IGNORE] new github action to ensure CUE gen files are up to date wit…
AntoineThebaud Jan 17, 2024
fdf709e
[ENHANCEMENT] Replace DaC init script by `percli dac setup` (#1695)
AntoineThebaud Jan 17, 2024
fc7a09a
Merge branch 'main' into feat/dashboard-as-code
Nexucis Jan 18, 2024
e4396c3
bump perses github actions to v0.3.2
Nexucis Jan 18, 2024
8658f61
update cue generated file with the latest update from main
Nexucis Jan 18, 2024
7337f13
Merge pull request #1716 from perses/nexucis/upgrade-perses-actions
Nexucis Jan 18, 2024
0771ae1
[ENHANCEMENT] Check if cue can be used during the dac setup (#1717)
Nexucis Jan 19, 2024
6c6f21a
[FEATURE] New command `percli dac build` (#1699)
AntoineThebaud Jan 19, 2024
22a5781
[ENHANCEMENT] Run ID validation on Metadata.Name in all cases to avoi…
AntoineThebaud Jan 22, 2024
35d5620
[DOC] Reference DaC doc in CLI doc (#1723)
AntoineThebaud Jan 23, 2024
a47439a
[ENHANCEMENT] DaC CUE SDK: support display attributes in variables ut…
AntoineThebaud Jan 23, 2024
a32e279
[FEATURE] Add Golang SDK (#1694)
Gladorme Feb 5, 2024
7230bbc
[IGNORE] GO-SDK: Refactor prometheus plugin package (#1742)
Nexucis Feb 5, 2024
b0fbb5b
[ENHANCEMENT] CUE SDK: better UX with panel groups + enforce SDKs ali…
AntoineThebaud Feb 6, 2024
d118d35
Merge branch 'main' into nexucis/sync
Nexucis Feb 8, 2024
ddbf9a1
Merge pull request #1751 from perses/nexucis/sync
Nexucis Feb 8, 2024
3ab1d64
[FEATURE] Add Golang SDK support for `percli dac build` (#1746)
Gladorme Feb 8, 2024
0490a24
[ENHANCEMENT] Add grouped variable helper in Go SDK (#1752)
Gladorme Feb 12, 2024
0f733fb
[ENHANCEMENT] Add output support on Go SDK (#1754)
Gladorme Feb 12, 2024
70f28ea
[ENHANCEMENT] CLI: add config to tune the DaC output folder + interna…
AntoineThebaud Feb 13, 2024
7b7fda5
[ENHANCEMENT] `percli dac setup` adds output dir to .gitignore (#1710)
AntoineThebaud Feb 13, 2024
5206e42
[ENHANCEMENT] `cmd dac setup` support the go language (#1760)
Nexucis Feb 13, 2024
715bb22
Merge branch 'main' into feat/dashboard-as-code
Nexucis Feb 13, 2024
dfbeaf2
[ignore] small improvement in the rbac impl
Nexucis Feb 13, 2024
3947ddc
[ENHANCEMENT] Add doc + renaming row to panel group (#1759)
Gladorme Feb 14, 2024
cf9ad35
Merge branch 'main' into feat/dashboard-as-code
Nexucis Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand All @@ -86,7 +86,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand All @@ -107,7 +107,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delete-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand Down
36 changes: 25 additions & 11 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,25 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
- name: install mdox
run: go install github.com/bwplotka/mdox@latest
- name: check docs
run: make checkdocs

gofmt:
name: "check code format"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
- name: install cue
run: go install cuelang.org/go/cmd/cue@v0.4.2
enable_cue: true
- name: check format
run: make checkformat
- name: check go.mod
Expand All @@ -60,10 +58,11 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
enable_cue: true # needed for DaC CLI commands unit tests
- name: test
run: make integration-test
test-mysql:
Expand All @@ -82,10 +81,11 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
enable_cue: true # needed for DaC CLI commands unit tests
- name: test
run: make mysql-integration-test
golangci:
Expand All @@ -94,7 +94,7 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
Expand All @@ -114,13 +114,27 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
- name: install cue
run: go install cuelang.org/go/cmd/cue@latest
enable_cue: true
- name: eval cue schema
run: make cue-eval
- name: test cue schema
run: make cue-test
check-cue-gen:
name: "check cue gen files"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
enable_cue: true
- name: generate cue files
run: make cue-gen
- name: check for changes
run: git diff --exit-code || { echo "CUE generated files are not up to date. Please run 'make cue-gen' and commit the changes."; exit 1; }
6 changes: 3 additions & 3 deletions .github/workflows/react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand All @@ -47,7 +47,7 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.2.0
- uses: perses/github-actions@v0.3.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Thumbs.db


/bin
/built
/dist

coverage.txt
Expand All @@ -27,8 +28,7 @@ coverage.txt

EXTRACTED_CHANGELOG.md

cue.mod/pkg
cue.mod/usr
cue.mod/gen

dev/local_db

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ USER nobody
COPY --chown=nobody:nobody perses /bin/perses
COPY --chown=nobody:nobody percli /bin/percli
COPY --chown=nobody:nobody LICENSE /LICENSE
COPY --chown=nobody:nobody schemas/ /etc/perses/schemas/
COPY --chown=nobody:nobody cue/schemas/ /etc/perses/schemas/
COPY --chown=nobody:nobody cue.mod/ /etc/perses/cue.mod/
COPY --chown=nobody:nobody docs/examples/config.docker.yaml /etc/perses/config.yaml
COPY --from=build-env --chown=nobody:nobody /perses /perses
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 The Perses Authors
# Copyright 2024 The Perses Authors
# 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
Expand Down Expand Up @@ -48,7 +48,7 @@ tag:
checkformat:
@echo ">> checking go code format"
! $(GOFMT) -d $$(find . -name '*.go' -not -path "./ui/*" -print) | grep '^'
@echo ">> running check for cue file format"
@echo ">> running check for CUE file format"
./scripts/cue.sh --checkformat

.PHONY: checkdocs
Expand Down Expand Up @@ -91,12 +91,19 @@ fmt-docs:

.PHONY: cue-eval
cue-eval:
@echo ">> eval cue schemas"
$(CUE) eval ./schemas/...
@echo ">> eval CUE files"
$(CUE) eval ./cue/...

.PHONY: cue-gen
cue-gen:
@echo ">> generate CUE definitions from golang datamodel"
$(CUE) get go github.com/perses/perses/pkg/model/api/v1
cp -r cue.mod/gen/github.com/perses/perses/pkg/model/* cue/model/ && rm -r cue.mod/gen
find cue/model -name "*.cue" -exec sed -i 's/\"github.com\/perses\/perses\/pkg/\"github.com\/perses\/perses\/cue/g' {} \;

.PHONY: cue-test
cue-test:
@echo ">> test cue schemas with json data"
@echo ">> test CUE schemas with json data"
$(GO) run ./scripts/cue-test/cue-test.go

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ progress. The current pieces that are in place are:
- The Plugin architecture has finally reached a stable point.
- The plugins concern the Variables, Panels, Queries and Datasources definitions.
- To provide a good static validation, the backend is using multiple CUE schemas and the CLI got a `lint` command.
All schemas are available in the [schemas](./schemas) folder.
All schemas are available in the [cue/schemas](./cue/schemas) folder.
- A backend REST API provides R/W access to dashboard and datasource definitions.
- A CLI that can be used to interact with the REST API. A short doc is available [here](./docs/tooling/cli.md)
- While the UI is still in progress, we already have:
Expand Down
8 changes: 5 additions & 3 deletions cmd/percli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"os"

"github.com/perses/perses/internal/cli/cmd/apply"
"github.com/perses/perses/internal/cli/cmd/dac"
"github.com/perses/perses/internal/cli/cmd/describe"
"github.com/perses/perses/internal/cli/cmd/get"
"github.com/perses/perses/internal/cli/cmd/lint"
Expand All @@ -42,19 +43,20 @@ func newRootCommand() *cobra.Command {
Short: "Command line interface to interact with the Perses API",
}

// The list of the commands supported
// The list of supported commands
cmd.AddCommand(apply.NewCMD())
cmd.AddCommand(dac.NewCMD())
cmd.AddCommand(describe.NewCMD())
cmd.AddCommand(get.NewCMD())
cmd.AddCommand(lint.NewCMD())
cmd.AddCommand(login.NewCMD())
cmd.AddCommand(migrate.NewCMD())
cmd.AddCommand(refresh.NewCMD())
cmd.AddCommand(project.NewCMD())
cmd.AddCommand(refresh.NewCMD())
cmd.AddCommand(remove.NewCMD())
cmd.AddCommand(version.NewCMD())

// the list of the global flags supported
// the list of supported global flags
cmd.PersistentFlags().StringVar(&configPath, "percliconfig", config.GetDefaultPath(), "Path to the percliconfig file to use for CLI requests.")
cmd.PersistentFlags().StringVar(&logLevel, "log.level", "info", "Set the log verbosity level. Possible values: panic, fatal, error, warning, info, debug, trace")

Expand Down
44 changes: 44 additions & 0 deletions cue/dac-utils/dashboard/dashboard.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 The Perses Authors
// 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 package offers an utility to build a dashboards easily, by allowing
// to provide panels together with their layout.

package dashboard

import (
"github.com/perses/perses/cue/model/api/v1"
v1Dashboard "github.com/perses/perses/cue/model/api/v1/dashboard"
)

// expected user inputs
#name: string
#project: string
#variables: [...v1Dashboard.#Variable]
#panelGroups: [string]: {
layout: v1Dashboard.#Layout
panels: [string]: v1.#Panel
}

// output: the dashboard in the format expected by Perses
v1.#Dashboard & {
metadata: {
name: #name
project: #project
}
spec: {
variables: #variables
panels: {for group in #panelGroups {group.panels}}
layouts: [for group in #panelGroups {group.layout}]
}
}
Loading
Loading