File tree Expand file tree Collapse file tree
operator/src/main/java/io/github/microcks/operator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ This secrete will need to have -at least- two keys:
8484* `service-account-name` will hold the value of the Service Account name to use,
8585* `service-account-credentials` will hold the corresponding credentials to authenticate on your target Keycloak instance and realm.
8686
87- The last thing is how to tell the Microcks operator the secret to be used for Service Account retrievel ? Well this
87+ The last thing is how to tell the Microcks operator the secret to be used for Service Account retrieval ? Well this
8888is done using an additional annotation on your Microcks-dependent resource : the `microcks.io/service-account-secret`
8989annotation allows you to specify the name of secret to consider :
9090
Original file line number Diff line number Diff line change @@ -154,8 +154,19 @@ private ServiceAccountAndCredentials getServiceAccountAndCredentials(ObjectMeta
154154 Secret saSecret = client .secrets ().inNamespace (resourceMetadata .getNamespace ())
155155 .withName (serviceAccountSecret ).get ();
156156
157- serviceAccountName = saSecret .getStringData ().get ("service-account-name" );
158- serviceAccountCredentials = saSecret .getStringData ().get ("service-account-credentials" );
157+ if (saSecret == null ) {
158+ logger .errorf ("Could not find secret '%s' in namespace '%s'" , serviceAccountSecret , resourceMetadata .getNamespace ());
159+ logger .errorf ("Please check that the secret exists and is in the same namespace as the Microcks instance '%s'" , resourceMetadata .getName ());
160+ } else {
161+ String encodedServiceAccountName = saSecret .getData ().get ("service-account-name" );
162+ String encodedServiceAccountCredentials = saSecret .getData ().get ("service-account-credentials" );
163+ if (encodedServiceAccountName != null && encodedServiceAccountCredentials != null ) {
164+ serviceAccountName = new String (Base64 .getDecoder ().decode (encodedServiceAccountName ));
165+ serviceAccountCredentials = new String (Base64 .getDecoder ().decode (encodedServiceAccountCredentials ));
166+ } else {
167+ logger .errorf ("Could not find service account name or credentials in secret '%s'" , serviceAccountSecret );
168+ }
169+ }
159170 }
160171
161172 return new ServiceAccountAndCredentials (serviceAccountName , serviceAccountCredentials );
You can’t perform that action at this time.
0 commit comments