1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/sbo-setting-annotations-mapping-optional.adoc
2024-03-15 12:39:37 +00:00

35 lines
1.6 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/connecting_applications_to_services/exposing-binding-data-from-a-service.adoc
:_mod-docs-content-type: PROCEDURE
[id="sbo-setting-annotations-mapping-optional_{context}"]
= Setting annotations mapping to be optional
You can have optional fields in the annotations. For example, a path to the credentials might not be present if the service endpoint does not require authentication. In such cases, a field might not exist in the target path of the annotations. As a result, {servicebinding-title} generates an error, by default.
As a service provider, to indicate whether you require annotations mapping, you can set a value for the `optional` flag in your annotations when enabling services. {servicebinding-title} provides annotations mapping only if the target path is available. When the target path is not available, the {servicebinding-title} skips the optional mapping and continues with the projection of the existing mappings without throwing any errors.
.Procedure
* To make a field in the annotations optional, set the `optional` flag value to `true`:
+
.Example
[source,yaml]
----
apiVersion: apps.example.org/v1beta1
kind: Database
metadata:
name: my-db
namespace: my-petclinic
annotations:
service.binding/username: path={.spec.name},optional=true
# ...
----
[NOTE]
====
* If you set the `optional` flag value to `false` and the {servicebinding-title} is unable to find the target path, the Operator fails the annotations mapping.
* If the `optional` flag has no value set, the {servicebinding-title} considers the value as `false` by default and fails the annotations mapping.
====