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

fix dashboards api definition nesting #10

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion api/v1alpha1/perses_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Dashboard struct {
persesv1.Dashboard `json:",inline"`
persesv1.DashboardSpec `json:",inline"`
}

func (in *Dashboard) DeepCopyInto(out *Dashboard) {
Expand Down
239 changes: 104 additions & 135 deletions config/crd/bases/perses.dev_persesdashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,77 @@ spec:
type: object
spec:
properties:
kind:
type: string
metadata:
description: ProjectMetadata is the metadata struct for resources
that belongs to a project.
datasources:
additionalProperties:
properties:
default:
type: boolean
display:
properties:
description:
type: string
name:
type: string
type: object
plugin:
description: Plugin will contain the datasource configuration.
The data typed is available in Cue.
properties:
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
required:
- default
- plugin
type: object
description: Datasources is an optional list of datasource definition.
type: object
display:
properties:
createdAt:
format: date-time
description:
type: string
name:
type: string
project:
type: string
updatedAt:
format: date-time
type: string
version:
format: int64
type: integer
required:
- name
- project
- version
type: object
spec:
properties:
datasources:
additionalProperties:
duration:
description: Duration is the default time range to use when getting
data to fill the dashboard
format: duration
type: string
layouts:
items:
properties:
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
type: array
panels:
additionalProperties:
properties:
kind:
type: string
spec:
properties:
default:
type: boolean
display:
properties:
description:
type: string
name:
type: string
required:
- name
type: object
plugin:
description: Plugin will contain the datasource configuration.
The data typed is available in Cue.
properties:
kind:
type: string
Expand All @@ -84,124 +114,63 @@ spec:
- kind
- spec
type: object
required:
- default
- plugin
type: object
description: Datasources is an optional list of datasource definition.
type: object
display:
properties:
description:
type: string
name:
type: string
type: object
duration:
description: Duration is the default time range to use when getting
data to fill the dashboard
format: duration
type: string
layouts:
items:
properties:
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
type: array
panels:
additionalProperties:
properties:
kind:
type: string
spec:
properties:
display:
properties:
description:
type: string
name:
type: string
required:
- name
type: object
plugin:
properties:
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
queries:
items:
queries:
items:
properties:
kind:
type: string
spec:
properties:
kind:
type: string
spec:
plugin:
properties:
plugin:
properties:
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
kind:
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- plugin
- kind
- spec
type: object
required:
- kind
- spec
- plugin
type: object
type: array
required:
- display
- plugin
type: object
required:
- kind
- spec
type: object
type: object
refreshInterval:
description: RefreshInterval is the default refresh interval to
use when landing on the dashboard
format: duration
type: string
variables:
items:
properties:
kind:
description: Kind is the type of the variable. Depending
on the value of Kind, it will change the content of Spec.
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
type: array
required:
- kind
- spec
- display
- plugin
type: object
type: array
required:
- duration
- layouts
- panels
required:
- kind
- spec
type: object
type: object
refreshInterval:
description: RefreshInterval is the default refresh interval to use
when landing on the dashboard
format: duration
type: string
variables:
items:
properties:
kind:
description: Kind is the type of the variable. Depending on
the value of Kind, it will change the content of Spec.
type: string
spec:
x-kubernetes-preserve-unknown-fields: true
required:
- kind
- spec
type: object
type: array
required:
- kind
- metadata
- spec
- duration
- layouts
- panels
type: object
status:
description: PersesDashboardStatus defines the observed state of PersesDashboard
Expand Down
2 changes: 1 addition & 1 deletion controllers/dashboard_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var _ = Describe("Dashboard controller", func() {
Namespace: PersesNamespace,
},
Spec: persesv1alpha1.Dashboard{
Dashboard: *newDashboard,
DashboardSpec: newDashboard.Spec,
},
}

Expand Down
11 changes: 9 additions & 2 deletions controllers/dashboards/dasboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ func (r *PersesDashboardReconciler) syncPersesDashboard(ctx context.Context, per

_, err = persesClient.Dashboard(dashboard.Namespace).Get(dashboard.Name)

persesDashboard := &dashboard.Spec.Dashboard
persesDashboard.Metadata.Name = dashboard.Name
persesDashboard := &persesv1.Dashboard{
Kind: persesv1.KindDashboard,
Metadata: persesv1.ProjectMetadata{
Metadata: persesv1.Metadata{
Name: dashboard.Name,
},
},
Spec: dashboard.Spec.DashboardSpec,
}

if err != nil {
if errors.Is(err, perseshttp.RequestNotFoundError) {
Expand Down
Loading