Viewer ACL (#26)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled

Provide ACLs (together with general improvements) for the viewer conlet.
This commit is contained in:
Michael N. Lipp 2024-06-01 11:12:15 +02:00 committed by GitHub
parent a6525a2289
commit 659463b3b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 1664 additions and 679 deletions

View file

@ -1,76 +0,0 @@
/*
* VM-Operator
* Copyright (C) 2024 Michael N. Lipp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.manager.events;
import io.kubernetes.client.openapi.models.V1Secret;
import org.jdrupes.vmoperator.common.K8sObserver.ResponseType;
import org.jgrapes.core.Channel;
import org.jgrapes.core.Components;
import org.jgrapes.core.Event;
/**
* Indicates that a display secret has changed.
*/
@SuppressWarnings("PMD.DataClass")
public class DisplayPasswordChanged extends Event<Void> {
private final ResponseType type;
private final V1Secret secret;
/**
* Initializes a new display secret changed event.
*
* @param type the type
* @param secret the secret
*/
public DisplayPasswordChanged(ResponseType type, V1Secret secret) {
this.type = type;
this.secret = secret;
}
/**
* Returns the type.
*
* @return the type
*/
public ResponseType type() {
return type;
}
/**
* Gets the secret.
*
* @return the secret
*/
public V1Secret secret() {
return secret;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(Components.objectName(this)).append(" [")
.append(secret.getMetadata().getName()).append(' ').append(type);
if (channels() != null) {
builder.append(", channels=").append(Channel.toString(channels()));
}
builder.append(']');
return builder.toString();
}
}

View file

@ -19,40 +19,44 @@
package org.jdrupes.vmoperator.manager.events;
import java.util.Optional;
import org.jdrupes.vmoperator.common.VmDefinitionModel;
import org.jgrapes.core.Event;
/**
* Gets the current display secret.
* Gets the current display secret and optionally updates it.
*/
@SuppressWarnings("PMD.DataClass")
public class GetDisplayPassword extends Event<String> {
private final String vmName;
private final VmDefinitionModel vmDef;
/**
* Instantiates a new returns the display secret.
*
* @param vmName the vm name
* @param vmDef the vm name
*/
public GetDisplayPassword(String vmName) {
this.vmName = vmName;
public GetDisplayPassword(VmDefinitionModel vmDef) {
this.vmDef = vmDef;
}
/**
* Gets the vm name.
* Gets the vm definition.
*
* @return the vm name
* @return the vm definition
*/
public String vmName() {
return vmName;
public VmDefinitionModel vmDefinition() {
return vmDef;
}
/**
* Return the password. Should only be called when the event is completed.
* Return the password. May only be called when the event is completed.
*
* @return the optional
*/
public Optional<String> password() {
if (!isDone()) {
throw new IllegalStateException("Event is not done.");
}
return currentResults().stream().findFirst();
}
}

View file

@ -19,7 +19,7 @@
package org.jdrupes.vmoperator.manager.events;
import org.jdrupes.vmoperator.common.K8sClient;
import org.jdrupes.vmoperator.common.K8sDynamicModel;
import org.jdrupes.vmoperator.common.VmDefinitionModel;
import org.jgrapes.core.Channel;
import org.jgrapes.core.EventPipeline;
import org.jgrapes.core.Subchannel.DefaultSubchannel;
@ -32,7 +32,7 @@ public class VmChannel extends DefaultSubchannel {
private final EventPipeline pipeline;
private final K8sClient client;
private K8sDynamicModel vmDefinition;
private VmDefinitionModel vmDefinition;
private long generation = -1;
/**
@ -56,7 +56,7 @@ public class VmChannel extends DefaultSubchannel {
* @return the watch channel
*/
@SuppressWarnings("PMD.LinguisticNaming")
public VmChannel setVmDefinition(K8sDynamicModel definition) {
public VmChannel setVmDefinition(VmDefinitionModel definition) {
this.vmDefinition = definition;
return this;
}
@ -66,7 +66,7 @@ public class VmChannel extends DefaultSubchannel {
*
* @return the json object
*/
public K8sDynamicModel vmDefinition() {
public VmDefinitionModel vmDefinition() {
return vmDefinition;
}

View file

@ -18,8 +18,8 @@
package org.jdrupes.vmoperator.manager.events;
import org.jdrupes.vmoperator.common.K8sDynamicModel;
import org.jdrupes.vmoperator.common.K8sObserver;
import org.jdrupes.vmoperator.common.VmDefinitionModel;
import org.jgrapes.core.Channel;
import org.jgrapes.core.Components;
import org.jgrapes.core.Event;
@ -36,7 +36,7 @@ public class VmDefChanged extends Event<Void> {
private final K8sObserver.ResponseType type;
private final boolean specChanged;
private final K8sDynamicModel vmDef;
private final VmDefinitionModel vmDef;
/**
* Instantiates a new VM changed event.
@ -46,7 +46,7 @@ public class VmDefChanged extends Event<Void> {
* @param vmDefinition the VM definition
*/
public VmDefChanged(K8sObserver.ResponseType type, boolean specChanged,
K8sDynamicModel vmDefinition) {
VmDefinitionModel vmDefinition) {
this.type = type;
this.specChanged = specChanged;
this.vmDef = vmDefinition;
@ -73,7 +73,7 @@ public class VmDefChanged extends Event<Void> {
*
* @return the object.
*/
public K8sDynamicModel vmDefinition() {
public VmDefinitionModel vmDefinition() {
return vmDef;
}