Skip to content

Commit 8667797

Browse files
committed
crd: add corootCloud integration spec
1 parent a240f1d commit 8667797

File tree

5 files changed

+123
-6
lines changed

5 files changed

+123
-6
lines changed

api/v1/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
66
)
77

8+
type CorootCloudSpec struct {
9+
// Coroot Cloud API key. Can be obtained from the UI after connecting to Coroot Cloud.
10+
APIKey string `json:"apiKey,omitempty"`
11+
// Secret containing the API key.
12+
APIKeySecret *corev1.SecretKeySelector `json:"apiKeySecret,omitempty"`
13+
// Root Cause Analysis (RCA) configuration.
14+
RCA *CorootCloudRCASpec `json:"rca,omitempty"`
15+
}
16+
17+
type CorootCloudRCASpec struct {
18+
// If true, incidents will not be investigated automatically.
19+
DisableIncidentsAutoInvestigation bool `json:"disableIncidentsAutoInvestigation,omitempty"`
20+
}
21+
822
type SSOSpec struct {
923
Enabled bool `json:"enabled,omitempty"`
1024
// Default role for authenticated users (Admin, Editor, Viewer, or a custom role).

api/v1/coroot_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ type CorootSpec struct {
272272
// Store configuration in a Postgres DB instead of SQLite (required if replicas > 1).
273273
Postgres *PostgresSpec `json:"postgres,omitempty"`
274274

275+
// Coroot Cloud integration.
276+
CorootCloud *CorootCloudSpec `json:"corootCloud,omitempty"`
275277
// Projects configuration (Coroot will create or update the specified projects).
276278
Projects []ProjectSpec `json:"projects,omitempty"`
277279
// Single Sign-On configuration (Coroot Enterprise Edition only).

api/v1/zz_generated.deepcopy.go

Lines changed: 45 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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4636,6 +4636,45 @@ spec:
46364636
type: array
46374637
type: object
46384638
type: object
4639+
corootCloud:
4640+
description: Coroot Cloud integration.
4641+
properties:
4642+
apiKey:
4643+
description: Coroot Cloud API key. Can be obtained from the UI
4644+
after connecting to Coroot Cloud.
4645+
type: string
4646+
apiKeySecret:
4647+
description: Secret containing the API key.
4648+
properties:
4649+
key:
4650+
description: The key of the secret to select from. Must be
4651+
a valid secret key.
4652+
type: string
4653+
name:
4654+
default: ""
4655+
description: |-
4656+
Name of the referent.
4657+
This field is effectively required, but due to backwards compatibility is
4658+
allowed to be empty. Instances of this type with an empty value here are
4659+
almost certainly wrong.
4660+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
4661+
type: string
4662+
optional:
4663+
description: Specify whether the Secret or its key must be
4664+
defined
4665+
type: boolean
4666+
required:
4667+
- key
4668+
type: object
4669+
x-kubernetes-map-type: atomic
4670+
rca:
4671+
description: Root Cause Analysis (RCA) configuration.
4672+
properties:
4673+
disableIncidentsAutoInvestigation:
4674+
description: If true, incidents will not be investigated automatically.
4675+
type: boolean
4676+
type: object
4677+
type: object
46394678
enterpriseEdition:
46404679
description: Configurations for Coroot Enterprise Edition.
46414680
properties:

controller/coroot.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ func (r *CorootReconciler) validateCoroot(ctx context.Context, cr *corootv1.Coro
4848
}
4949
}
5050

51+
if cc := cr.Spec.CorootCloud; cc != nil {
52+
if cc.APIKeySecret != nil {
53+
if _, err = r.GetSecret(ctx, cr, cc.APIKeySecret); err != nil {
54+
logErr("Failed to get Coroot Cloud API Key: %s", err.Error())
55+
} else {
56+
cc.APIKey = configEnvs.Add(cc.APIKeySecret)
57+
}
58+
cc.APIKeySecret = nil
59+
}
60+
if cc.APIKey == "" {
61+
logErr("Coroot Cloud API key is required.")
62+
cr.Spec.CorootCloud = nil
63+
}
64+
}
65+
5166
apiKeySecrets := map[string][]string{}
5267
for _, p := range cr.Spec.Projects {
5368
for i, k := range p.ApiKeys {
@@ -549,13 +564,15 @@ func (r *CorootReconciler) corootConfigMap(ctx context.Context, cr *corootv1.Cor
549564
}
550565

551566
var cfg = struct {
552-
Projects []corootv1.ProjectSpec `json:"projects,omitempty"`
553-
SSO *corootv1.SSOSpec `json:"sso,omitempty"`
554-
AI *corootv1.AISpec `json:"ai,omitempty"`
567+
Projects []corootv1.ProjectSpec `json:"projects,omitempty"`
568+
SSO *corootv1.SSOSpec `json:"sso,omitempty"`
569+
AI *corootv1.AISpec `json:"ai,omitempty"`
570+
CorootCloud *corootv1.CorootCloudSpec `json:"corootCloud,omitempty"`
555571
}{
556-
Projects: cr.Spec.Projects,
557-
SSO: cr.Spec.SSO,
558-
AI: cr.Spec.AI,
572+
Projects: cr.Spec.Projects,
573+
SSO: cr.Spec.SSO,
574+
AI: cr.Spec.AI,
575+
CorootCloud: cr.Spec.CorootCloud,
559576
}
560577

561578
data, err := yaml.Marshal(cfg)

0 commit comments

Comments
 (0)