Compare commits
1 commit
main
...
wip/api-up
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c2a327559 |
16 changed files with 56 additions and 48 deletions
|
|
@ -11,7 +11,7 @@ plugins {
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':org.jdrupes.vmoperator.util')
|
api project(':org.jdrupes.vmoperator.util')
|
||||||
api 'org.jgrapes:org.jgrapes.core:[1.22.1,2)'
|
api 'org.jgrapes:org.jgrapes.core:[1.22.1,2)'
|
||||||
api 'io.kubernetes:client-java:[19.0.0,20.0.0)'
|
api 'io.kubernetes:client-java:[23.0.0,24.0.0)'
|
||||||
api 'org.yaml:snakeyaml'
|
api 'org.yaml:snakeyaml'
|
||||||
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:[2.16.1,3]'
|
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:[2.16.1,3]'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import com.google.gson.TypeAdapterFactory;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import io.kubernetes.client.openapi.ApiClient;
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
@ -45,18 +45,15 @@ public class DynamicTypeAdapterFactory<O extends K8sDynamicModel,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure that this adapter is registered.
|
* Make sure that this adapter is registered.
|
||||||
*
|
|
||||||
* @param client the client
|
|
||||||
*/
|
*/
|
||||||
public void register(ApiClient client) {
|
public void register() {
|
||||||
if (!ModelCreator.class
|
if (!ModelCreator.class
|
||||||
.equals(client.getJSON().getGson().getAdapter(objectClass)
|
.equals(JSON.getGson().getAdapter(objectClass).getClass())
|
||||||
.getClass())
|
|| !ModelsCreator.class.equals(JSON.getGson()
|
||||||
|| !ModelsCreator.class.equals(client.getJSON().getGson()
|
|
||||||
.getAdapter(objectListClass).getClass())) {
|
.getAdapter(objectListClass).getClass())) {
|
||||||
Gson gson = client.getJSON().getGson();
|
Gson gson = JSON.getGson();
|
||||||
client.getJSON().setGson(gson.newBuilder()
|
JSON.setGson(
|
||||||
.registerTypeAdapterFactory(this).create());
|
gson.newBuilder().registerTypeAdapterFactory(this).create());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import io.kubernetes.client.common.KubernetesType;
|
||||||
import io.kubernetes.client.custom.V1Patch;
|
import io.kubernetes.client.custom.V1Patch;
|
||||||
import io.kubernetes.client.openapi.ApiClient;
|
import io.kubernetes.client.openapi.ApiClient;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.openapi.apis.EventsV1Api;
|
import io.kubernetes.client.openapi.apis.EventsV1Api;
|
||||||
import io.kubernetes.client.openapi.models.EventsV1Event;
|
import io.kubernetes.client.openapi.models.EventsV1Event;
|
||||||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||||
|
|
@ -118,7 +119,7 @@ public class K8s {
|
||||||
= new Yaml(new SafeConstructor(new LoaderOptions())).load(yaml);
|
= new Yaml(new SafeConstructor(new LoaderOptions())).load(yaml);
|
||||||
|
|
||||||
// There's no short-cut from Java (collections) to Gson
|
// There's no short-cut from Java (collections) to Gson
|
||||||
var gson = client.getJSON().getGson();
|
var gson = JSON.getGson();
|
||||||
var jsonText = gson.toJson(yamlData);
|
var jsonText = gson.toJson(yamlData);
|
||||||
return gson.fromJson(jsonText, JsonObject.class);
|
return gson.fromJson(jsonText, JsonObject.class);
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +246,7 @@ public class K8s {
|
||||||
if (event.getRegarding() == null) {
|
if (event.getRegarding() == null) {
|
||||||
event.regarding(objectReference(object));
|
event.regarding(objectReference(object));
|
||||||
}
|
}
|
||||||
new EventsV1Api(client).createNamespacedEvent(
|
new EventsV1Api(client)
|
||||||
object.getMetadata().getNamespace(), event, null, null, null, null);
|
.createNamespacedEvent(object.getMetadata().getNamespace(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.net.URI;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -804,6 +805,7 @@ public class K8sClient extends ApiClient {
|
||||||
/**
|
/**
|
||||||
* Builds the call.
|
* Builds the call.
|
||||||
*
|
*
|
||||||
|
* @param baseUrl the base url
|
||||||
* @param path the path
|
* @param path the path
|
||||||
* @param method the method
|
* @param method the method
|
||||||
* @param queryParams the query params
|
* @param queryParams the query params
|
||||||
|
|
@ -820,12 +822,13 @@ public class K8sClient extends ApiClient {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
|
@SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
|
||||||
@Override
|
@Override
|
||||||
public Call buildCall(String path, String method, List<Pair> queryParams,
|
public Call buildCall(String baseUrl, String path, String method,
|
||||||
List<Pair> collectionQueryParams, Object body,
|
List<Pair> queryParams, List<Pair> collectionQueryParams,
|
||||||
Map<String, String> headerParams, Map<String, String> cookieParams,
|
Object body, Map<String, String> headerParams,
|
||||||
Map<String, Object> formParams, String[] authNames,
|
Map<String, String> cookieParams, Map<String, Object> formParams,
|
||||||
|
String[] authNames,
|
||||||
ApiCallback callback) throws ApiException {
|
ApiCallback callback) throws ApiException {
|
||||||
return apiClient().buildCall(path, method, queryParams,
|
return apiClient().buildCall(baseUrl, path, method, queryParams,
|
||||||
collectionQueryParams, body, headerParams, cookieParams, formParams,
|
collectionQueryParams, body, headerParams, cookieParams, formParams,
|
||||||
authNames, callback);
|
authNames, callback);
|
||||||
}
|
}
|
||||||
|
|
@ -833,6 +836,7 @@ public class K8sClient extends ApiClient {
|
||||||
/**
|
/**
|
||||||
* Builds the request.
|
* Builds the request.
|
||||||
*
|
*
|
||||||
|
* @param baseUrl the base url
|
||||||
* @param path the path
|
* @param path the path
|
||||||
* @param method the method
|
* @param method the method
|
||||||
* @param queryParams the query params
|
* @param queryParams the query params
|
||||||
|
|
@ -849,12 +853,12 @@ public class K8sClient extends ApiClient {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
|
@SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
|
||||||
@Override
|
@Override
|
||||||
public Request buildRequest(String path, String method,
|
public Request buildRequest(String baseUrl, String path, String method,
|
||||||
List<Pair> queryParams, List<Pair> collectionQueryParams,
|
List<Pair> queryParams, List<Pair> collectionQueryParams,
|
||||||
Object body, Map<String, String> headerParams,
|
Object body, Map<String, String> headerParams,
|
||||||
Map<String, String> cookieParams, Map<String, Object> formParams,
|
Map<String, String> cookieParams, Map<String, Object> formParams,
|
||||||
String[] authNames, ApiCallback callback) throws ApiException {
|
String[] authNames, ApiCallback callback) throws ApiException {
|
||||||
return apiClient().buildRequest(path, method, queryParams,
|
return apiClient().buildRequest(baseUrl, path, method, queryParams,
|
||||||
collectionQueryParams, body, headerParams, cookieParams, formParams,
|
collectionQueryParams, body, headerParams, cookieParams, formParams,
|
||||||
authNames, callback);
|
authNames, callback);
|
||||||
}
|
}
|
||||||
|
|
@ -862,6 +866,7 @@ public class K8sClient extends ApiClient {
|
||||||
/**
|
/**
|
||||||
* Builds the url.
|
* Builds the url.
|
||||||
*
|
*
|
||||||
|
* @param baseUrl the base url
|
||||||
* @param path the path
|
* @param path the path
|
||||||
* @param queryParams the query params
|
* @param queryParams the query params
|
||||||
* @param collectionQueryParams the collection query params
|
* @param collectionQueryParams the collection query params
|
||||||
|
|
@ -869,9 +874,10 @@ public class K8sClient extends ApiClient {
|
||||||
* @see ApiClient#buildUrl(java.lang.String, java.util.List, java.util.List)
|
* @see ApiClient#buildUrl(java.lang.String, java.util.List, java.util.List)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String buildUrl(String path, List<Pair> queryParams,
|
public String buildUrl(String baseUrl, String path, List<Pair> queryParams,
|
||||||
List<Pair> collectionQueryParams) {
|
List<Pair> collectionQueryParams) {
|
||||||
return apiClient().buildUrl(path, queryParams, collectionQueryParams);
|
return apiClient().buildUrl(baseUrl, path, queryParams,
|
||||||
|
collectionQueryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -907,14 +913,15 @@ public class K8sClient extends ApiClient {
|
||||||
* @param queryParams the query params
|
* @param queryParams the query params
|
||||||
* @param headerParams the header params
|
* @param headerParams the header params
|
||||||
* @param cookieParams the cookie params
|
* @param cookieParams the cookie params
|
||||||
|
* @throws ApiException
|
||||||
* @see ApiClient#updateParamsForAuth(java.lang.String[], java.util.List, java.util.Map, java.util.Map)
|
* @see ApiClient#updateParamsForAuth(java.lang.String[], java.util.List, java.util.Map, java.util.Map)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams,
|
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams,
|
||||||
Map<String, String> headerParams,
|
Map<String, String> headerParams, Map<String, String> cookieParams,
|
||||||
Map<String, String> cookieParams) {
|
String payload, String method, URI uri) throws ApiException {
|
||||||
apiClient().updateParamsForAuth(authNames, queryParams, headerParams,
|
apiClient().updateParamsForAuth(authNames, queryParams, headerParams,
|
||||||
cookieParams);
|
cookieParams, payload, method, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,7 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
|
||||||
* @param <L> the object list type
|
* @param <L> the object list type
|
||||||
* @param <R> the result type
|
* @param <R> the result type
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface GenericSupplier<O extends KubernetesObject,
|
public interface GenericSupplier<O extends KubernetesObject,
|
||||||
L extends KubernetesListObject,
|
L extends KubernetesListObject,
|
||||||
R extends K8sClusterGenericStub<O, L>> {
|
R extends K8sClusterGenericStub<O, L>> {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import io.kubernetes.client.common.KubernetesListObject;
|
import io.kubernetes.client.common.KubernetesListObject;
|
||||||
import io.kubernetes.client.openapi.Configuration;
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.openapi.models.V1ListMeta;
|
import io.kubernetes.client.openapi.models.V1ListMeta;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -147,9 +147,7 @@ public class K8sDynamicModelsBase<T extends K8sDynamicModel>
|
||||||
* @param objectMeta the new metadata
|
* @param objectMeta the new metadata
|
||||||
*/
|
*/
|
||||||
public void setMetadata(V1ListMeta objectMeta) {
|
public void setMetadata(V1ListMeta objectMeta) {
|
||||||
data.add("metadata",
|
data.add("metadata", JSON.getGson().toJsonTree(objectMeta));
|
||||||
Configuration.getDefaultApiClient().getJSON().getGson()
|
|
||||||
.toJsonTree(objectMeta));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.common;
|
||||||
import io.kubernetes.client.Discovery.APIResource;
|
import io.kubernetes.client.Discovery.APIResource;
|
||||||
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -101,8 +102,8 @@ public class K8sDynamicStub
|
||||||
*/
|
*/
|
||||||
public static K8sDynamicStub createFromYaml(K8sClient client,
|
public static K8sDynamicStub createFromYaml(K8sClient client,
|
||||||
APIResource context, Reader yaml) throws ApiException {
|
APIResource context, Reader yaml) throws ApiException {
|
||||||
var model = new K8sDynamicModel(client.getJSON().getGson(),
|
var model
|
||||||
K8s.yamlToJson(client, yaml));
|
= new K8sDynamicModel(JSON.getGson(), K8s.yamlToJson(client, yaml));
|
||||||
return K8sGenericStub.create(K8sDynamicModel.class,
|
return K8sGenericStub.create(K8sDynamicModel.class,
|
||||||
K8sDynamicModels.class, client, context, model,
|
K8sDynamicModels.class, client, context, model,
|
||||||
(c, ns, n) -> new K8sDynamicStub(c, context, ns, n));
|
(c, ns, n) -> new K8sDynamicStub(c, context, ns, n));
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,6 @@ public abstract class K8sDynamicStubBase<O extends K8sDynamicModel,
|
||||||
K8sClient client, APIResource context, String namespace,
|
K8sClient client, APIResource context, String namespace,
|
||||||
String name) {
|
String name) {
|
||||||
super(objectClass, objectListClass, client, context, namespace, name);
|
super(objectClass, objectListClass, client, context, namespace, name);
|
||||||
taf.register(client);
|
taf.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,6 +24,7 @@ import io.kubernetes.client.common.KubernetesListObject;
|
||||||
import io.kubernetes.client.common.KubernetesObject;
|
import io.kubernetes.client.common.KubernetesObject;
|
||||||
import io.kubernetes.client.custom.V1Patch;
|
import io.kubernetes.client.custom.V1Patch;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.util.Strings;
|
import io.kubernetes.client.util.Strings;
|
||||||
import io.kubernetes.client.util.generic.GenericKubernetesApi;
|
import io.kubernetes.client.util.generic.GenericKubernetesApi;
|
||||||
import io.kubernetes.client.util.generic.KubernetesApiResponse;
|
import io.kubernetes.client.util.generic.KubernetesApiResponse;
|
||||||
|
|
@ -325,7 +326,7 @@ public class K8sGenericStub<O extends KubernetesObject,
|
||||||
opts.setForce(true);
|
opts.setForce(true);
|
||||||
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
||||||
return patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
return patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
||||||
new V1Patch(client.getJSON().serialize(def)), opts);
|
new V1Patch(JSON.serialize(def)), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -359,6 +360,7 @@ public class K8sGenericStub<O extends KubernetesObject,
|
||||||
* @param <L> the object list type
|
* @param <L> the object list type
|
||||||
* @param <R> the result type
|
* @param <R> the result type
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface GenericSupplier<O extends KubernetesObject,
|
public interface GenericSupplier<O extends KubernetesObject,
|
||||||
L extends KubernetesListObject, R extends K8sGenericStub<O, L>> {
|
L extends KubernetesListObject, R extends K8sGenericStub<O, L>> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class VmDefinition extends K8sDynamicModel {
|
||||||
private static final Logger logger
|
private static final Logger logger
|
||||||
= Logger.getLogger(VmDefinition.class.getName());
|
= Logger.getLogger(VmDefinition.class.getName());
|
||||||
@SuppressWarnings("PMD.FieldNamingConventions")
|
@SuppressWarnings("PMD.FieldNamingConventions")
|
||||||
private static final Gson gson = new JSON().getGson();
|
private static final Gson gson = JSON.getGson();
|
||||||
@SuppressWarnings("PMD.FieldNamingConventions")
|
@SuppressWarnings("PMD.FieldNamingConventions")
|
||||||
private static final ObjectMapper objectMapper
|
private static final ObjectMapper objectMapper
|
||||||
= new ObjectMapper().registerModule(new JavaTimeModule());
|
= new ObjectMapper().registerModule(new JavaTimeModule());
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.common;
|
||||||
import io.kubernetes.client.Discovery.APIResource;
|
import io.kubernetes.client.Discovery.APIResource;
|
||||||
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -101,8 +102,8 @@ public class VmDefinitionStub
|
||||||
*/
|
*/
|
||||||
public static VmDefinitionStub createFromYaml(K8sClient client,
|
public static VmDefinitionStub createFromYaml(K8sClient client,
|
||||||
APIResource context, Reader yaml) throws ApiException {
|
APIResource context, Reader yaml) throws ApiException {
|
||||||
var model = new VmDefinition(client.getJSON().getGson(),
|
var model
|
||||||
K8s.yamlToJson(client, yaml));
|
= new VmDefinition(JSON.getGson(), K8s.yamlToJson(client, yaml));
|
||||||
return K8sGenericStub.create(VmDefinition.class,
|
return K8sGenericStub.create(VmDefinition.class,
|
||||||
VmDefinitions.class, client, context, model,
|
VmDefinitions.class, client, context, model,
|
||||||
(c, ns, n) -> new VmDefinitionStub(c, context, ns, n));
|
(c, ns, n) -> new VmDefinitionStub(c, context, ns, n));
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import com.google.gson.Gson;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.openapi.models.V1APIService;
|
import io.kubernetes.client.openapi.models.V1APIService;
|
||||||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||||
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject;
|
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject;
|
||||||
|
|
@ -122,7 +123,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
? (Map<String, Map<String, String>>) lbsDef
|
? (Map<String, Map<String, String>>) lbsDef
|
||||||
: null;
|
: null;
|
||||||
var client = channel.client();
|
var client = channel.client();
|
||||||
mergeMetadata(client.getJSON().getGson(), svcDef, defaults, vmDef);
|
mergeMetadata(JSON.getGson(), svcDef, defaults, vmDef);
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
var svcStub = K8sV1ServiceStub
|
var svcStub = K8sV1ServiceStub
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.manager;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.util.Watch;
|
import io.kubernetes.client.util.Watch;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -130,7 +131,7 @@ public class PoolMonitor extends
|
||||||
|
|
||||||
// Get pool and merge changes
|
// Get pool and merge changes
|
||||||
var vmPool = pools.computeIfAbsent(poolName, k -> new VmPool(poolName));
|
var vmPool = pools.computeIfAbsent(poolName, k -> new VmPool(poolName));
|
||||||
vmPool.defineFrom(client().getJSON().getGson().fromJson(
|
vmPool.defineFrom(JSON.getGson().fromJson(
|
||||||
GsonPtr.to(poolModel.data()).to("spec").get(), VmPool.class));
|
GsonPtr.to(poolModel.data()).to("spec").get(), VmPool.class));
|
||||||
poolPipeline.fire(new VmPoolChanged(vmPool));
|
poolPipeline.fire(new VmPoolChanged(vmPool));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import freemarker.template.TemplateException;
|
||||||
import freemarker.template.TemplateNotFoundException;
|
import freemarker.template.TemplateNotFoundException;
|
||||||
import io.kubernetes.client.custom.V1Patch;
|
import io.kubernetes.client.custom.V1Patch;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import io.kubernetes.client.util.generic.dynamic.Dynamics;
|
import io.kubernetes.client.util.generic.dynamic.Dynamics;
|
||||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||||
import io.kubernetes.client.util.generic.options.PatchOptions;
|
import io.kubernetes.client.util.generic.options.PatchOptions;
|
||||||
|
|
@ -160,8 +161,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
opts.setForce(true);
|
opts.setForce(true);
|
||||||
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
||||||
if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
||||||
new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts)
|
new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) {
|
||||||
.isEmpty()) {
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
() -> "Could not patch pvc for " + pvcStub.name());
|
() -> "Could not patch pvc for " + pvcStub.name());
|
||||||
}
|
}
|
||||||
|
|
@ -203,8 +203,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
opts.setForce(true);
|
opts.setForce(true);
|
||||||
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
||||||
if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML,
|
||||||
new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts)
|
new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) {
|
||||||
.isEmpty()) {
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
() -> "Could not patch pvc for " + pvcStub.name());
|
() -> "Could not patch pvc for " + pvcStub.name());
|
||||||
}
|
}
|
||||||
|
|
@ -218,8 +217,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
PatchOptions opts = new PatchOptions();
|
PatchOptions opts = new PatchOptions();
|
||||||
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
opts.setFieldManager("kubernetes-java-kubectl-apply");
|
||||||
if (pvcStub.patch(V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH,
|
if (pvcStub.patch(V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH,
|
||||||
new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts)
|
new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) {
|
||||||
.isEmpty()) {
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
() -> "Could not patch pvc for " + pvcStub.name());
|
() -> "Could not patch pvc for " + pvcStub.name());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ import org.jgrapes.core.events.Start;
|
||||||
public class StatusUpdater extends VmDefUpdater {
|
public class StatusUpdater extends VmDefUpdater {
|
||||||
|
|
||||||
@SuppressWarnings("PMD.FieldNamingConventions")
|
@SuppressWarnings("PMD.FieldNamingConventions")
|
||||||
private static final Gson gson = new JSON().getGson();
|
private static final Gson gson = JSON.getGson();
|
||||||
@SuppressWarnings("PMD.FieldNamingConventions")
|
@SuppressWarnings("PMD.FieldNamingConventions")
|
||||||
private static final ObjectMapper objectMapper
|
private static final ObjectMapper objectMapper
|
||||||
= new ObjectMapper().registerModule(new JavaTimeModule());
|
= new ObjectMapper().registerModule(new JavaTimeModule());
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jdrupes.vmoperator.runner.qemu;
|
package org.jdrupes.vmoperator.runner.qemu;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import io.kubernetes.client.openapi.JSON;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
@ -161,8 +162,7 @@ public class VmDefUpdater extends Component {
|
||||||
: cond)
|
: cond)
|
||||||
.collect(Collectors.toCollection(() -> new ArrayList<>()));
|
.collect(Collectors.toCollection(() -> new ArrayList<>()));
|
||||||
newConds.addAll(toReplace);
|
newConds.addAll(toReplace);
|
||||||
status.add("conditions",
|
status.add("conditions", JSON.getGson().toJsonTree(newConds));
|
||||||
apiClient.getJSON().getGson().toJsonTree(newConds));
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue