Skip to content

Commit

Permalink
CLI: add .env configuration file (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi authored Oct 31, 2023
1 parent c2208a2 commit fde166d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions langstream-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<platform>windows</platform>
<platform>unix</platform>
</platforms>
<environmentSetupFileName>langstream.env</environmentSetupFileName>
<programs>
<program>
<mainClass>ai.langstream.cli.LangStreamCLI</mainClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import ai.langstream.cli.LangStreamCLI;
import ai.langstream.cli.NamedProfile;
import ai.langstream.cli.api.model.Gateways;
import ai.langstream.cli.commands.VersionProvider;
import ai.langstream.cli.commands.applications.MermaidAppDiagramGenerator;
import ai.langstream.cli.commands.applications.UIAppCmd;
import ai.langstream.cli.util.DockerImageUtils;
Expand Down Expand Up @@ -143,12 +142,14 @@ public class LocalRunApplicationCmd extends BaseDockerCmd {

@CommandLine.Option(
names = {"--langstream-runtime-version"},
description = "Version of the LangStream runtime to use")
private String dockerImageVersion = VersionProvider.getMavenVersion();
description = "Version of the LangStream runtime to use",
defaultValue = "${env:LANGSTREAM_RUNTIME_DOCKER_IMAGE_VERSION}")
private String dockerImageVersion;

@CommandLine.Option(
names = {"--langstream-runtime-docker-image"},
description = "Docker image of the LangStream runtime to use")
description = "Docker image of the LangStream runtime to use",
defaultValue = "${env:LANGSTREAM_RUNTIME_DOCKER_IMAGE}")
private String dockerImageName;

@CommandLine.Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package ai.langstream.cli.commands.python;

import ai.langstream.cli.commands.VersionProvider;
import ai.langstream.cli.util.DockerImageUtils;
import java.io.File;
import java.nio.file.Files;
Expand Down Expand Up @@ -56,12 +55,14 @@ public class LoadPythonDependenciesCmd extends BasePythonCmd {

@CommandLine.Option(
names = {"--langstream-runtime-version"},
description = "Version of the LangStream runtime to use")
private String dockerImageVersion = VersionProvider.getMavenVersion();
description = "Version of the LangStream runtime to use",
defaultValue = "${env:LANGSTREAM_RUNTIME_DOCKER_IMAGE_VERSION}")
private String dockerImageVersion;

@CommandLine.Option(
names = {"--langstream-runtime-docker-image"},
description = "Docker image of the LangStream runtime to use")
description = "Docker image of the LangStream runtime to use",
defaultValue = "${env:LANGSTREAM_RUNTIME_DOCKER_IMAGE}")
private String dockerImageName;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
*/
package ai.langstream.cli.util;

import ai.langstream.cli.commands.VersionProvider;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class DockerImageUtils {

public static DockerImage computeDockerImage(
String dockerImageVersion, String dockerImageName) {
if (dockerImageVersion != null && dockerImageVersion.endsWith("-SNAPSHOT")) {
// built-from-sources, not a release
dockerImageVersion = "latest-dev";
if (dockerImageVersion == null) {
dockerImageVersion = VersionProvider.getMavenVersion();
if (dockerImageVersion != null && dockerImageVersion.endsWith("-SNAPSHOT")) {
// built-from-sources, not a release
dockerImageVersion = "latest-dev";
}
}

if (dockerImageName == null) {
Expand Down

0 comments on commit fde166d

Please sign in to comment.