Reorganize imports.
This commit is contained in:
parent
e822d472f9
commit
41ae658e0c
16 changed files with 139 additions and 100 deletions
|
|
@ -11,7 +11,7 @@ metadata:
|
|||
vmoperator.jdrupes.org/version: ${ managerVersion }
|
||||
ownerReferences:
|
||||
- apiVersion: ${ cr.apiVersion() }
|
||||
kind: ${ constants.VM_OP_KIND_VM }
|
||||
kind: ${ constants.Crd.KIND_VM }
|
||||
name: ${ cr.name() }
|
||||
uid: ${ cr.metadata().getUid() }
|
||||
controller: false
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ metadata:
|
|||
vmoperator.jdrupes.org/version: ${ managerVersion }
|
||||
ownerReferences:
|
||||
- apiVersion: ${ cr.apiVersion() }
|
||||
kind: ${ constants.VM_OP_KIND_VM }
|
||||
kind: ${ constants.Crd.KIND_VM }
|
||||
name: ${ cr.name() }
|
||||
uid: ${ cr.metadata().getUid() }
|
||||
controller: false
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ metadata:
|
|||
vmoperator.jdrupes.org/version: ${ managerVersion }
|
||||
ownerReferences:
|
||||
- apiVersion: ${ cr.apiVersion() }
|
||||
kind: ${ constants.VM_OP_KIND_VM }
|
||||
kind: ${ constants.Crd.KIND_VM }
|
||||
name: ${ cr.name() }
|
||||
uid: ${ cr.metadata().getUid() }
|
||||
blockOwnerDeletion: true
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.logging.Level;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
import org.jdrupes.vmoperator.common.K8sDynamicStub;
|
||||
import org.jdrupes.vmoperator.common.VmDefinitionStub;
|
||||
|
|
@ -194,7 +193,7 @@ public class Controller extends Component {
|
|||
private void patchVmDef(K8sClient client, String name, String path,
|
||||
Object value) throws ApiException, IOException {
|
||||
var vmStub = K8sDynamicStub.get(client,
|
||||
new GroupVersionKind(VM_OP_GROUP, "", VM_OP_KIND_VM), namespace,
|
||||
new GroupVersionKind(Crd.GROUP, "", Crd.KIND_VM), namespace,
|
||||
name);
|
||||
|
||||
// Patch running
|
||||
|
|
@ -227,7 +226,7 @@ public class Controller extends Component {
|
|||
try {
|
||||
var vmDef = channel.vmDefinition();
|
||||
var vmStub = VmDefinitionStub.get(channel.client(),
|
||||
new GroupVersionKind(VM_OP_GROUP, "", VM_OP_KIND_VM),
|
||||
new GroupVersionKind(Crd.GROUP, "", Crd.KIND_VM),
|
||||
vmDef.namespace(), vmDef.name());
|
||||
if (vmStub.updateStatus(vmDef, from -> {
|
||||
JsonObject status = from.statusJson();
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ import io.kubernetes.client.util.generic.options.PatchOptions;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||
import org.jdrupes.vmoperator.common.Constants.DisplaySecret;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_NAME;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
import org.jdrupes.vmoperator.common.K8sV1PodStub;
|
||||
import org.jdrupes.vmoperator.common.K8sV1SecretStub;
|
||||
import static org.jdrupes.vmoperator.manager.Constants.COMP_DISPLAY_SECRET;
|
||||
import org.jdrupes.vmoperator.manager.events.ChannelDictionary;
|
||||
import org.jdrupes.vmoperator.manager.events.VmChannel;
|
||||
import org.jgrapes.core.Channel;
|
||||
|
|
@ -61,7 +61,7 @@ public class DisplaySecretMonitor
|
|||
context(K8sV1SecretStub.CONTEXT);
|
||||
ListOptions options = new ListOptions();
|
||||
options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET);
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
||||
options(options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,14 +37,12 @@ import java.util.Optional;
|
|||
import java.util.Scanner;
|
||||
import java.util.logging.Logger;
|
||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||
import static org.jdrupes.vmoperator.common.Constants.COMP_DISPLAY_SECRET;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.Constants.DisplaySecret;
|
||||
import org.jdrupes.vmoperator.common.Constants.Status;
|
||||
import org.jdrupes.vmoperator.common.K8sV1SecretStub;
|
||||
import org.jdrupes.vmoperator.common.VmDefinition;
|
||||
import org.jdrupes.vmoperator.common.VmDefinitionStub;
|
||||
import static org.jdrupes.vmoperator.manager.Constants.DATA_DISPLAY_PASSWORD;
|
||||
import static org.jdrupes.vmoperator.manager.Constants.DATA_PASSWORD_EXPIRY;
|
||||
import org.jdrupes.vmoperator.manager.events.PrepareConsole;
|
||||
import org.jdrupes.vmoperator.manager.events.VmChannel;
|
||||
import org.jdrupes.vmoperator.manager.events.VmDefChanged;
|
||||
|
|
@ -143,7 +141,7 @@ public class DisplaySecretReconciler extends Component {
|
|||
var vmDef = event.vmDefinition();
|
||||
ListOptions options = new ListOptions();
|
||||
options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET + ","
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME + ","
|
||||
+ "app.kubernetes.io/instance=" + vmDef.name());
|
||||
var stubs = K8sV1SecretStub.list(channel.client(), vmDef.namespace(),
|
||||
options);
|
||||
|
|
@ -154,9 +152,9 @@ public class DisplaySecretReconciler extends Component {
|
|||
// Create secret
|
||||
var secret = new V1Secret();
|
||||
secret.setMetadata(new V1ObjectMeta().namespace(vmDef.namespace())
|
||||
.name(vmDef.name() + "-" + COMP_DISPLAY_SECRET)
|
||||
.name(vmDef.name() + "-" + DisplaySecret.NAME)
|
||||
.putLabelsItem("app.kubernetes.io/name", APP_NAME)
|
||||
.putLabelsItem("app.kubernetes.io/component", COMP_DISPLAY_SECRET)
|
||||
.putLabelsItem("app.kubernetes.io/component", DisplaySecret.NAME)
|
||||
.putLabelsItem("app.kubernetes.io/instance", vmDef.name()));
|
||||
secret.setType("Opaque");
|
||||
SecureRandom random = null;
|
||||
|
|
@ -169,8 +167,8 @@ public class DisplaySecretReconciler extends Component {
|
|||
byte[] bytes = new byte[16];
|
||||
random.nextBytes(bytes);
|
||||
var password = Base64.encode(bytes);
|
||||
secret.setStringData(Map.of(DATA_DISPLAY_PASSWORD, password,
|
||||
DATA_PASSWORD_EXPIRY, "now"));
|
||||
secret.setStringData(Map.of(DisplaySecret.PASSWORD, password,
|
||||
DisplaySecret.EXPIRY, "now"));
|
||||
K8sV1SecretStub.create(channel.client(), secret);
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +194,7 @@ public class DisplaySecretReconciler extends Component {
|
|||
|
||||
// Check if access is possible
|
||||
if (event.loginUser()
|
||||
? !vmDef.<String> fromStatus("loggedInUser")
|
||||
? !vmDef.<String> fromStatus(Status.LOGGED_IN_USER)
|
||||
.map(u -> u.equals(event.user())).orElse(false)
|
||||
: !vmDef.conditionStatus("Running").orElse(false)) {
|
||||
return;
|
||||
|
|
@ -229,11 +227,11 @@ public class DisplaySecretReconciler extends Component {
|
|||
private VmDefinition updateConsoleUser(PrepareConsole event,
|
||||
VmChannel channel) throws ApiException {
|
||||
var vmStub = VmDefinitionStub.get(channel.client(),
|
||||
new GroupVersionKind(VM_OP_GROUP, "", VM_OP_KIND_VM),
|
||||
new GroupVersionKind(Crd.GROUP, "", Crd.KIND_VM),
|
||||
event.vmDefinition().namespace(), event.vmDefinition().name());
|
||||
return vmStub.updateStatus(from -> {
|
||||
JsonObject status = from.statusJson();
|
||||
status.addProperty("consoleUser", event.user());
|
||||
status.addProperty(Status.CONSOLE_USER, event.user());
|
||||
return status;
|
||||
}).orElse(null);
|
||||
}
|
||||
|
|
@ -243,7 +241,7 @@ public class DisplaySecretReconciler extends Component {
|
|||
// Look for secret
|
||||
ListOptions options = new ListOptions();
|
||||
options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET + ","
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME + ","
|
||||
+ "app.kubernetes.io/instance=" + vmDef.name());
|
||||
var stubs = K8sV1SecretStub.list(channel.client(), vmDef.namespace(),
|
||||
options);
|
||||
|
|
@ -257,12 +255,12 @@ public class DisplaySecretReconciler extends Component {
|
|||
|
||||
private boolean updatePassword(V1Secret secret, PrepareConsole event) {
|
||||
var expiry = Optional.ofNullable(secret.getData()
|
||||
.get(DATA_PASSWORD_EXPIRY)).map(b -> new String(b)).orElse(null);
|
||||
if (secret.getData().get(DATA_DISPLAY_PASSWORD) != null
|
||||
.get(DisplaySecret.EXPIRY)).map(b -> new String(b)).orElse(null);
|
||||
if (secret.getData().get(DisplaySecret.PASSWORD) != null
|
||||
&& stillValid(expiry)) {
|
||||
// Fixed secret, don't touch
|
||||
event.setResult(
|
||||
new String(secret.getData().get(DATA_DISPLAY_PASSWORD)));
|
||||
new String(secret.getData().get(DisplaySecret.PASSWORD)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -277,8 +275,8 @@ public class DisplaySecretReconciler extends Component {
|
|||
byte[] bytes = new byte[16];
|
||||
random.nextBytes(bytes);
|
||||
var password = Base64.encode(bytes);
|
||||
secret.setStringData(Map.of(DATA_DISPLAY_PASSWORD, password,
|
||||
DATA_PASSWORD_EXPIRY,
|
||||
secret.setStringData(Map.of(DisplaySecret.PASSWORD, password,
|
||||
DisplaySecret.EXPIRY,
|
||||
Long.toString(Instant.now().getEpochSecond() + passwordValidity)));
|
||||
event.setResult(password);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.K8s;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
import org.jdrupes.vmoperator.common.K8sDynamicModel;
|
||||
|
|
@ -38,7 +37,6 @@ import org.jdrupes.vmoperator.common.K8sDynamicStub;
|
|||
import org.jdrupes.vmoperator.common.K8sObserver.ResponseType;
|
||||
import org.jdrupes.vmoperator.common.VmDefinitionStub;
|
||||
import org.jdrupes.vmoperator.common.VmPool;
|
||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_KIND_VM_POOL;
|
||||
import org.jdrupes.vmoperator.manager.events.GetPools;
|
||||
import org.jdrupes.vmoperator.manager.events.VmDefChanged;
|
||||
import org.jdrupes.vmoperator.manager.events.VmPoolChanged;
|
||||
|
|
@ -88,7 +86,7 @@ public class PoolMonitor extends
|
|||
client(new K8sClient());
|
||||
|
||||
// Get all our API versions
|
||||
var ctx = K8s.context(client(), VM_OP_GROUP, "", VM_OP_KIND_VM_POOL);
|
||||
var ctx = K8s.context(client(), Crd.GROUP, "", Crd.KIND_VM_POOL);
|
||||
if (ctx.isEmpty()) {
|
||||
logger.severe(() -> "Cannot get CRD context.");
|
||||
return;
|
||||
|
|
@ -184,7 +182,7 @@ public class PoolMonitor extends
|
|||
return;
|
||||
}
|
||||
var vmStub = VmDefinitionStub.get(client(),
|
||||
new GroupVersionKind(VM_OP_GROUP, "", VM_OP_KIND_VM),
|
||||
new GroupVersionKind(Crd.GROUP, "", Crd.KIND_VM),
|
||||
vmDef.namespace(), vmDef.name());
|
||||
vmStub.updateStatus(from -> {
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -22,12 +22,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import freemarker.template.AdapterTemplateModel;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.DefaultObjectWrapperBuilder;
|
||||
import freemarker.template.SimpleNumber;
|
||||
import freemarker.template.SimpleScalar;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateExceptionHandler;
|
||||
import freemarker.template.TemplateHashModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
|
@ -37,21 +35,23 @@ import io.kubernetes.client.openapi.ApiException;
|
|||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||
import org.jdrupes.vmoperator.common.Constants.DisplaySecret;
|
||||
import org.jdrupes.vmoperator.common.Convertions;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
import org.jdrupes.vmoperator.common.K8sObserver;
|
||||
import org.jdrupes.vmoperator.common.K8sV1SecretStub;
|
||||
import org.jdrupes.vmoperator.common.VmDefinition;
|
||||
import static org.jdrupes.vmoperator.manager.Constants.COMP_DISPLAY_SECRET;
|
||||
import org.jdrupes.vmoperator.manager.events.ResetVm;
|
||||
import org.jdrupes.vmoperator.manager.events.VmChannel;
|
||||
import org.jdrupes.vmoperator.manager.events.VmDefChanged;
|
||||
|
|
@ -266,17 +266,14 @@ public class Reconciler extends Component {
|
|||
Optional.ofNullable(Reconciler.class.getPackage()
|
||||
.getImplementationVersion()).orElse("(Unknown)"));
|
||||
model.put("cr", vmDef);
|
||||
model.put("constants",
|
||||
(TemplateHashModel) new DefaultObjectWrapperBuilder(
|
||||
Configuration.VERSION_2_3_32)
|
||||
.build().getStaticModels()
|
||||
.get(Constants.class.getName()));
|
||||
// Freemarker's static models don't handle nested classes.
|
||||
model.put("constants", constantsMap(Constants.class));
|
||||
model.put("reconciler", config);
|
||||
|
||||
// Check if we have a display secret
|
||||
ListOptions options = new ListOptions();
|
||||
options.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET + ","
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME + ","
|
||||
+ "app.kubernetes.io/instance=" + vmDef.name());
|
||||
var dsStub = K8sV1SecretStub
|
||||
.list(client, vmDef.namespace(), options)
|
||||
|
|
@ -297,6 +294,30 @@ public class Reconciler extends Component {
|
|||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.EmptyCatchBlock")
|
||||
private Map<String, Object> constantsMap(Class<?> clazz) {
|
||||
@SuppressWarnings("PMD.UseConcurrentHashMap")
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Arrays.stream(clazz.getFields()).filter(f -> {
|
||||
var modifiers = f.getModifiers();
|
||||
return Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)
|
||||
&& f.getType() == String.class;
|
||||
}).forEach(f -> {
|
||||
try {
|
||||
result.put(f.getName(), f.get(null));
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
// Should not happen, ignore
|
||||
}
|
||||
});
|
||||
Arrays.stream(clazz.getClasses()).filter(c -> {
|
||||
var modifiers = c.getModifiers();
|
||||
return Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers);
|
||||
}).forEach(c -> {
|
||||
result.put(c.getSimpleName(), constantsMap(c));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private final TemplateMethodModelEx parseQuantityModel
|
||||
= new TemplateMethodModelEx() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.K8s;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
import org.jdrupes.vmoperator.common.K8sDynamicStub;
|
||||
|
|
@ -87,7 +86,7 @@ public class VmMonitor extends
|
|||
client(new K8sClient());
|
||||
|
||||
// Get all our API versions
|
||||
var ctx = K8s.context(client(), VM_OP_GROUP, "", VM_OP_KIND_VM);
|
||||
var ctx = K8s.context(client(), Crd.GROUP, "", Crd.KIND_VM);
|
||||
if (ctx.isEmpty()) {
|
||||
logger.severe(() -> "Cannot get CRD context.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ import java.util.Collection;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jdrupes.vmoperator.common.Constants;
|
||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||
import static org.jdrupes.vmoperator.common.Constants.COMP_DISPLAY_SECRET;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.Constants.DisplaySecret;
|
||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_NAME;
|
||||
import org.jdrupes.vmoperator.common.K8s;
|
||||
import org.jdrupes.vmoperator.common.K8sClient;
|
||||
|
|
@ -60,7 +60,7 @@ class BasicTests {
|
|||
waitForManager();
|
||||
|
||||
// Context for working with our CR
|
||||
var apiRes = K8s.context(client, VM_OP_GROUP, null, VM_OP_KIND_VM);
|
||||
var apiRes = K8s.context(client, Crd.GROUP, null, Crd.KIND_VM);
|
||||
assertTrue(apiRes.isPresent());
|
||||
vmsContext = apiRes.get();
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class BasicTests {
|
|||
ListOptions listOpts = new ListOptions();
|
||||
listOpts.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/instance=" + VM_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET);
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
||||
var secrets = K8sV1SecretStub.list(client, "vmop-dev", listOpts);
|
||||
for (var secret : secrets) {
|
||||
secret.delete();
|
||||
|
|
@ -138,12 +138,11 @@ class BasicTests {
|
|||
List.of("name"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"),
|
||||
Constants.VM_OP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"), VM_OP_NAME,
|
||||
List.of("annotations", "vmoperator.jdrupes.org/version"), EXISTS,
|
||||
List.of("ownerReferences", 0, "apiVersion"),
|
||||
vmsContext.getGroup() + "/" + vmsContext.getVersions().get(0),
|
||||
List.of("ownerReferences", 0, "kind"), Constants.VM_OP_KIND_VM,
|
||||
List.of("ownerReferences", 0, "kind"), Crd.KIND_VM,
|
||||
List.of("ownerReferences", 0, "name"), VM_NAME,
|
||||
List.of("ownerReferences", 0, "uid"), EXISTS);
|
||||
checkProps(config.getMetadata(), toCheck);
|
||||
|
|
@ -189,7 +188,7 @@ class BasicTests {
|
|||
ListOptions listOpts = new ListOptions();
|
||||
listOpts.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||
+ "app.kubernetes.io/instance=" + VM_NAME + ","
|
||||
+ "app.kubernetes.io/component=" + COMP_DISPLAY_SECRET);
|
||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
||||
Collection<K8sV1SecretStub> secrets = null;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
secrets = K8sV1SecretStub.list(client, "vmop-dev", listOpts);
|
||||
|
|
@ -219,8 +218,7 @@ class BasicTests {
|
|||
checkProps(pvc.getMetadata(), Map.of(
|
||||
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"),
|
||||
Constants.VM_OP_NAME));
|
||||
List.of("labels", "app.kubernetes.io/managed-by"), VM_OP_NAME));
|
||||
checkProps(pvc.getSpec(), Map.of(
|
||||
List.of("resources", "requests", "storage"),
|
||||
Quantity.fromString("1Mi")));
|
||||
|
|
@ -240,8 +238,7 @@ class BasicTests {
|
|||
checkProps(pvc.getMetadata(), Map.of(
|
||||
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"),
|
||||
Constants.VM_OP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"), VM_OP_NAME,
|
||||
List.of("annotations", "use_as"), "system-disk"));
|
||||
checkProps(pvc.getSpec(), Map.of(
|
||||
List.of("resources", "requests", "storage"),
|
||||
|
|
@ -262,8 +259,7 @@ class BasicTests {
|
|||
checkProps(pvc.getMetadata(), Map.of(
|
||||
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"),
|
||||
Constants.VM_OP_NAME));
|
||||
List.of("labels", "app.kubernetes.io/managed-by"), VM_OP_NAME));
|
||||
checkProps(pvc.getSpec(), Map.of(
|
||||
List.of("resources", "requests", "storage"),
|
||||
Quantity.fromString("1Gi")));
|
||||
|
|
@ -290,13 +286,12 @@ class BasicTests {
|
|||
List.of("labels", "app.kubernetes.io/name"), APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||
List.of("labels", "app.kubernetes.io/component"), APP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"),
|
||||
Constants.VM_OP_NAME,
|
||||
List.of("labels", "app.kubernetes.io/managed-by"), VM_OP_NAME,
|
||||
List.of("annotations", "vmrunner.jdrupes.org/cmVersion"), EXISTS,
|
||||
List.of("annotations", "vmoperator.jdrupes.org/version"), EXISTS,
|
||||
List.of("ownerReferences", 0, "apiVersion"),
|
||||
vmsContext.getGroup() + "/" + vmsContext.getVersions().get(0),
|
||||
List.of("ownerReferences", 0, "kind"), Constants.VM_OP_KIND_VM,
|
||||
List.of("ownerReferences", 0, "kind"), Crd.KIND_VM,
|
||||
List.of("ownerReferences", 0, "name"), VM_NAME,
|
||||
List.of("ownerReferences", 0, "uid"), EXISTS));
|
||||
checkProps(pod.getSpec(), Map.of(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue