From f2d37cb632bb1706f3e223776e72e50253d4025c Mon Sep 17 00:00:00 2001 From: Srivahni Date: Fri, 23 Aug 2019 11:19:26 -0700 Subject: visualization operator: Add datasource Added support to create a grafana datasource dynamically using GrafanaDataSource CR. Issue-ID: ONAPARC-393 Signed-off-by: Srivahni Change-Id: Iaa645c5c4f303afbcec114c00e35cd6e6ae6c98c --- .../pkg/apis/onap/v1alpha1/doc.go | 4 + .../apis/onap/v1alpha1/grafanadatasource_types.go | 68 +++++++ .../pkg/apis/onap/v1alpha1/register.go | 19 ++ .../apis/onap/v1alpha1/zz_generated.deepcopy.go | 139 +++++++++++++ .../pkg/apis/onap/v1alpha1/zz_generated.openapi.go | 220 +++++++++++++++++++++ 5 files changed, 450 insertions(+) create mode 100644 vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/doc.go create mode 100644 vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/grafanadatasource_types.go create mode 100644 vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/register.go create mode 100644 vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go create mode 100644 vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go (limited to 'vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1') diff --git a/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/doc.go b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/doc.go new file mode 100644 index 00000000..29b3493e --- /dev/null +++ b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/doc.go @@ -0,0 +1,4 @@ +// Package v1alpha1 contains API Schema definitions for the onap v1alpha1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=onap.org +package v1alpha1 diff --git a/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/grafanadatasource_types.go b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/grafanadatasource_types.go new file mode 100644 index 00000000..60820067 --- /dev/null +++ b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/grafanadatasource_types.go @@ -0,0 +1,68 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// GrafanaDataSourceSpec defines the desired state of GrafanaDataSource +// +k8s:openapi-gen=true +type GrafanaDataSourceSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file + // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html + Datasources []Datasource `json:"datasources"` + Grafana map[string]string `json:"grafana"` +} + +// GrafanaDataSourceStatus defines the observed state of GrafanaDataSource +// +k8s:openapi-gen=true +type GrafanaDataSourceStatus struct { +} + +// Datasource defines the fields in a GrafanaDataSource +// +k8s:openapi-gen=true +type Datasource struct { + Name string `json:"name"` + Type string `json:"type"` + URL string `json:"url"` + IsDefault bool `json:"isDefault,omitempty"` + Access string `json:"access"` + WithCredentials bool `json:"withCredentials,omitempty"` + BasicAuth bool `json:"basicAuth,omitempty"` + BasicAuthUser string `json:"basicAuthUser,omitempty"` + BasicAuthPassword string `json:"basicAuthPassword,omitempty"` + JsonData map[string]string `json:"jsonData,omitempty"` + Database string `json:"database,omitempty"` + User string `json:"user,omitempty"` + Password string `json:"password,omitempty"` + ReadOnly bool `json:"readOnly,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GrafanaDataSource is the Schema for the grafanadatasources API +// +k8s:openapi-gen=true +// +kubebuilder:subresource:status +type GrafanaDataSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec GrafanaDataSourceSpec `json:"spec,omitempty"` + Status GrafanaDataSourceStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GrafanaDataSourceList contains a list of GrafanaDataSource +type GrafanaDataSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []GrafanaDataSource `json:"items"` +} + +func init() { + SchemeBuilder.Register(&GrafanaDataSource{}, &GrafanaDataSourceList{}) +} diff --git a/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/register.go b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/register.go new file mode 100644 index 00000000..c670eea4 --- /dev/null +++ b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/register.go @@ -0,0 +1,19 @@ +// NOTE: Boilerplate only. Ignore this file. + +// Package v1alpha1 contains API Schema definitions for the onap v1alpha1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=onap.org +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/runtime/scheme" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "onap.org", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} +) diff --git a/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..2cc830ba --- /dev/null +++ b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,139 @@ +// +build !ignore_autogenerated + +// Code generated by operator-sdk. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Datasource) DeepCopyInto(out *Datasource) { + *out = *in + if in.JsonData != nil { + in, out := &in.JsonData, &out.JsonData + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Datasource. +func (in *Datasource) DeepCopy() *Datasource { + if in == nil { + return nil + } + out := new(Datasource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GrafanaDataSource) DeepCopyInto(out *GrafanaDataSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaDataSource. +func (in *GrafanaDataSource) DeepCopy() *GrafanaDataSource { + if in == nil { + return nil + } + out := new(GrafanaDataSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GrafanaDataSource) 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 *GrafanaDataSourceList) DeepCopyInto(out *GrafanaDataSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]GrafanaDataSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaDataSourceList. +func (in *GrafanaDataSourceList) DeepCopy() *GrafanaDataSourceList { + if in == nil { + return nil + } + out := new(GrafanaDataSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GrafanaDataSourceList) 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 *GrafanaDataSourceSpec) DeepCopyInto(out *GrafanaDataSourceSpec) { + *out = *in + if in.Datasources != nil { + in, out := &in.Datasources, &out.Datasources + *out = make([]Datasource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Grafana != nil { + in, out := &in.Grafana, &out.Grafana + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaDataSourceSpec. +func (in *GrafanaDataSourceSpec) DeepCopy() *GrafanaDataSourceSpec { + if in == nil { + return nil + } + out := new(GrafanaDataSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GrafanaDataSourceStatus) DeepCopyInto(out *GrafanaDataSourceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrafanaDataSourceStatus. +func (in *GrafanaDataSourceStatus) DeepCopy() *GrafanaDataSourceStatus { + if in == nil { + return nil + } + out := new(GrafanaDataSourceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go new file mode 100644 index 00000000..7f74f2f7 --- /dev/null +++ b/vnfs/DAaaS/microservices/visualization-operator/pkg/apis/onap/v1alpha1/zz_generated.openapi.go @@ -0,0 +1,220 @@ +// +build ! + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package v1alpha1 + +import ( + spec "github.com/go-openapi/spec" + common "k8s.io/kube-openapi/pkg/common" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "./pkg/apis/onap/v1alpha1.Datasource": schema_pkg_apis_onap_v1alpha1_Datasource(ref), + "./pkg/apis/onap/v1alpha1.GrafanaDataSource": schema_pkg_apis_onap_v1alpha1_GrafanaDataSource(ref), + "./pkg/apis/onap/v1alpha1.GrafanaDataSourceSpec": schema_pkg_apis_onap_v1alpha1_GrafanaDataSourceSpec(ref), + "./pkg/apis/onap/v1alpha1.GrafanaDataSourceStatus": schema_pkg_apis_onap_v1alpha1_GrafanaDataSourceStatus(ref), + } +} + +func schema_pkg_apis_onap_v1alpha1_Datasource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Datasource defines the fields in a GrafanaDataSource", + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "url": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "isDefault": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "access": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "withCredentials": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "basicAuth": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + "basicAuthUser": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "basicAuthPassword": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "jsonData": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "database": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "user": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "password": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "readOnly": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"name", "type", "url", "access"}, + }, + }, + Dependencies: []string{}, + } +} + +func schema_pkg_apis_onap_v1alpha1_GrafanaDataSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GrafanaDataSource is the Schema for the grafanadatasources API", + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Ref: ref("./pkg/apis/onap/v1alpha1.GrafanaDataSourceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Ref: ref("./pkg/apis/onap/v1alpha1.GrafanaDataSourceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "./pkg/apis/onap/v1alpha1.GrafanaDataSourceSpec", "./pkg/apis/onap/v1alpha1.GrafanaDataSourceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_pkg_apis_onap_v1alpha1_GrafanaDataSourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GrafanaDataSourceSpec defines the desired state of GrafanaDataSource", + Properties: map[string]spec.Schema{ + "datasources": { + SchemaProps: spec.SchemaProps{ + Description: "INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run \"operator-sdk generate k8s\" to regenerate code after modifying this file Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("./pkg/apis/onap/v1alpha1.Datasource"), + }, + }, + }, + }, + }, + "grafana": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"datasources", "grafana"}, + }, + }, + Dependencies: []string{ + "./pkg/apis/onap/v1alpha1.Datasource"}, + } +} + +func schema_pkg_apis_onap_v1alpha1_GrafanaDataSourceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GrafanaDataSourceStatus defines the observed state of GrafanaDataSource", + Properties: map[string]spec.Schema{}, + }, + }, + Dependencies: []string{}, + } +} -- cgit 1.2.3-korg