@@ -28,73 +28,85 @@ var templates = map[string]string{
28
28
"lowercase" : "{{ .name | lower }}" ,
29
29
}
30
30
31
- // ServiceBindingSpec defines the desired state of ServiceBinding
31
+ // ServiceBindingSpec defines the desired state of ServiceBinding.
32
32
type ServiceBindingSpec struct {
33
- // MountPath is the path inside app container where bindings will be mounted
34
- // If `SERVICE_BINDING_ROOT` env var is present, mountPath is ignored.
35
- // If `SERVICE_BINDING_ROOT` is absent and mountPath is present, set `SERVICE_BINDING_ROOT` as mountPath value
36
- // If `SERVICE_BINDING_ROOT` is absent but mounthPath is absent, set SERVICE_BINDING_ROOT as `/bindings`
37
- // When mountPath is used, the file will be mounted directly under that directory
38
- // Otherwise it will be under `SERVICE_BINDING_ROOT`/<SERVICE-BINDING-NAME>
33
+ // MountPath specifies the path inside the app container where bindings
34
+ // will be mounted. The environment variable `SERVICE_BINDING_ROOT`
35
+ // has higher precedence than this option, and setting it within an
36
+ // application to be bound will cause MountPath to be ignored and will
37
+ // always mount resources as files. If it isn't set, then it is
38
+ // automatically set to the value of MountPath. If neither MountPath
39
+ // nor `SERVICE_BINDING_ROOT` are set, this field defaults to
40
+ // `/bindings`, and `SERVICE_BINDING_ROOT` is also set. This results
41
+ // in the file being mounted under the directory specified.
39
42
// +optional
40
43
MountPath string `json:"mountPath,omitempty"`
41
44
42
- // NamingStrategy defines custom string template for preparing binding names.
43
- // It can be pre-defined strategies(i.e none,uppercase), in case strategy provided in this field isn't defined
44
- // we are going to treat the value as a custom template and prepare binding names accordingly.
45
+ // NamingStrategy defines custom string template for preparing binding
46
+ // names. It can be set to pre-defined strategies: `none`,
47
+ // `lowercase`, or `uppercase`. Otherwise, it is treated as a custom
48
+ // go template, and it is handled accordingly.
45
49
// +optional
46
50
NamingStrategy string `json:"namingStrategy,omitempty"`
47
51
48
- // Custom mappings
52
+ // Mappings specifies custom mappings.
49
53
// +optional
50
54
Mappings []Mapping `json:"mappings,omitempty"`
51
55
52
- // Services is used to identify multiple backing services.
56
+ // Services indicates the backing services to be connected to by an
57
+ // application. At least one service must be specified.
53
58
// +kubebuilder:validation:MinItems:=1
54
59
Services []Service `json:"services"`
55
60
56
- // Application is used to identify the application connecting to the
57
- // backing service operator .
61
+ // Application identifies the application connecting to the backing
62
+ // service.
58
63
Application Application `json:"application"`
59
64
60
- // DetectBindingResources is flag used to bind all non-bindable variables from
61
- // different subresources owned by backing operator CR.
65
+ // DetectBindingResources is a flag that, when set to true, will cause
66
+ // SBO to search for binding information in the owned resources of the
67
+ // specified services. If this binding information exists, then the
68
+ // application is bound to these subresources.
62
69
// +optional
63
70
DetectBindingResources bool `json:"detectBindingResources,omitempty"`
64
71
65
- // BindAsFiles makes available the binding values as files in the application's container
66
- // See MountPath attribute description for more details.
72
+ // BindAsFiles makes the binding values available as files in the
73
+ // application's container. See the MountPath attribute description
74
+ // for more details.
67
75
// +optional
68
76
// +kubebuilder:default:=true
69
77
BindAsFiles bool `json:"bindAsFiles"`
70
78
}
71
79
72
- // ServiceBindingMapping defines a new binding from set of existing bindings
80
+ // ServiceBindingMapping defines a new binding from a set of existing bindings.
73
81
type Mapping struct {
74
- // Name is the name of new binding
82
+ // Name is the name of new binding.
75
83
Name string `json:"name"`
76
- // Value is a template which will be rendered and ibjected into the application
84
+
85
+ // Value specificies a go template that will be rendered and injected
86
+ // into the application.
77
87
Value string `json:"value"`
78
88
}
79
89
80
- // ServiceBindingStatus defines the observed state of ServiceBinding
90
+ // ServiceBindingStatus defines the observed state of ServiceBinding.
81
91
// +k8s:openapi-gen=true
82
92
type ServiceBindingStatus struct {
83
- // Conditions describes the state of the operator's reconciliation functionality.
93
+ // Conditions describes the state of the operator's reconciliation
94
+ // functionality.
84
95
// +patchMergeKey=type
85
96
// +patchStrategy=merge
86
97
// +listType=map
87
98
// +listMapKey=type
88
99
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
89
- // Secret is the name of the intermediate secret
100
+
101
+ // Secret indicates the name of the binding secret.
90
102
Secret string `json:"secret"`
91
103
92
- // Application defines the application workloads to which the binding secret has
93
- // injected
104
+ // Applications defines the application workloads to which the binding
105
+ // secret has been injected.
94
106
Applications []Ref `json:"applications,omitempty"`
95
107
}
96
108
97
- // Object reference in the same namespace
109
+ // Ref identifies an object reference in the same namespace.
98
110
// +mapType=atomic
99
111
type Ref struct {
100
112
@@ -116,58 +128,59 @@ type Ref struct {
116
128
Name string `json:"name,omitempty"`
117
129
}
118
130
119
- // Object reference in some namespace
131
+ // NamespacedRef is an object reference in some namespace.
120
132
type NamespacedRef struct {
121
133
Ref `json:",inline"`
122
134
123
- // Namespace of the referent.
124
- // if empty assumes the same namespace as ServiceBinding
135
+ // Namespace of the referent. If unspecified, assumes the same namespace as
136
+ // ServiceBinding.
125
137
// +optional
126
138
Namespace * string `json:"namespace,omitempty"`
127
139
}
128
140
129
- // Service defines the selector based on resource name, version, and resource kind
141
+ // Service defines the selector based on resource name, version, and resource kind.
130
142
type Service struct {
131
143
NamespacedRef `json:",inline"`
132
144
133
145
Id * string `json:"id,omitempty"`
134
146
}
135
147
136
- // Application defines the selector based on labels and GVR
148
+ // Application defines the selector based on labels and group version resource.
137
149
type Application struct {
138
150
Ref `json:",inline"`
151
+
139
152
// +optional
140
153
LabelSelector * metav1.LabelSelector `json:"labelSelector,omitempty"`
141
154
142
155
// BindingPath refers to the paths in the application workload's schema
143
- // where the binding workload would be referenced.
144
- // If BindingPath is not specified the default path locations is going to
145
- // be used. The default location for ContainersPath is
146
- // going to be: "spec.template.spec.containers" and if SecretPath
147
- // is not specified, the name of the secret object is not going
148
- // to be specified.
156
+ // where the binding workload would be referenced. If BindingPath is
157
+ // not specified, then the default path locations are used. The
158
+ // default location for ContainersPath is
159
+ // "spec.template.spec.containers". If SecretPath is not specified,
160
+ // then the name of the secret object does not need to be specified.
149
161
// +optional
150
162
BindingPath * BindingPath `json:"bindingPath,omitempty"`
151
163
}
152
164
153
165
// BindingPath defines the path to the field where the binding would be
154
- // embedded in the workload
166
+ // embedded in the workload.
155
167
type BindingPath struct {
156
- // ContainersPath defines the path to the corev1.Containers reference
168
+ // ContainersPath defines the path to the corev1.Containers reference.
157
169
// If BindingPath is not specified, the default location is
158
- // going to be: "spec.template.spec.containers"
170
+ // "spec.template.spec.containers".
159
171
// +optional
160
172
ContainersPath string `json:"containersPath"`
161
173
162
- // SecretPath defines the path to a string field where
163
- // the name of the secret object is going to be assigned.
164
- // Note: The name of the secret object is same as that of the name of SBR CR (metadata.name)
174
+ // SecretPath defines the path to a string field where the name of the
175
+ // secret object is going to be assigned. Note: The name of the secret
176
+ // object is same as that of the name of service binding custom resource
177
+ // (metadata.name).
165
178
// +optional
166
179
SecretPath string `json:"secretPath"`
167
180
}
168
181
169
- // ServiceBinding expresses intent to bind an operator-backed service with
170
- // an application workload.
182
+ // ServiceBinding expresses intent to bind a service with an application
183
+ // workload.
171
184
// +kubebuilder:subresource:status
172
185
// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Service Binding"
173
186
// +kubebuilder:resource:path=servicebindings,shortName=sbr;sbrs
@@ -182,7 +195,7 @@ type ServiceBinding struct {
182
195
183
196
// +kubebuilder:object:root=true
184
197
185
- // ServiceBindingList contains a list of ServiceBinding
198
+ // ServiceBindingList contains a list of ServiceBinding.
186
199
type ServiceBindingList struct {
187
200
metav1.TypeMeta `json:",inline"`
188
201
metav1.ListMeta `json:"metadata,omitempty"`
0 commit comments