-
Notifications
You must be signed in to change notification settings - Fork 16
/
config.go
94 lines (83 loc) · 3.67 KB
/
config.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package mapper
import (
"github.com/crossplane-contrib/provider-keycloak/config/common"
"github.com/crossplane/upjet/pkg/config"
ujconfig "github.com/crossplane/upjet/pkg/config"
)
// Group is the short group name for the resources in this package
var Group = "mapper"
// Configure configures individual resources by adding custom ResourceConfigurators.
func Configure(p *ujconfig.Provider) {
//p.AddResourceConfigurator("keycloak_generic_protocol_mapper", func(r *ujconfig.Resource) {
// r.ShortGroup = Group
// r.Name = "keycloak_generic_protocol_mapper"
// r.Kind = "OpenIdProtocolMapper"
// r.References["client_scope_id"] = ujconfig.Reference{
// Type: "github.com/crossplane-contrib/provider-keycloak/apis/openid/v1alpha1.ClientScope",
// }
//})
//p.AddResourceConfigurator("keycloak_generic_protocol_mapper", func(r *ujconfig.Resource) {
// r.ShortGroup = Group
// r.Name = "keycloak_generic_protocol_mapper"
// r.Kind = "SamlProtocolMapper"
// r.References["client_scope_id"] = ujconfig.Reference{
// Type: "github.com/crossplane-contrib/provider-keycloak/apis/saml/v1alpha1.ClientScope",
// }
//})
// Configure keycloak_generic_protocol_mapper for OpenIdProtocolMapper
openIdConfigurator := ujconfig.ResourceConfiguratorFn(func(r *ujconfig.Resource) {
r.ShortGroup = Group
r.Name = "keycloak_generic_protocol_mapper"
r.Kind = "OpenIdProtocolMapper"
r.References["client_scope_id"] = ujconfig.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/openid/v1alpha1.ClientScope",
}
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.OpenIdClient",
Extractor: common.PathUUIDExtractor,
}
})
// Configure keycloak_generic_protocol_mapper for SamlProtocolMapper
samlConfigurator := ujconfig.ResourceConfiguratorFn(func(r *ujconfig.Resource) {
r.ShortGroup = Group
r.Name = "keycloak_generic_protocol_mapper"
r.Kind = "SamlProtocolMapper"
r.References["client_scope_id"] = ujconfig.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/saml/v1alpha1.ClientScope",
}
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.SamlClient",
Extractor: common.PathUUIDExtractor,
}
})
p.SetResourceConfigurator("keycloak_generic_protocol_mapper", ujconfig.ResourceConfiguratorChain{openIdConfigurator, samlConfigurator})
// TODO: Add for SAML
p.AddResourceConfigurator("keycloak_generic_role_mapper", func(r *ujconfig.Resource) {
r.ShortGroup = Group
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.OpenIdClient",
Extractor: common.PathUUIDExtractor,
}
})
p.AddResourceConfigurator("keycloak_saml_script_protocol_mapper", func(r *config.Resource) {
r.ShortGroup = Group
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.SamlClient",
Extractor: common.PathUUIDExtractor,
}
})
p.AddResourceConfigurator("keycloak_saml_user_attribute_protocol_mapper", func(r *config.Resource) {
r.ShortGroup = Group
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.SamlClient",
Extractor: common.PathUUIDExtractor,
}
})
p.AddResourceConfigurator("keycloak_saml_user_property_protocol_mapper", func(r *config.Resource) {
r.ShortGroup = Group
r.References["client_id"] = config.Reference{
Type: "github.com/crossplane-contrib/provider-keycloak/apis/client/v1alpha1.SamlClient",
Extractor: common.PathUUIDExtractor,
}
})
}