Skip to content

Commit 603067f

Browse files
committed
crd: add inspectionOverrides to the ProjectSpec
1 parent cd9fc60 commit 603067f

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

api/v1/common.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package v1
22

33
import (
4+
"encoding/json"
5+
"strconv"
6+
47
corev1 "k8s.io/api/core/v1"
58
"k8s.io/apimachinery/pkg/api/resource"
69
)
@@ -50,3 +53,26 @@ type HeaderSpec struct {
5053
Key string `json:"key" yaml:"key"`
5154
Value string `json:"value" yaml:"value"`
5255
}
56+
57+
// Percent represents a percentage value between 0 and 100 (inclusive).
58+
// +kubebuilder:validation:Type=number
59+
// +kubebuilder:validation:Minimum=0
60+
// +kubebuilder:validation:Maximum=100
61+
type Percent string
62+
63+
func (p *Percent) UnmarshalJSON(b []byte) error {
64+
var v float32
65+
if err := json.Unmarshal(b, &v); err != nil {
66+
return err
67+
}
68+
*p = Percent(strconv.FormatFloat(float64(v), 'f', -1, 32))
69+
return nil
70+
}
71+
72+
func (p Percent) MarshalJSON() ([]byte, error) {
73+
_, err := strconv.ParseFloat(string(p), 32)
74+
if err != nil {
75+
return nil, err
76+
}
77+
return []byte(string(p)), nil
78+
}

api/v1/config.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v1
22

33
import (
44
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
56
)
67

78
type SSOSpec struct {
@@ -71,6 +72,8 @@ type ProjectSpec struct {
7172
ApplicationCategories []ApplicationCategorySpec `json:"applicationCategories,omitempty"`
7273
// Custom applications.
7374
CustomApplications []CustomApplicationSpec `json:"customApplications,omitempty"`
75+
// Inspection overrides.
76+
InspectionOverrides *InspectionOverrides `json:"inspectionOverrides,omitempty"`
7477
}
7578

7679
type ApiKeySpec struct {
@@ -221,3 +224,29 @@ type CustomApplicationSpec struct {
221224
// List of glob patterns for <instance_name>.
222225
InstancePatterns []string `json:"instancePatterns,omitempty"`
223226
}
227+
228+
type InspectionOverrides struct {
229+
// SLO Availability overrides.
230+
SLOAvailability []SLOAvailabilityOverride `json:"sloAvailability,omitempty"`
231+
// SLO Latency overrides.
232+
SLOLatency []SLOLatencyOverride `json:"sloLatency,omitempty"`
233+
}
234+
235+
type SLOAvailabilityOverride struct {
236+
// ApplicationId in the format <namespace>:<kind>:<name> (e.g., default:Deployment:catalog).
237+
// +kubebuilder:validation:Pattern="^[^:]*:[^:]*:[^:]*"
238+
ApplicationId string `json:"applicationId"`
239+
// The percentage of requests that should be served without errors (e.g., 95, 99, 99.9).
240+
ObjectivePercent Percent `json:"objectivePercent"`
241+
}
242+
243+
type SLOLatencyOverride struct {
244+
// ApplicationId in the format <namespace>:<kind>:<name> (e.g., default:Deployment:catalog).
245+
// +kubebuilder:validation:Pattern="^[^:]*:[^:]*:[^:]*"
246+
ApplicationId string `json:"applicationId"`
247+
// The percentage of requests that should be served faster than ObjectiveThreshold (e.g., 95, 99, 99.9).
248+
ObjectivePercent Percent `json:"objectivePercent"`
249+
// The latency threshold (e.g., 5ms, 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s).
250+
// +kubebuilder:validation:Enum="5ms";"10ms";"25ms";"50ms";"100ms";"250ms";"500ms";"1s";"2.5s";"5s";"10s"
251+
ObjectiveThreshold metav1.Duration `json:"objectiveThreshold"`
252+
}

api/v1/zz_generated.deepcopy.go

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/coroot.com_coroots.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6465,6 +6465,68 @@ spec:
64656465
- name
64666466
type: object
64676467
type: array
6468+
inspectionOverrides:
6469+
description: Inspection overrides.
6470+
properties:
6471+
sloAvailability:
6472+
description: SLO Availability overrides.
6473+
items:
6474+
properties:
6475+
applicationId:
6476+
description: ApplicationId in the format <namespace>:<kind>:<name>
6477+
(e.g., default:Deployment:catalog).
6478+
pattern: ^[^:]*:[^:]*:[^:]*
6479+
type: string
6480+
objectivePercent:
6481+
description: The percentage of requests that should
6482+
be served without errors (e.g., 95, 99, 99.9).
6483+
maximum: 100
6484+
minimum: 0
6485+
type: number
6486+
required:
6487+
- applicationId
6488+
- objectivePercent
6489+
type: object
6490+
type: array
6491+
sloLatency:
6492+
description: SLO Latency overrides.
6493+
items:
6494+
properties:
6495+
applicationId:
6496+
description: ApplicationId in the format <namespace>:<kind>:<name>
6497+
(e.g., default:Deployment:catalog).
6498+
pattern: ^[^:]*:[^:]*:[^:]*
6499+
type: string
6500+
objectivePercent:
6501+
description: The percentage of requests that should
6502+
be served faster than ObjectiveThreshold (e.g.,
6503+
95, 99, 99.9).
6504+
maximum: 100
6505+
minimum: 0
6506+
type: number
6507+
objectiveThreshold:
6508+
description: The latency threshold (e.g., 5ms, 10ms,
6509+
25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s).
6510+
enum:
6511+
- 5ms
6512+
- 10ms
6513+
- 25ms
6514+
- 50ms
6515+
- 100ms
6516+
- 250ms
6517+
- 500ms
6518+
- 1s
6519+
- 2.5s
6520+
- 5s
6521+
- 10s
6522+
type: string
6523+
required:
6524+
- applicationId
6525+
- objectivePercent
6526+
- objectiveThreshold
6527+
type: object
6528+
type: array
6529+
type: object
64686530
name:
64696531
description: Project name (e.g., production, staging; required).
64706532
type: string

0 commit comments

Comments
 (0)