/
keycloak_types.go
84 lines (73 loc) · 2.98 KB
/
keycloak_types.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
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// KeycloakSpec defines the desired state of Keycloak.
// +k8s:openapi-gen=true
type KeycloakSpec struct {
// When set to true, this Keycloak will be marked as unmanaged and will not be managed by this operator.
// It can then be used for targeting purposes.
// +optional
// +kubebuilder:default:=true
Unmanaged bool `json:"unmanaged,omitempty"`
// Contains configuration for external Keycloak instances. Unmanaged needs to be set to true to use this.
// +optional
External KeycloakExternal `json:"external"`
}
type KeycloakExternal struct {
// If set to true, this Keycloak will be treated as an external instance.
// The unmanaged field also needs to be set to true if this field is true.
Enabled bool `json:"enabled,omitempty"`
// The URL to use for the keycloak admin API. Needs to be set if external is true.
// +optional
URL string `json:"url,omitempty"`
}
// KeycloakStatus defines the observed state of Keycloak.
// +k8s:openapi-gen=true
type KeycloakStatus struct {
// Current phase of the operator.
Phase StatusPhase `json:"phase"`
// Human-readable message indicating details about current operator phase or error.
Message string `json:"message"`
// True if all resources are in a ready state and all work is done.
Ready bool `json:"ready"`
// A map of all the secondary resources types and names created for this CR. e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ].
SecondaryResources map[string][]string `json:"secondaryResources,omitempty"`
// Version of Keycloak or RHSSO running on the cluster.
Version string `json:"version"`
// External URL for accessing Keycloak instance from outside the cluster. Is identical to external.URL if it's specified, otherwise is computed (e.g. from Ingress).
ExternalURL string `json:"externalURL,omitempty"`
// The secret where the admin credentials are to be found.
CredentialSecret string `json:"credentialSecret"`
}
type StatusPhase string
var (
NoPhase StatusPhase
PhaseReconciling StatusPhase = "reconciling"
PhaseFailing StatusPhase = "failing"
PhaseInitialising StatusPhase = "initialising"
)
// Keycloak is the Schema for the keycloaks API.
// +genclient
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +kubebuilder:object:root=true
type Keycloak struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec KeycloakSpec `json:"spec,omitempty"`
Status KeycloakStatus `json:"status,omitempty"`
}
// KeycloakList contains a list of Keycloak.
// +kubebuilder:object:root=true
type KeycloakList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Keycloak `json:"items"`
}
func init() {
SchemeBuilder.Register(&Keycloak{}, &KeycloakList{})
}
func (i *Keycloak) UpdateStatusSecondaryResources(kind string, resourceName string) {
i.Status.SecondaryResources = UpdateStatusSecondaryResources(i.Status.SecondaryResources, kind, resourceName)
}