Skip to content

Commit

Permalink
feat(metrics-operator): add AnalysisValueTemplate CRD (#1822)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
  • Loading branch information
bacherfl committed Aug 9, 2023
1 parent 9521a16 commit f25b24d
Show file tree
Hide file tree
Showing 13 changed files with 436 additions and 2 deletions.
52 changes: 52 additions & 0 deletions docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Package v1alpha3 contains API Schema definitions for the metrics v1alpha3 API gr
- [AnalysisDefinition](#analysisdefinition)
- [AnalysisDefinitionList](#analysisdefinitionlist)
- [AnalysisList](#analysislist)
- [AnalysisValueTemplate](#analysisvaluetemplate)
- [AnalysisValueTemplateList](#analysisvaluetemplatelist)
- [KeptnMetric](#keptnmetric)
- [KeptnMetricList](#keptnmetriclist)
- [KeptnMetricsProvider](#keptnmetricsprovider)
Expand Down Expand Up @@ -123,6 +125,55 @@ _Appears in:_
| `analysisDefinition` _[ObjectReference](#objectreference)_ | AnalysisDefinition refers to the AnalysisDefinition, a CRD that stores the AnalysisValuesTemplates |


#### AnalysisValueTemplate



AnalysisValueTemplate is the Schema for the analysisvaluetemplates API

_Appears in:_
- [AnalysisValueTemplateList](#analysisvaluetemplatelist)

| Field | Description |
| --- | --- |
| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3`
| `kind` _string_ | `AnalysisValueTemplate`
| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. |
| `spec` _[AnalysisValueTemplateSpec](#analysisvaluetemplatespec)_ | Spec contains the specification for the AnalysisValueTemplate |
| `status` _string_ | unused field |


#### AnalysisValueTemplateList



AnalysisValueTemplateList contains a list of AnalysisValueTemplate



| Field | Description |
| --- | --- |
| `apiVersion` _string_ | `metrics.keptn.sh/v1alpha3`
| `kind` _string_ | `AnalysisValueTemplateList`
| `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. |
| `items` _[AnalysisValueTemplate](#analysisvaluetemplate) array_ | |


#### AnalysisValueTemplateSpec



AnalysisValueTemplateSpec defines the desired state of AnalysisValueTemplate

_Appears in:_
- [AnalysisValueTemplate](#analysisvaluetemplate)

| Field | Description |
| --- | --- |
| `provider` _[ObjectReference](#objectreference)_ | Provider refers to the KeptnMetricsProvider which should be used to retrieve the data |
| `query` _string_ | Query represents the query to be run. It can include placeholders that are defined using the go template syntax. More info on go templating - https://pkg.go.dev/text/template |


#### KeptnMetric


Expand Down Expand Up @@ -249,6 +300,7 @@ _Appears in:_

_Appears in:_
- [AnalysisSpec](#analysisspec)
- [AnalysisValueTemplateSpec](#analysisvaluetemplatespec)
- [Objective](#objective)

| Field | Description |
Expand Down
77 changes: 77 additions & 0 deletions helm/chart/templates/analysisvaluetemplate-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: analysisvaluetemplates.metrics.keptn.sh
annotations:
controller-gen.kubebuilder.io/version: v0.12.1
labels:
app.kubernetes.io/part-of: keptn-lifecycle-toolkit
crdGroup: metrics.keptn.sh
keptn.sh/inject-cert: "true"
{{- include "chart.labels" . | nindent 4 }}
spec:
group: metrics.keptn.sh
names:
kind: AnalysisValueTemplate
listKind: AnalysisValueTemplateList
plural: analysisvaluetemplates
singular: analysisvaluetemplate
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.provider.name
name: Provider
type: string
name: v1alpha3
schema:
openAPIV3Schema:
description: AnalysisValueTemplate is the Schema for the analysisvaluetemplates
API
properties:
apiVersion:
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/sig-architecture/api-conventions.md#resources'
type: string
kind:
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/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec contains the specification for the AnalysisValueTemplate
properties:
provider:
description: Provider refers to the KeptnMetricsProvider which should
be used to retrieve the data
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
required:
- name
type: object
query:
description: Query represents the query to be run. It can include
placeholders that are defined using the go template syntax. More
info on go templating - https://pkg.go.dev/text/template
type: string
required:
- provider
- query
type: object
status:
description: unused field
type: string
type: object
served: true
storage: true
subresources:
status: {}
8 changes: 8 additions & 0 deletions metrics-operator/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ resources:
kind: Analysis
path: github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3
version: v1alpha3
- api:
crdVersion: v1
namespaced: true
domain: keptn.sh
group: metrics
kind: AnalysisValueTemplate
path: github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3
version: v1alpha3
version: "3"
58 changes: 58 additions & 0 deletions metrics-operator/api/v1alpha3/analysisvaluetemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2023.
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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AnalysisValueTemplateSpec defines the desired state of AnalysisValueTemplate
type AnalysisValueTemplateSpec struct {
// Provider refers to the KeptnMetricsProvider which should be used to retrieve the data
Provider ObjectReference `json:"provider"`
// Query represents the query to be run. It can include placeholders that are defined using the go template
// syntax. More info on go templating - https://pkg.go.dev/text/template
Query string `json:"query"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Provider",type=string,JSONPath=`.spec.provider.name`

// AnalysisValueTemplate is the Schema for the analysisvaluetemplates API
type AnalysisValueTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec contains the specification for the AnalysisValueTemplate
Spec AnalysisValueTemplateSpec `json:"spec,omitempty"`
// unused field
Status string `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// AnalysisValueTemplateList contains a list of AnalysisValueTemplate
type AnalysisValueTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AnalysisValueTemplate `json:"items"`
}

func init() {
SchemeBuilder.Register(&AnalysisValueTemplate{}, &AnalysisValueTemplateList{})
}
74 changes: 74 additions & 0 deletions metrics-operator/api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.1
name: analysisvaluetemplates.metrics.keptn.sh
spec:
group: metrics.keptn.sh
names:
kind: AnalysisValueTemplate
listKind: AnalysisValueTemplateList
plural: analysisvaluetemplates
singular: analysisvaluetemplate
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.provider.name
name: Provider
type: string
name: v1alpha3
schema:
openAPIV3Schema:
description: AnalysisValueTemplate is the Schema for the analysisvaluetemplates
API
properties:
apiVersion:
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/sig-architecture/api-conventions.md#resources'
type: string
kind:
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/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec contains the specification for the AnalysisValueTemplate
properties:
provider:
description: Provider refers to the KeptnMetricsProvider which should
be used to retrieve the data
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
required:
- name
type: object
query:
description: Query represents the query to be run. It can include
placeholders that are defined using the go template syntax. More
info on go templating - https://pkg.go.dev/text/template
type: string
required:
- provider
- query
type: object
status:
description: unused field
type: string
type: object
served: true
storage: true
subresources:
status: {}
Loading

0 comments on commit f25b24d

Please sign in to comment.