use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.
the class Authenticator method authenticateByServiceAccount.
/**
* Given a V1ServiceAccount object, pull the authentication secrets and
* initialize a new ApiClient to authenticate with those credentials.
*
* @param serviceAccount The name of the Service Account to authenticate with.
* @return ApiClient An ApiClient for the given Service Account.
* @throws ApiException if there is an API error.
*/
private ApiClient authenticateByServiceAccount(V1ServiceAccount serviceAccount) throws ApiException {
LOGGER.entering();
byte[] caCert = null;
String token = null;
List<V1ObjectReference> secretList = serviceAccount.getSecrets();
for (V1ObjectReference reference : secretList) {
// Get the secret.
V1Secret secret = helper.readSecretByReference(reference, serviceAccount.getMetadata().getNamespace());
Map<String, byte[]> secretMap = secret.getData();
for (Entry<String, byte[]> entry : secretMap.entrySet()) {
if (entry.getKey().equals("ca.crt")) {
caCert = entry.getValue();
}
if (entry.getKey().equals("token")) {
token = new String(entry.getValue());
}
}
}
serviceToken = token;
String serviceHost = System.getenv(_SERVICE_HOST);
String servicePort = System.getenv(_SERVICE_PORT);
String serviceUrl = "https://" + serviceHost + ":" + servicePort;
ApiClient newClient = new ApiClient();
newClient.setBasePath(serviceUrl);
newClient.setApiKey("Bearer " + token);
newClient.setSslCaCert(new ByteArrayInputStream(caCert));
LOGGER.exiting(newClient);
return newClient;
}
use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listDomain.
/* Domains */
/**
* List domains
* @param namespace Namespace
* @return Domain list
* @throws ApiException API exception
*/
public DomainList listDomain(String namespace) throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new WeblogicApi(client).listWebLogicOracleV1NamespacedDomain(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listPersistentVolume.
/* Persistent Volumes */
/**
* List persistent volumes
* @return List of persistent volumes
* @throws ApiException API Exception
*/
public V1PersistentVolumeList listPersistentVolume() throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).listPersistentVolume(pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listPersistentVolumeClaim.
/* Persistent Volume Claims */
/**
* List persistent volume claims
* @param namespace Namespace
* @return List of persistent volume claims
* @throws ApiException API Exception
*/
public V1PersistentVolumeClaimList listPersistentVolumeClaim(String namespace) throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).listNamespacedPersistentVolumeClaim(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listConfigMap.
/* Config Maps */
/**
* List config maps
* @param namespace Namespace
* @return List of config maps
* @throws ApiException API Exception
*/
public V1ConfigMapList listConfigMap(String namespace) throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).listNamespacedConfigMap(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
Aggregations