/
indexers.go
59 lines (53 loc) · 1.41 KB
/
indexers.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
*/
package controllers
import (
"sigs.k8s.io/controller-runtime/pkg/client"
mysql "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1"
postgresql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1"
azuresql "github.com/Azure/azure-service-operator/v2/api/sql/v1"
)
// indexMySQLUserPassword an index function for mysql user passwords
func indexMySQLUserPassword(rawObj client.Object) []string {
obj, ok := rawObj.(*mysql.User)
if !ok {
return nil
}
if obj.Spec.LocalUser == nil {
return nil
}
if obj.Spec.LocalUser.Password == nil {
return nil
}
return []string{obj.Spec.LocalUser.Password.Name}
}
// indexPostgreSQLUserPassword an index function for postgresql user passwords
func indexPostgreSQLUserPassword(rawObj client.Object) []string {
obj, ok := rawObj.(*postgresql.User)
if !ok {
return nil
}
if obj.Spec.LocalUser == nil {
return nil
}
if obj.Spec.LocalUser.Password == nil {
return nil
}
return []string{obj.Spec.LocalUser.Password.Name}
}
// indexAzureSQLUserPassword an index function for azure sql user passwords
func indexAzureSQLUserPassword(rawObj client.Object) []string {
obj, ok := rawObj.(*azuresql.User)
if !ok {
return nil
}
if obj.Spec.LocalUser == nil {
return nil
}
if obj.Spec.LocalUser.Password == nil {
return nil
}
return []string{obj.Spec.LocalUser.Password.Name}
}