Skip to content

Commit

Permalink
Azure Functions maven plugin port
Browse files Browse the repository at this point in the history
integration testing

finish quarkus:run and integration tests

quarkus:run gradle

cli run command

implement deploy

afk rebase'

azf deploy

azf deploy working

azf more fixes

azf service-principal
  • Loading branch information
patriot1burke committed Apr 26, 2023
1 parent aee982d commit cda7949
Show file tree
Hide file tree
Showing 40 changed files with 2,328 additions and 55 deletions.
22 changes: 21 additions & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<aws-xray.version>2.14.0</aws-xray.version>
<azure-functions-java-library.version>2.2.0</azure-functions-java-library.version>
<azure-functions-java-spi.version>1.0.0</azure-functions-java-spi.version>
<azure.toolkit-lib.version>0.27.0</azure.toolkit-lib.version>
<kotlin.version>1.8.10</kotlin.version>
<kotlin.coroutine.version>1.6.4</kotlin.coroutine.version>
<kotlin-serialization.version>1.5.0</kotlin-serialization.version>
Expand Down Expand Up @@ -6056,7 +6057,26 @@
<artifactId>azure-functions-java-spi</artifactId>
<version>${azure-functions-java-spi.version}</version>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-toolkit-common-lib</artifactId>
<version>${azure.toolkit-lib.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-toolkit-auth-lib</artifactId>
<version>${azure.toolkit-lib.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-toolkit-appservice-lib</artifactId>
<version>${azure.toolkit-lib.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-toolkit-applicationinsights-lib</artifactId>
<version>${azure.toolkit-lib.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions core/builder/src/main/java/io/quarkus/builder/BuildException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.builder;

import java.util.Collections;
import java.util.List;

import org.wildfly.common.Assert;
Expand All @@ -25,6 +26,16 @@ public BuildException(final List<Diagnostic> diagnostics) {
this.diagnostics = diagnostics;
}

/**
* Constructs a new {@code DeploymentException} instance. The diagnostics is left blank ({@code null}), and no
* cause is specified.
*
* @param msg the message
*/
public BuildException(String msg) {
this(msg, Collections.emptyList());
}

/**
* Constructs a new {@code DeploymentException} instance with an initial message. No
* cause is specified.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.deployment.cmd;

import io.quarkus.builder.item.MultiBuildItem;

public final class DeployCommandActionBuildItem extends MultiBuildItem {
private final String commandName;
private final boolean successful;

public DeployCommandActionBuildItem(String commandName, boolean successful) {
this.commandName = commandName;
this.successful = successful;
}

public String getCommandName() {
return commandName;
}

public boolean isSuccessful() {
return successful;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkus.deployment.cmd;

import java.util.List;

import io.quarkus.builder.item.SimpleBuildItem;

public final class DeployCommandActionResultBuildItem extends SimpleBuildItem {
private final List<DeployCommandActionBuildItem> commands;

public DeployCommandActionResultBuildItem(List<DeployCommandActionBuildItem> commands) {
this.commands = commands;
}

public List<DeployCommandActionBuildItem> getCommands() {
return commands;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.deployment.cmd;

import io.quarkus.builder.item.MultiBuildItem;

/**
* Way for maven and gradle plugins to discover if any declared extensions
* support quarkus deploy
*/
public final class DeployCommandDeclarationBuildItem extends MultiBuildItem {
private final String name;

public DeployCommandDeclarationBuildItem(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.deployment.cmd;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import io.quarkus.builder.BuildResult;

public class DeployCommandDeclarationHandler implements BiConsumer<Object, BuildResult> {

@Override
public void accept(Object o, BuildResult buildResult) {
DeployCommandDeclarationResultBuildItem result = buildResult.consume(DeployCommandDeclarationResultBuildItem.class);

// FYI: AugmentAction.performCustomBuild runs in its own classloader
// so we can only pass back instances of those classes in the system classloader

Consumer<List<String>> consumer = (Consumer<List<String>>) o;
consumer.accept(result.getCommands());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkus.deployment.cmd;

import java.util.List;

import io.quarkus.builder.item.SimpleBuildItem;

public final class DeployCommandDeclarationResultBuildItem extends SimpleBuildItem {
private final List<String> commands;

public DeployCommandDeclarationResultBuildItem(List<String> commands) {
this.commands = commands;
}

public List<String> getCommands() {
return commands;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.deployment.cmd;

import java.util.function.BiConsumer;
import java.util.function.Consumer;

import io.quarkus.builder.BuildResult;

public class DeployCommandHandler implements BiConsumer<Object, BuildResult> {

@Override
public void accept(Object o, BuildResult buildResult) {
DeployCommandActionResultBuildItem result = buildResult.consume(DeployCommandActionResultBuildItem.class);

// FYI: AugmentAction.performCustomBuild runs in its own classloader
// so we can only pass back instances of those classes in the system classloader

Consumer<Boolean> consumer = (Consumer<Boolean>) o;
if (result.getCommands().isEmpty()) {
consumer.accept(false);
} else {
consumer.accept(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.quarkus.deployment.cmd;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import io.quarkus.deployment.annotations.BuildStep;

public class DeployCommandProcessor {
@BuildStep
public DeployCommandDeclarationResultBuildItem commandDeclaration(List<DeployCommandDeclarationBuildItem> cmds) {
if (cmds == null || cmds.isEmpty()) {
return new DeployCommandDeclarationResultBuildItem(Collections.emptyList());
}
return new DeployCommandDeclarationResultBuildItem(
cmds.stream().map(item -> item.getName()).collect(Collectors.toList()));
}

@BuildStep
public DeployCommandActionResultBuildItem commandExecution(List<DeployCommandActionBuildItem> cmds) {
if (cmds == null || cmds.isEmpty()) {
return new DeployCommandActionResultBuildItem(Collections.emptyList());
}
return new DeployCommandActionResultBuildItem(cmds);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.quarkus.deployment.cmd;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public class DeployConfig {
/**
* Deployment target
*/
@ConfigItem
public Optional<String> target;

public boolean isEnabled(String t) {
return target.isEmpty() || target.get().equals(t);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.quarkus.deployment.cmd;

import java.nio.file.Path;
import java.util.List;

import io.quarkus.builder.item.MultiBuildItem;

public final class RunCommandActionBuildItem extends MultiBuildItem {
private final String commandName;
private final List<String> args;
private Path workingDirectory;
private String startedExpression;
private Path logFile;
private boolean needsLogfile;

public RunCommandActionBuildItem(String commandName, List<String> args, Path workingDirectory, String startedExpression,
Path logFile,
boolean needsLogfile) {
this.args = args;
this.commandName = commandName;
this.workingDirectory = workingDirectory;
this.startedExpression = startedExpression;
this.logFile = logFile;
this.needsLogfile = needsLogfile;
}

public String getCommandName() {
return commandName;
}

public String getStartedExpression() {
return startedExpression;
}

public Path getWorkingDirectory() {
return workingDirectory;
}

public List<String> getArgs() {
return args;
}

public Path getLogFile() {
return logFile;
}

public boolean isNeedsLogfile() {
return needsLogfile;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkus.deployment.cmd;

import java.util.List;

import io.quarkus.builder.item.SimpleBuildItem;

public final class RunCommandActionResultBuildItem extends SimpleBuildItem {
private final List<RunCommandActionBuildItem> commands;

public RunCommandActionResultBuildItem(List<RunCommandActionBuildItem> commands) {
this.commands = commands;
}

public List<RunCommandActionBuildItem> getCommands() {
return commands;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.deployment.cmd;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import io.quarkus.builder.BuildResult;

public class RunCommandHandler implements BiConsumer<Object, BuildResult> {

@Override
public void accept(Object o, BuildResult buildResult) {
RunCommandActionResultBuildItem result = buildResult.consume(RunCommandActionResultBuildItem.class);

// FYI: AugmentAction.performCustomBuild runs in its own classloader
// so we can only pass back instances of those classes in the system classloader

Consumer<Map<String, List>> consumer = (Consumer<Map<String, List>>) o;
Map<String, List> entries = new HashMap<>();
for (RunCommandActionBuildItem item : result.getCommands()) {
LinkedList itemList = new LinkedList();
addLaunchCommand(itemList, item);
entries.put(item.getCommandName(), itemList);
}
consumer.accept(entries);
}

private void addLaunchCommand(List list, RunCommandActionBuildItem item) {
list.add(item.getArgs());
list.add(item.getWorkingDirectory());
list.add(item.getStartedExpression());
list.add(item.isNeedsLogfile());
list.add(item.getLogFile());
}
}
Loading

0 comments on commit cda7949

Please sign in to comment.