-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(version): update to version 'v0.8.0'.
- Loading branch information
Showing
298 changed files
with
6,843 additions
and
1,330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Match the .editorconfig | ||
* text=auto eol=lf | ||
|
||
# Scripts | ||
*.bat text eol=crlf | ||
*.sh text eol=lf | ||
|
||
# Gradle wrapper | ||
/gradlew text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
cli/src/main/java/io/kestra/cli/commands/flows/FlowExpandCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.kestra.cli.commands.flows; | ||
|
||
import io.kestra.cli.AbstractCommand; | ||
import io.kestra.core.models.flows.Flow; | ||
import io.kestra.core.models.validations.ModelValidator; | ||
import io.kestra.core.serializers.YamlFlowParser; | ||
import jakarta.inject.Inject; | ||
import picocli.CommandLine; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@CommandLine.Command( | ||
name = "expand", | ||
description = "expand a flow" | ||
) | ||
public class FlowExpandCommand extends AbstractCommand { | ||
|
||
@CommandLine.Parameters(index = "0", description = "the flow file to expand") | ||
private Path file; | ||
|
||
@Inject | ||
private YamlFlowParser yamlFlowParser; | ||
|
||
@Inject | ||
private ModelValidator modelValidator; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
super.call(); | ||
String content = IncludeHelperExpander.expand(Files.readString(file), file.getParent()); | ||
Flow flow = yamlFlowParser.parse(content, Flow.class); | ||
modelValidator.validate(flow); | ||
stdOut(content); | ||
return 0; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
cli/src/main/java/io/kestra/cli/commands/flows/IncludeHelperExpander.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.kestra.cli.commands.flows; | ||
|
||
import com.google.common.io.Files; | ||
import lombok.SneakyThrows; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public abstract class IncludeHelperExpander { | ||
|
||
public static String expand(String value, Path directory) throws IOException { | ||
return value.lines() | ||
.map(line -> line.contains("[[>") && line.contains("]]") ? expandLine(line, directory) : line) | ||
.collect(Collectors.joining("\n")); | ||
} | ||
|
||
@SneakyThrows | ||
private static String expandLine(String line, Path directory) { | ||
String prefix = line.substring(0, line.indexOf("[[>")); | ||
String suffix = line.substring(line.indexOf("]]") + 2, line.length()); | ||
String file = line.substring(line.indexOf("[[>") + 3 , line.indexOf("]]")).strip(); | ||
Path includePath = directory.resolve(file); | ||
List<String> include = Files.readLines(includePath.toFile(), Charset.defaultCharset()); | ||
|
||
// handle single line directly with the suffix (should be between quotes or double-quotes | ||
if(include.size() == 1) { | ||
String singleInclude = include.get(0); | ||
return prefix + singleInclude + suffix; | ||
} | ||
|
||
// multi-line will be expanded with the prefix but no suffix | ||
return include.stream() | ||
.map(includeLine -> prefix + includeLine) | ||
.collect(Collectors.joining("\n")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.