[v3.2] Add grafana dashboard importing API (#11)

* Add API to import grafana templates to kubesphere dashboard
* Merge and fix the latest codes from kubesphere #2501

Signed-off-by: zhu733756 <talonzhu@yunify.com>
This commit is contained in:
zhu733756
2021-08-16 11:41:29 +08:00
committed by zhu733756
parent 9df6df5544
commit 242ceb54f6
217 changed files with 119028 additions and 96 deletions

View File

@@ -0,0 +1,15 @@
/*
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.
*/
package v1alpha1
func (_ *Dashboard) Hub() {}

View File

@@ -18,7 +18,6 @@ package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/json"
"kubesphere.io/monitoring-dashboard/api/v1alpha1/panels"
)
@@ -48,9 +47,14 @@ type Time struct {
To string `json:"to,omitempty"`
}
// Supported panel type
// Supported panel
type Panel struct {
// It can only be one of the following three types
// panel metadata
PanelMeta `json:",inline"`
// A collection of queries
// Only for panels with `graph` or `singlestat` type
Targets []panels.Target `json:"targets,omitempty"`
// The panel row
Row *panels.Row `json:",inline"`
@@ -68,42 +72,13 @@ const (
PanelSingleStat PanelType = "singlestat"
)
func (p *Panel) UnmarshalJSON(data []byte) error {
if len(data) == 0 {
return nil
}
var t struct{ Type PanelType }
err := json.Unmarshal(data, &t)
if err != nil {
return err
}
switch t.Type {
case PanelRow:
p.Row = &panels.Row{}
return json.Unmarshal(data, p.Row)
case PanelGraph:
p.Graph = &panels.Graph{}
return json.Unmarshal(data, p.Graph)
case PanelSingleStat:
p.SingleStat = &panels.SingleStat{}
return json.Unmarshal(data, p.SingleStat)
}
return json.Unmarshal(data, p)
}
func (p *Panel) MarshalJSON() (data []byte, err error) {
switch {
case p.Row != nil:
return json.Marshal(p.Row)
case p.Graph != nil:
return json.Marshal(p.Graph)
case p.SingleStat != nil:
return json.Marshal(p.SingleStat)
}
return json.Marshal(p)
type PanelMeta struct {
// Name of the panel
Title string `json:"title,omitempty"`
// Panel ID
Id int64 `json:"id,omitempty"`
// Panel Type, one of `row`, `graph`, `singlestat`
Type PanelType `json:"type"`
}
// Templating defines a variable, which can be used as a placeholder in query
@@ -115,6 +90,7 @@ type Templating struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// Dashboard is the Schema for the dashboards API
type Dashboard struct {

View File

@@ -5,15 +5,15 @@ package panels
// Graph visualizes range query results into a linear graph
type Graph struct {
// Name of the graph panel
Title string `json:"title,omitempty"`
//Title string `json:"title,omitempty"`
// Must be `graph`
Type string `json:"type"`
//Type string `json:"type"`
// Panel ID
Id int64 `json:"id,omitempty"`
//Id int64 `json:"id,omitempty"`
// Panel description
Description string `json:"description,omitempty"`
// A collection of queries
Targets []Target `json:"targets,omitempty"`
//Targets []Target `json:"targets,omitempty"`
// Display as a bar chart
Bars bool `json:"bars,omitempty"`
// Set series color

View File

@@ -5,9 +5,9 @@ package panels
// Row groups relevant charts
type Row struct {
// Name of the row panel
Title string `json:"title,omitempty"`
//Title string `json:"title,omitempty"`
// Must be `row`
Type string `json:"type"`
//Type string `json:"type"`
// Panel ID
Id int64 `json:"id,omitempty"`
//Id int64 `json:"id,omitempty"`
}

View File

@@ -5,15 +5,15 @@ package panels
// SingleStat shows instant query result
type SingleStat struct {
// Name of the signlestat panel
Title string `json:"title,omitempty"`
//Title string `json:"title,omitempty"`
// Must be `singlestat`
Type string `json:"type"`
//Type string `json:"type"`
// Panel ID
Id int64 `json:"id,omitempty"`
//Id int64 `json:"id,omitempty"`
// A collection of queries
Targets []Target `json:"targets,omitempty"`
//Targets []Target `json:"targets,omitempty"`
// Limit the decimal numbers
Decimals int64 `json:"decimals,omitempty"`
Decimals *int64 `json:"decimals,omitempty"`
// Display unit
Format string `json:"format,omitempty"`
}

View File

@@ -25,11 +25,6 @@ import ()
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Graph) DeepCopyInto(out *Graph) {
*out = *in
if in.Targets != nil {
in, out := &in.Targets, &out.Targets
*out = make([]Target, len(*in))
copy(*out, *in)
}
if in.Colors != nil {
in, out := &in.Colors, &out.Colors
*out = make([]string, len(*in))
@@ -70,10 +65,10 @@ func (in *Row) DeepCopy() *Row {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SingleStat) DeepCopyInto(out *SingleStat) {
*out = *in
if in.Targets != nil {
in, out := &in.Targets, &out.Targets
*out = make([]Target, len(*in))
copy(*out, *in)
if in.Decimals != nil {
in, out := &in.Decimals, &out.Decimals
*out = new(int64)
**out = **in
}
}

View File

@@ -172,6 +172,12 @@ func (in *DashboardSpec) DeepCopy() *DashboardSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Panel) DeepCopyInto(out *Panel) {
*out = *in
out.PanelMeta = in.PanelMeta
if in.Targets != nil {
in, out := &in.Targets, &out.Targets
*out = make([]panels.Target, len(*in))
copy(*out, *in)
}
if in.Row != nil {
in, out := &in.Row, &out.Row
*out = new(panels.Row)
@@ -199,6 +205,21 @@ func (in *Panel) DeepCopy() *Panel {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PanelMeta) DeepCopyInto(out *PanelMeta) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PanelMeta.
func (in *PanelMeta) DeepCopy() *PanelMeta {
if in == nil {
return nil
}
out := new(PanelMeta)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Templating) DeepCopyInto(out *Templating) {
*out = *in

View File

@@ -0,0 +1,26 @@
// +kubebuilder:object:generate=true
package anotations
// "github.com/grafana-tools/sdk,omitempty"
// refers to https://pkg.go.dev/github.com/grafana-tools/sdk#Annotation
type Annotation struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Datasource string `json:"datasource,omitempty" yaml:"datasource,omitempty"`
ShowLine bool `json:"showLine,omitempty" yaml:"showLine,omitempty"`
IconColor string `json:"iconColor,omitempty" yaml:"iconColor,omitempty"`
LineColor string `json:"lineColor,omitempty" yaml:"lineColor,omitempty"`
IconSize uint `json:"iconSize,omitempty" yaml:"iconSize,omitempty"`
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
Query string `json:"query,omitempty" yaml:"query,omitempty"`
Expr string `json:"expr,omitempty" yaml:"expr,omitempty"`
Step string `json:"step,omitempty" yaml:"step,omitempty"`
TextField string `json:"textField,omitempty" yaml:"textField,omitempty"`
TextFormat string `json:"textFormat,omitempty" yaml:"textFormat,omitempty"`
TitleFormat string `json:"titleFormat,omitempty" yaml:"titleFormat,omitempty"`
TagsField string `json:"tagsField,omitempty" yaml:"tagsField,omitempty"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
TagKeys string `json:"tagKeys,omitempty" yaml:"tagKeys,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}

View File

@@ -0,0 +1,43 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package anotations
import ()
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Annotation) DeepCopyInto(out *Annotation) {
*out = *in
if in.Tags != nil {
in, out := &in.Tags, &out.Tags
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Annotation.
func (in *Annotation) DeepCopy() *Annotation {
if in == nil {
return nil
}
out := new(Annotation)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,224 @@
/*
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.
*/
package v1alpha2
import (
"fmt"
"kubesphere.io/monitoring-dashboard/api/v1alpha1"
v1alpha1panels "kubesphere.io/monitoring-dashboard/api/v1alpha1/panels"
v1alpha2panels "kubesphere.io/monitoring-dashboard/api/v1alpha2/panels"
v1alpha2templatings "kubesphere.io/monitoring-dashboard/api/v1alpha2/templatings"
"kubesphere.io/monitoring-dashboard/api/v1alpha2/time"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
func (_ *Dashboard) Hub() {}
func (src *Dashboard) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha1.Dashboard)
dst.ObjectMeta = src.ObjectMeta
dst.Spec.Title = src.Spec.Title
dst.Spec.Description = src.Spec.Description
dst.Spec.Time = v1alpha1.Time{
From: src.Spec.Time.From,
To: src.Spec.Time.To,
}
pls := []v1alpha1.Panel{}
for _, panel := range src.Spec.Panels {
if panel == nil {
continue
}
t := v1alpha1.PanelType(panel.Type)
if dst.Spec.DataSource == "" && panel.CommonPanel.Datasource != nil {
dst.Spec.DataSource = point2string(panel.CommonPanel.Datasource)
}
dstPanel := v1alpha1.Panel{
PanelMeta: v1alpha1.PanelMeta{
Title: panel.Title,
Id: panel.Id,
Type: t,
},
}
for _, target := range panel.CommonPanel.Targets {
dstPanel.Targets = append(dstPanel.Targets, v1alpha1panels.Target{
Expression: target.Expression,
LegendFormat: target.LegendFormat,
RefID: target.RefID,
Step: target.Step,
})
}
switch t {
case "graph":
if len(panel.CommonPanel.Colors) > 0 {
dstPanel.Graph.Colors = panel.CommonPanel.Colors
}
graph := panel.GraphPanel
if graph != nil {
yaxes := make([]v1alpha1panels.Yaxis, 0)
for _, yaxis := range graph.Yaxes {
yaxes = append(yaxes, v1alpha1panels.Yaxis{
Decimals: yaxis.Decimals,
Format: yaxis.Format,
})
}
if len(yaxes) > 0 {
dstPanel.Graph.Yaxes = yaxes
}
if panel.CommonPanel.Description != nil {
dstPanel.Graph.Description = point2string(panel.CommonPanel.Description)
}
if graph.Bars {
dstPanel.Graph.Bars = graph.Bars
}
if graph.Lines {
dstPanel.Graph.Lines = graph.Lines
}
if graph.Stack {
dstPanel.Graph.Stack = graph.Stack
}
}
case "singlestat":
if panel.CommonPanel.Decimals != nil {
dstPanel.SingleStat.Decimals = panel.CommonPanel.Decimals
}
if panel.CommonPanel.Format != "" {
dstPanel.SingleStat.Format = panel.CommonPanel.Format
}
case "row":
// var r v1alpha1panels.Row
// dstPanel.Row = &r
default:
fmt.Println("unhandled panel type: skippedtype:", t)
}
pls = append(pls, dstPanel)
}
dst.Spec.Panels = pls
for _, temp := range src.Spec.Templatings {
dst.Spec.Templatings = append(dst.Spec.Templatings, v1alpha1.Templating{
Name: temp.Name,
Query: temp.Query,
})
}
return nil
}
func (dst *Dashboard) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1alpha1.Dashboard)
dst.ObjectMeta = src.ObjectMeta
dst.Spec.Title = src.Spec.Title
dst.Spec.Description = src.Spec.Description
dst.Spec.Time = time.Time{
From: src.Spec.Time.From,
To: src.Spec.Time.To,
}
pls := []*v1alpha2panels.Panel{}
for _, panel := range src.Spec.Panels {
t := v1alpha1.PanelType(panel.Type)
dstPanel := v1alpha2panels.Panel{
CommonPanel: v1alpha2panels.CommonPanel{
Title: panel.PanelMeta.Title,
Id: panel.PanelMeta.Id,
Type: string(panel.PanelMeta.Type),
Datasource: &src.Spec.DataSource,
},
}
for _, target := range panel.Targets {
dstPanel.CommonPanel.Targets = append(dstPanel.CommonPanel.Targets, v1alpha2panels.Target{
Expression: target.Expression,
LegendFormat: target.LegendFormat,
RefID: target.RefID,
Step: target.Step,
})
}
switch t {
case "graph":
graph := panel.Graph
if graph != nil {
dstPanel.CommonPanel.Description = &graph.Description
yaxes := make([]v1alpha2panels.Axis, 0)
for _, yaxis := range graph.Yaxes {
yaxes = append(yaxes, v1alpha2panels.Axis{
Decimals: yaxis.Decimals,
Format: yaxis.Format,
})
}
dstPanel.GraphPanel.Bars = graph.Bars
dstPanel.GraphPanel.Lines = graph.Lines
dstPanel.GraphPanel.Stack = graph.Stack
dstPanel.GraphPanel.Yaxes = yaxes
}
case "singlestat":
singlestat := panel.SingleStat
if singlestat != nil {
dstPanel.CommonPanel.Decimals = singlestat.Decimals
dstPanel.CommonPanel.Format = singlestat.Format
}
case "row":
// var r v1alpha2panels.RowPanel
// dstPanel.RowPanel = &r
default:
fmt.Println("unhandled panel type: skippedtype:", t)
}
pls = append(pls, &dstPanel)
}
dst.Spec.Panels = pls
for _, temp := range src.Spec.Templatings {
dst.Spec.Templatings = append(dst.Spec.Templatings, v1alpha2templatings.TemplateVar{
Name: temp.Name,
Query: temp.Query,
})
}
return nil
}
func point2string(p *string) string {
if p == nil {
return ""
}
return *p
}

View File

@@ -0,0 +1,92 @@
/*
Copyright 2020 The KubeSphere 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.
*/
package v1alpha2
import (
ants "kubesphere.io/monitoring-dashboard/api/v1alpha2/annotations"
panels "kubesphere.io/monitoring-dashboard/api/v1alpha2/panels"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
templatings "kubesphere.io/monitoring-dashboard/api/v1alpha2/templatings"
time "kubesphere.io/monitoring-dashboard/api/v1alpha2/time"
)
// DashboardSpec defines the desired state of Dashboard
type DashboardSpec struct {
ID uint `json:"id,omitempty" `
UID string `json:"uid,omitempty" `
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Editable bool `json:"editable,omitempty"`
SharedCrosshair bool `json:"shared_crosshair,omitempty"`
Tags []string `json:"tags,omitempty"`
AutoRefresh string `json:"auto_refresh,omitempty"`
Timezone string `json:"timezone,omitempty"`
// Annotations
Annotations []ants.Annotation `json:"annotations,omitempty"`
// Time range
Time time.Time `json:"time,omitempty"`
Panels []*panels.Panel `json:"panels,omitempty"`
// // Templating variables
Templatings []templatings.TemplateVar `json:"templatings,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// Dashboard is the Schema for the dashboards API
type Dashboard struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DashboardSpec `json:"spec,omitempty"`
}
// +kubebuilder:object:root=true
// DashboardList contains a list of Dashboard
type DashboardList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Dashboard `json:"items"`
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:storageversion
// ClusterDashboard is the Schema for the culsterdashboards API
type ClusterDashboard struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DashboardSpec `json:"spec,omitempty"`
}
// +kubebuilder:object:root=true
// ClusterDashboardList contains a list of ClusterDashboard
type ClusterDashboardList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterDashboard `json:"items"`
}
func init() {
SchemeBuilder.Register(&Dashboard{}, &DashboardList{})
SchemeBuilder.Register(&ClusterDashboard{}, &ClusterDashboardList{})
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 The KubeSphere 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.
*/
// Package v1alpha2 contains API Schema definitions for the monitoring v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=monitoring.kubesphere.io
package v1alpha2
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "monitoring.kubesphere.io", Version: "v1alpha2"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

View File

@@ -0,0 +1,19 @@
// +kubebuilder:object:generate=true
package panels
type BarGaugeOptions struct {
Orientation string `json:"orientation,omitempty"`
TextMode string `json:"textMode,omitempty"`
ColorMode string `json:"colorMode,omitempty"`
GraphMode string `json:"graphMode,omitempty"`
JustifyMode string `json:"justifyMode,omitempty"`
DisplayMode string `json:"displayMode,omitempty"`
Content string `json:"content,omitempty"`
Mode string `json:"mode,omitempty"`
}
// refers to https://pkg.go.dev/github.com/grafana-tools/sdk#BarGaugePanel
type BarGaugePanel struct {
Options *BarGaugeOptions `json:"options,omitempty"`
// FieldConfig FieldConfig `json:"fieldConfig,omitempty"`
}

View File

@@ -0,0 +1,44 @@
// +kubebuilder:object:generate=true
package panels
// Query editor options
type CommonPanel struct {
// Name of the panel
Title string `json:"title,omitempty"`
// Type of the panel
Type string `json:"type,omitempty"`
// Panel ID
Id int64 `json:"id,omitempty"`
// Description
Description *string `json:"description,omitempty"`
// Datasource
Datasource *string `json:"datasource,omitempty"`
// Height
Height *string `json:"height,omitempty"`
Decimals *int64 `json:"decimals,omitempty"`
// A collection of queries
Targets []Target `json:"targets,omitempty"`
// Set series color
Colors []string `json:"colors,omitempty"`
// legend
Legend []string `json:"legend,omitempty"`
// Display unit
Format string `json:"format,omitempty"`
}
// +kubebuilder:object:generate=true
// Query editor options
// Referers to https://pkg.go.dev/github.com/grafana-tools/sdk#Target
type Target struct {
// Reference ID
RefID int64 `json:"refId,omitempty"`
// only support prometheus,and the corresponding fields are as follows:
// Input for fetching metrics.
Expression string `json:"expr,omitempty"`
// Legend format for outputs. You can make a dynamic legend with templating variables.
LegendFormat string `json:"legendFormat,omitempty"`
// Set series time interval
Step string `json:"step,omitempty"`
}

View File

@@ -0,0 +1,229 @@
// +kubebuilder:object:generate=true
package panels
import (
"encoding/json"
"errors"
"reflect"
)
// Supported panel type
// type Panel struct {
// // private property of the bargauge panel
// Options *BarGaugeOptions `json:"options,omitempty"`
// // ****common properties start
// // Name pf the panel
// Title string `json:"title,omitempty"`
// // The type of the panel
// Type string `json:"type,omitempty"`
// // Panel ID
// Id int64 `json:"id,omitempty"`
// // Panel description
// Description string `json:"description,omitempty"`
// // datasource
// Datasource string `json:"datasource,omitempty"`
// // A collection of queries
// Targets []Target `json:"targets,omitempty"`
// // Display as a bar chart
// Bars bool `json:"bars,omitempty"`
// // Set series color
// Colors []string `json:"colors,omitempty"`
// // color settings
// // todo graph
// Color []string `json:"color,omitempty"`
// // Display as a line chart
// Lines bool `json:"lines,omitempty"`
// // Display as a stacked chart
// Stack bool `json:"stack,omitempty"`
// // legend
// Legend []string `json:"legend,omitempty,flow"`
// // height
// Height string `json:"height,omitempty"`
// // transparent
// Transparent bool `json:"transparent,omitempty"`
// HiddenColumns []string `json:"hidden_columns,omitempty,flow"`
// TimeSeriesAggregations []string `json:"time_series_aggregations,omitempty"`
// // value name
// ValueName string `json:"valueName,omitempty"`
// // *****common properties end
// // private property of graph panel
// // Y-axis options
// Yaxes []Yaxis `json:"yaxes,omitempty"`
// // private properties of singlestat panel
// // spark line: full or bottom
// SparkLine string `json:"sparkline,omitempty"`
// // Limit the decimal numbers
// Decimals int64 `json:"decimals,omitempty"`
// // Display unit
// Format string `json:"format,omitempty"`
// // gauge
// Gauge *Gauge `json:"gauge,omitempty"`
// // table panel has no private property
// // private properties of text panel
// HTML string `json:"html,omitempty"`
// Markdown string `json:"markdown,omitempty"`
// }
type (
Panel struct {
CommonPanel `json:",inline"`
*GraphPanel `json:",inline"`
// RowPanel *RowPanel `json:",inline"`
*SinglestatPanel `json:",inline"`
*TablePanel `json:",inline"`
*TextPanel `json:",inline"`
*BarGaugePanel `json:",inline"`
// *CustomPanel `json:",inline"`
}
probePanel struct {
CommonPanel
}
// CustomPanel map[string]runtime.RawExtension
)
func (p *Panel) UnmarshalJSON(b []byte) (err error) {
var probe probePanel
if err = json.Unmarshal(b, &probe); err == nil {
p.CommonPanel = probe.CommonPanel
switch probe.Type {
case "graph":
var graph GraphPanel
if err = json.Unmarshal(b, &graph); err == nil {
if !isZero(reflect.ValueOf(graph)) {
p.GraphPanel = &graph
}
}
case "table":
var table TablePanel
if err = json.Unmarshal(b, &table); err == nil {
if !isZero(reflect.ValueOf(table)) {
p.TablePanel = &table
}
}
case "text":
var text TextPanel
if err = json.Unmarshal(b, &text); err == nil {
if !isZero(reflect.ValueOf(text)) {
p.TextPanel = &text
}
}
case "singlestat":
var singlestat SinglestatPanel
if err = json.Unmarshal(b, &singlestat); err == nil {
if !isZero(reflect.ValueOf(singlestat)) {
p.SinglestatPanel = &singlestat
}
}
case "bargauge":
var bargauge BarGaugePanel
if err = json.Unmarshal(b, &bargauge); err == nil {
if !isZero(reflect.ValueOf(bargauge)) {
p.BarGaugePanel = &bargauge
}
}
case "row":
// var row RowPanel
// if err = json.Unmarshal(b, &row); err == nil {
// p.RowPanel = &row
// }
// default:
// var custom = make(CustomPanel)
// if err = json.Unmarshal(b, &custom); err == nil {
// p.CustomPanel = &custom
// }
}
}
return
}
func (p *Panel) MarshalJSON() ([]byte, error) {
var outCommon = struct {
CommonPanel
}{p.CommonPanel}
switch p.Type {
case "graph":
if p.GraphPanel == nil {
return json.Marshal(outCommon)
}
var outGraph = struct {
CommonPanel
GraphPanel
}{p.CommonPanel, *p.GraphPanel}
return json.Marshal(outGraph)
case "table":
if p.TablePanel == nil {
return json.Marshal(outCommon)
}
var outTable = struct {
CommonPanel
TablePanel
}{p.CommonPanel, *p.TablePanel}
return json.Marshal(outTable)
case "text":
if p.TextPanel == nil {
return json.Marshal(outCommon)
}
var outText = struct {
CommonPanel
TextPanel
}{p.CommonPanel, *p.TextPanel}
return json.Marshal(outText)
case "singlestat":
if p.SinglestatPanel == nil {
return json.Marshal(outCommon)
}
var outSinglestat = struct {
CommonPanel
SinglestatPanel
}{p.CommonPanel, *p.SinglestatPanel}
return json.Marshal(outSinglestat)
case "bargauge":
if p.BarGaugePanel == nil {
return json.Marshal(outCommon)
}
var outBarGauge = struct {
CommonPanel
BarGaugePanel
}{p.CommonPanel, *p.BarGaugePanel}
return json.Marshal(outBarGauge)
case "row":
var outRow = struct {
CommonPanel
}{p.CommonPanel}
return json.Marshal(outRow)
// default:
// var outCustom = struct {
// CommonPanel
// CustomPanel
// }{p.CommonPanel, *p.CustomPanel}
// return json.Marshal(outCustom)
}
return nil, errors.New("can't marshal unknown panel type")
}
func isZero(value reflect.Value) bool {
switch value.Kind() {
case reflect.String:
return value.Len() == 0
case reflect.Bool:
return !value.Bool()
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return value.Int() == 0
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return value.Uint() == 0
case reflect.Float32, reflect.Float64:
return value.Float() == 0
case reflect.Interface, reflect.Ptr:
return value.IsNil()
}
return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
}

View File

@@ -0,0 +1,39 @@
// +kubebuilder:object:generate=true
package panels
// Graph visualizes range query results into a linear graph
type GraphPanel struct {
// Display as a bar chart
Bars bool `json:"bars,omitempty"`
// Display as a line chart
Lines bool `json:"lines,omitempty"`
// Display as a stacked chart
Stack bool `json:"stack,omitempty"`
Xaxis Axis `json:"xaxis,omitempty"`
// Y-axis options
Yaxes []Axis `json:"yaxes,omitempty"`
}
type Axis struct {
// Limit the decimal numbers
Decimals int64 `json:"decimals,omitempty"`
// Display unit
Format string `json:"format,omitempty"`
}
// type Legend struct {
// AlignAsTable bool `json:"alignAsTable,omitempty"`
// Avg bool `json:"avg,omitempty"`
// Current bool `json:"current,omitempty" `
// HideEmpty bool `json:"hideEmpty,omitempty"`
// HideZero bool `json:"hideZero,omitempty"`
// Max bool `json:"max,omitempty"`
// Min bool `json:"min,omitempty"`
// RightSide bool `json:"rightSide,omitempty"`
// Show bool `json:"show,omitempty"`
// SideWidth *uint `json:"sideWidth,omitempty"`
// Total bool `json:"total,omitempty"`
// Values bool `json:"values,omitempty"`
// }

View File

@@ -0,0 +1,7 @@
// +kubebuilder:object:generate=true
package panels
// Row groups relevant charts
type RowPanel struct {
}

View File

@@ -0,0 +1,31 @@
// +kubebuilder:object:generate=true
package panels
// SingleStat shows instant query result
type SinglestatPanel struct {
// spark line: full or bottom
SparkLine string `json:"sparkline,omitempty"`
// gauge
Gauge Gauge `json:"gauge,omitempty"`
// value name
ValueName string `json:"valueName,omitempty"`
}
// Gauge for a stat
type Gauge struct {
MaxValue int64 `json:"maxValue,omitempty"`
MinValue int64 `json:"minValue,omitempty"`
Show bool `json:"show,omitempty"`
ThresholdLabels bool `json:"thresholdLabels,omitempty"`
ThresholdMarkers bool `json:"thresholdMarkers,omitempty"`
}
// type SparkLine struct {
// FillColor *string `json:"fillColor,omitempty"`
// Full bool `json:"full,omitempty"`
// LineColor *string `json:"lineColor,omitempty"`
// Show bool `json:"show,omitempty"`
// YMin *float64 `json:"ymin,omitempty"`
// YMax *float64 `json:"ymax,omitempty"`
// }

View File

@@ -0,0 +1,14 @@
// +kubebuilder:object:generate=true
package panels
// a table panel
type TablePanel struct {
Sort *Sort `json:"sort,omitempty"`
Scroll bool `json:"scroll,omitempty"`
}
type Sort struct {
Col int `json:"col,omitempty"`
Desc bool `json:"desc,omitempty"`
}

View File

@@ -0,0 +1,10 @@
// +kubebuilder:object:generate=true
package panels
// dashboard text type
// referers to https://pkg.go.dev/github.com/K-Phoen/grabana/decoder#DashboardText
type TextPanel struct {
Mode string `json:"mode,omitempty"`
Content string `json:"content,omitempty"`
}

View File

@@ -0,0 +1,296 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package panels
import ()
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Axis) DeepCopyInto(out *Axis) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Axis.
func (in *Axis) DeepCopy() *Axis {
if in == nil {
return nil
}
out := new(Axis)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BarGaugeOptions) DeepCopyInto(out *BarGaugeOptions) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarGaugeOptions.
func (in *BarGaugeOptions) DeepCopy() *BarGaugeOptions {
if in == nil {
return nil
}
out := new(BarGaugeOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BarGaugePanel) DeepCopyInto(out *BarGaugePanel) {
*out = *in
if in.Options != nil {
in, out := &in.Options, &out.Options
*out = new(BarGaugeOptions)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarGaugePanel.
func (in *BarGaugePanel) DeepCopy() *BarGaugePanel {
if in == nil {
return nil
}
out := new(BarGaugePanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CommonPanel) DeepCopyInto(out *CommonPanel) {
*out = *in
if in.Description != nil {
in, out := &in.Description, &out.Description
*out = new(string)
**out = **in
}
if in.Datasource != nil {
in, out := &in.Datasource, &out.Datasource
*out = new(string)
**out = **in
}
if in.Height != nil {
in, out := &in.Height, &out.Height
*out = new(string)
**out = **in
}
if in.Decimals != nil {
in, out := &in.Decimals, &out.Decimals
*out = new(int64)
**out = **in
}
if in.Targets != nil {
in, out := &in.Targets, &out.Targets
*out = make([]Target, len(*in))
copy(*out, *in)
}
if in.Colors != nil {
in, out := &in.Colors, &out.Colors
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Legend != nil {
in, out := &in.Legend, &out.Legend
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommonPanel.
func (in *CommonPanel) DeepCopy() *CommonPanel {
if in == nil {
return nil
}
out := new(CommonPanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Gauge) DeepCopyInto(out *Gauge) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Gauge.
func (in *Gauge) DeepCopy() *Gauge {
if in == nil {
return nil
}
out := new(Gauge)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GraphPanel) DeepCopyInto(out *GraphPanel) {
*out = *in
out.Xaxis = in.Xaxis
if in.Yaxes != nil {
in, out := &in.Yaxes, &out.Yaxes
*out = make([]Axis, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GraphPanel.
func (in *GraphPanel) DeepCopy() *GraphPanel {
if in == nil {
return nil
}
out := new(GraphPanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Panel) DeepCopyInto(out *Panel) {
*out = *in
in.CommonPanel.DeepCopyInto(&out.CommonPanel)
if in.GraphPanel != nil {
in, out := &in.GraphPanel, &out.GraphPanel
*out = new(GraphPanel)
(*in).DeepCopyInto(*out)
}
if in.SinglestatPanel != nil {
in, out := &in.SinglestatPanel, &out.SinglestatPanel
*out = new(SinglestatPanel)
**out = **in
}
if in.TablePanel != nil {
in, out := &in.TablePanel, &out.TablePanel
*out = new(TablePanel)
(*in).DeepCopyInto(*out)
}
if in.TextPanel != nil {
in, out := &in.TextPanel, &out.TextPanel
*out = new(TextPanel)
**out = **in
}
if in.BarGaugePanel != nil {
in, out := &in.BarGaugePanel, &out.BarGaugePanel
*out = new(BarGaugePanel)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Panel.
func (in *Panel) DeepCopy() *Panel {
if in == nil {
return nil
}
out := new(Panel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RowPanel) DeepCopyInto(out *RowPanel) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RowPanel.
func (in *RowPanel) DeepCopy() *RowPanel {
if in == nil {
return nil
}
out := new(RowPanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SinglestatPanel) DeepCopyInto(out *SinglestatPanel) {
*out = *in
out.Gauge = in.Gauge
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinglestatPanel.
func (in *SinglestatPanel) DeepCopy() *SinglestatPanel {
if in == nil {
return nil
}
out := new(SinglestatPanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Sort) DeepCopyInto(out *Sort) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sort.
func (in *Sort) DeepCopy() *Sort {
if in == nil {
return nil
}
out := new(Sort)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TablePanel) DeepCopyInto(out *TablePanel) {
*out = *in
if in.Sort != nil {
in, out := &in.Sort, &out.Sort
*out = new(Sort)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TablePanel.
func (in *TablePanel) DeepCopy() *TablePanel {
if in == nil {
return nil
}
out := new(TablePanel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Target) DeepCopyInto(out *Target) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Target.
func (in *Target) DeepCopy() *Target {
if in == nil {
return nil
}
out := new(Target)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TextPanel) DeepCopyInto(out *TextPanel) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TextPanel.
func (in *TextPanel) DeepCopy() *TextPanel {
if in == nil {
return nil
}
out := new(TextPanel)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,109 @@
// +kubebuilder:object:generate=true
package templatings
//referers to https://pkg.go.dev/github.com/K-Phoen/grabana/decoder#DashboardVariable
// type Templatings struct {
// Interval *VariableInterval `json:"interval,omitempty"`
// Custom *VariableCustom `json:"custom,omitempty"`
// Query *VariableQuery `json:"query,omitempty"`
// Const *VariableConst `json:"const,omitempty"`
// Datasource *VariableDatasource `json:"datasource,omitempty"`
// }
// type VariableInterval struct {
// Name string `json:"name,omitempty"`
// Label string `json:"label,omitempty"`
// Default string `json:"default,omitempty"`
// Values []string `json:"values,omitempty,flow"`
// }
// type VariableCustom struct {
// Name string `json:"name,omitempty"`
// Label string `json:"label,omitempty"`
// Default string `json:"default,omitempty"`
// ValuesMap map[string]string `json:"values_map,omitempty"`
// IncludeAll bool `json:"include_all,omitempty"`
// AllValue string `json:"all_value,omitempty"`
// }
// type VariableConst struct {
// Name string `json:"name,omitempty"`
// Label string `json:"label,omitempty"`
// Default string `json:"default,omitempty"`
// ValuesMap map[string]string `json:"values_map,omitempty"`
// }
// type VariableQuery struct {
// Name string `json:"name,omitempty"`
// Label string `json:"label,omitempty"`
// Datasource string `json:"datasource,omitempty"`
// Request string `json:"request,omitempty"`
// Regex string `json:"regex,omitempty"`
// IncludeAll bool `json:"include_all,omitempty"`
// DefaultAll bool `json:"default_all,omitempty"`
// AllValue string `json:"all_value,omitempty"`
// }
// type VariableDatasource struct {
// Name string `json:"name,omitempty"`
// Label string `json:"label,omitempty"`
// Query string `json:"query,omitempty"`
// Regex string `json:"regex,omitempty"`
// IncludeAll bool `json:"include_all,omitempty"`
// }
// type TemplateVar struct {
// // common properties, more than one containing
// Name string `json:"name,omitempty"`
// Type string `json:"type,omitempty"`
// Auto bool `json:"auto,omitempty"`
// AutoCount *int `json:"auto_count,omitempty"`
// Label string `json:"label,omitempty"`
// Default string `json:"default,omitempty"`
// ValuesMap map[string]string `json:"values_map,omitempty"`
// IncludeAll bool `json:"include_all,omitempty"`
// AllValue string `json:"all_value,omitempty"`
// Regex string `json:"regex,omitempty"`
// // from type VariableInterval
// Values []string `json:"values,omitempty,flow"`
// // type VariableCustom has no special field
// // type VariableConst has no special field
// // from type VariableQuery
// Datasource string `json:"datasource,omitempty"`
// Request string `json:"request,omitempty"`
// DefaultAll bool `json:"default_all,omitempty"`
// // from type VariableDatasource
// Query string `json:"query,omitempty"`
// }
// Refers to https://pkg.go.dev/github.com/grafana-tools/sdk#Templating
//TemplateVar combines above types to one struct
type TemplateVar struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Auto bool `json:"auto,omitempty"`
AutoCount *int `json:"auto_count,omitempty"`
Datasource *string `json:"datasource,omitempty"`
Options []Option `json:"options,omitempty"`
IncludeAll bool `json:"includeAll,omitempty"`
AllFormat string `json:"allFormat,omitempty"`
AllValue string `json:"allValue,omitempty"`
Multi bool `json:"multi,omitempty"`
MultiFormat string `json:"multiFormat,omitempty"`
Query string `json:"query,omitempty"`
Regex string `json:"regex,omitempty"`
Label string `json:"label,omitempty"`
Hide uint8 `json:"hide,omitempty"`
Sort int `json:"sort,omitempty"`
}
type Option struct {
Text string `json:"text,omitempty"`
Value string `json:"value,omitempty"`
Selected bool `json:"selected,omitempty"`
}

View File

@@ -0,0 +1,68 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package templatings
import ()
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Option) DeepCopyInto(out *Option) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Option.
func (in *Option) DeepCopy() *Option {
if in == nil {
return nil
}
out := new(Option)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TemplateVar) DeepCopyInto(out *TemplateVar) {
*out = *in
if in.AutoCount != nil {
in, out := &in.AutoCount, &out.AutoCount
*out = new(int)
**out = **in
}
if in.Datasource != nil {
in, out := &in.Datasource, &out.Datasource
*out = new(string)
**out = **in
}
if in.Options != nil {
in, out := &in.Options, &out.Options
*out = make([]Option, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateVar.
func (in *TemplateVar) DeepCopy() *TemplateVar {
if in == nil {
return nil
}
out := new(TemplateVar)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,13 @@
// +kubebuilder:object:generate=true
package time
// Time ranges of the metrics for display
type Time struct {
// Start time in the format of `^now([+-][0-9]+[smhdwMy])?$`, eg. `now-1M`.
// It denotes the end time is set to the last month since now.
From string `json:"from,omitempty" json:"from,omitempty"`
// End time in the format of `^now([+-][0-9]+[smhdwMy])?$`, eg. `now-1M`.
// It denotes the start time is set to the last month since now.
To string `json:"to,omitempty" json:"to,omitempty"`
}

View File

@@ -0,0 +1,38 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package time
import ()
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Time) DeepCopyInto(out *Time) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Time.
func (in *Time) DeepCopy() *Time {
if in == nil {
return nil
}
out := new(Time)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,190 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by controller-gen. DO NOT EDIT.
package v1alpha2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
annotations "kubesphere.io/monitoring-dashboard/api/v1alpha2/annotations"
"kubesphere.io/monitoring-dashboard/api/v1alpha2/panels"
"kubesphere.io/monitoring-dashboard/api/v1alpha2/templatings"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterDashboard) DeepCopyInto(out *ClusterDashboard) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterDashboard.
func (in *ClusterDashboard) DeepCopy() *ClusterDashboard {
if in == nil {
return nil
}
out := new(ClusterDashboard)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterDashboard) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterDashboardList) DeepCopyInto(out *ClusterDashboardList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ClusterDashboard, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterDashboardList.
func (in *ClusterDashboardList) DeepCopy() *ClusterDashboardList {
if in == nil {
return nil
}
out := new(ClusterDashboardList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterDashboardList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Dashboard) DeepCopyInto(out *Dashboard) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dashboard.
func (in *Dashboard) DeepCopy() *Dashboard {
if in == nil {
return nil
}
out := new(Dashboard)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Dashboard) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DashboardList) DeepCopyInto(out *DashboardList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Dashboard, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardList.
func (in *DashboardList) DeepCopy() *DashboardList {
if in == nil {
return nil
}
out := new(DashboardList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *DashboardList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DashboardSpec) DeepCopyInto(out *DashboardSpec) {
*out = *in
if in.Tags != nil {
in, out := &in.Tags, &out.Tags
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Annotations != nil {
in, out := &in.Annotations, &out.Annotations
*out = make([]annotations.Annotation, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
out.Time = in.Time
if in.Panels != nil {
in, out := &in.Panels, &out.Panels
*out = make([]*panels.Panel, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(panels.Panel)
(*in).DeepCopyInto(*out)
}
}
}
if in.Templatings != nil {
in, out := &in.Templatings, &out.Templatings
*out = make([]templatings.TemplateVar, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardSpec.
func (in *DashboardSpec) DeepCopy() *DashboardSpec {
if in == nil {
return nil
}
out := new(DashboardSpec)
in.DeepCopyInto(out)
return out
}