Skip to content
Snippets Groups Projects
Commit 69f62bb4 authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Implemented local bash command execution

parent 8b037a8d
Branches
No related tags found
1 merge request!133Resolve "Remove nmaas-helm interaction"
Pipeline #93147 passed
...@@ -2,7 +2,7 @@ plugins { ...@@ -2,7 +2,7 @@ plugins {
id 'java' id 'java'
id 'idea' id 'idea'
id 'jacoco' id 'jacoco'
id 'org.springframework.boot' version '3.4.3' id 'org.springframework.boot' version '3.4.4'
id 'io.spring.dependency-management' version '1.1.7' id 'io.spring.dependency-management' version '1.1.7'
id 'com.gorylenko.gradle-git-properties' version '2.4.2' id 'com.gorylenko.gradle-git-properties' version '2.4.2'
id 'org.sonarqube' version '6.0.1.5171' id 'org.sonarqube' version '6.0.1.5171'
...@@ -30,11 +30,11 @@ gitProperties { ...@@ -30,11 +30,11 @@ gitProperties {
protobuf { protobuf {
protoc { protoc {
artifact = 'com.google.protobuf:protoc:4.29.3' artifact = 'com.google.protobuf:protoc:4.30.2'
} }
plugins { plugins {
grpc { grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.69.1' artifact = 'io.grpc:protoc-gen-grpc-java:1.71.0'
} }
} }
generateProtoTasks { generateProtoTasks {
...@@ -128,14 +128,14 @@ dependencies { ...@@ -128,14 +128,14 @@ dependencies {
// Kubernetes API client // Kubernetes API client
implementation('io.fabric8:kubernetes-client:6.13.5') implementation('io.fabric8:kubernetes-client:6.13.5')
implementation('com.google.protobuf:protobuf-java:4.29.3') implementation('com.google.protobuf:protobuf-java:4.30.2')
implementation('io.grpc:grpc-netty-shaded:1.69.1') implementation('io.grpc:grpc-netty-shaded:1.71.0')
implementation('io.grpc:grpc-protobuf:1.69.1') implementation('io.grpc:grpc-protobuf:1.71.0')
implementation('io.grpc:grpc-stub:1.69.1') implementation('io.grpc:grpc-stub:1.71.0')
implementation('com.opencsv:opencsv:5.9') implementation('com.opencsv:opencsv:5.9')
testImplementation('org.mockito:mockito-inline:5.2.0') testImplementation('org.mockito:mockito-core:5.16.1')
testImplementation('org.springframework.boot:spring-boot-starter-test') testImplementation('org.springframework.boot:spring-boot-starter-test')
integrationTestImplementation('org.springframework.boot:spring-boot-starter-test') integrationTestImplementation('org.springframework.boot:spring-boot-starter-test')
......
Host nmaas-helm
Hostname nmaas-helm
IdentityFile ~/.ssh/id_rsa
User helm
package net.geant.nmaas.utils.bash; package net.geant.nmaas.utils.bash;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@Slf4j
@Component @Component
public class DefaultCommandExecutor implements CommandExecutor { public class DefaultCommandExecutor implements CommandExecutor {
@Override @Override
public void execute(Command command) { public void execute(Command command) throws CommandExecutionException {
try {
new ProcessBuilder(command.asString()).start();
} catch (IOException e) {
throw new CommandExecutionException(e.getMessage());
}
} }
@Override @Override
public String executeWithOutput(Command command) throws CommandExecutionException { public String executeWithOutput(Command command) throws CommandExecutionException {
return ""; try {
Process process = new ProcessBuilder(command.asString()).start();
final String output = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
log.debug("Output: {}", output);
return output;
} catch (IOException e) {
throw new CommandExecutionException(e.getMessage());
}
} }
} }
package net.geant.nmaas.utils.bash;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.function.Predicate;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class DefaultCommandExecutorTest {
private final CommandExecutor executor = new DefaultCommandExecutor();
@Test
void shouldRunHelmCommand() throws IOException {
String output = executor.executeWithOutput(new Command() {
@Override
public String asString() {
return "helm";
}
@Override
public Predicate<String> isOutputCorrect() {
return null;
}
});
assertNotNull(output);
}
}
...@@ -103,8 +103,6 @@ jwt.resetSigningKey=qCR0dochH55skij2aHltXE3Sh5IvgrY87wI4MACoa8aMYeFiCA0jWek9KYvE ...@@ -103,8 +103,6 @@ jwt.resetSigningKey=qCR0dochH55skij2aHltXE3Sh5IvgrY87wI4MACoa8aMYeFiCA0jWek9KYvE
jwt.resetTokenValidFor=1800000 jwt.resetTokenValidFor=1800000
jwt.resetTokenRegistrationValid=86400000 jwt.resetTokenRegistrationValid=86400000
# ------------------ # # ------------------ #
# Helm configuration # # Helm configuration #
# ------------------ # # ------------------ #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment