-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinfluxdb.go
41 lines (33 loc) · 1.15 KB
/
influxdb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package aiven
import (
"fmt"
aiven_nais_io_v1 "github.com/nais/liberator/pkg/apis/aiven.nais.io/v1"
nais_io_v1 "github.com/nais/liberator/pkg/apis/nais.io/v1"
"github.com/nais/naiserator/pkg/resourcecreator/resource"
corev1 "k8s.io/api/core/v1"
)
func Influx(ast *resource.Ast, influx *nais_io_v1.Influx, aivenApp *aiven_nais_io_v1.AivenApplication, credentialsEnabled bool) (bool, error) {
if influx == nil {
return false, nil
}
if credentialsEnabled {
if influx.Instance == "" {
return false, fmt.Errorf("NAISERATOR-1578: Influx enabled, but no instance specified")
}
addInfluxEnvVariables(ast, aivenApp.Spec.SecretName)
aivenApp.Spec.InfluxDB = &aiven_nais_io_v1.InfluxDBSpec{
Instance: influx.Instance,
}
}
ast.Labels["aiven"] = "enabled"
return credentialsEnabled, nil
}
func addInfluxEnvVariables(ast *resource.Ast, secretName string) {
// Add environment variables for string data
ast.Env = append(ast.Env, []corev1.EnvVar{
makeSecretEnvVar("INFLUXDB_USERNAME", secretName),
makeSecretEnvVar("INFLUXDB_PASSWORD", secretName),
makeSecretEnvVar("INFLUXDB_URI", secretName),
makeSecretEnvVar("INFLUXDB_NAME", secretName),
}...)
}