Search in sources :

Example 1 with Config

use of bio.terra.cli.businessobject.Config in project terra-cli by DataBiosphere.

the class Image method execute.

/**
 * Updates the docker image id property of the global context.
 */
@Override
protected void execute() {
    Config config = Context.getConfig();
    String prevImageId = config.getDockerImageId();
    String newImageId = argGroup.useDefault ? Config.getDefaultImageId() : argGroup.imageId;
    if (!new DockerClientWrapper().checkImageExists(newImageId)) {
        ERR.printf("WARNING: Image %s was not found on the local machine. " + "Do `docker pull %s` to obtain it.%n", newImageId, newImageId);
    }
    config.setDockerImageId(newImageId);
    if (config.getDockerImageId().equals(prevImageId)) {
        OUT.println("Docker image: " + config.getDockerImageId() + " (UNCHANGED)");
    } else {
        OUT.println("Docker image: " + config.getDockerImageId() + " (CHANGED FROM " + prevImageId + ")");
    }
}
Also used : Config(bio.terra.cli.businessobject.Config) DockerClientWrapper(bio.terra.cli.app.utils.DockerClientWrapper)

Example 2 with Config

use of bio.terra.cli.businessobject.Config in project terra-cli by DataBiosphere.

the class ResourceLimit method execute.

/**
 * Updates the resources cache size property of the global context.
 */
@Override
protected void execute() {
    Config config = Context.getConfig();
    int prevMaxResources = config.getResourcesCacheSize();
    int newMaxResources = argGroup.useDefault ? Config.DEFAULT_RESOURCES_CACHE_SIZE : argGroup.max;
    if (newMaxResources <= 0) {
        throw new UserActionableException("Maximum number of resources allowed per workspace must be positive.");
    }
    config.setResourcesCacheSize(newMaxResources);
    if (config.getResourcesCacheSize() == prevMaxResources) {
        OUT.println("Max number of resources per workspace: " + config.getResourcesCacheSize() + " (UNCHANGED)");
    } else {
        OUT.println("Max number of resources per workspace: " + config.getResourcesCacheSize() + " (CHANGED FROM " + prevMaxResources + ")");
    }
}
Also used : Config(bio.terra.cli.businessobject.Config) UserActionableException(bio.terra.cli.exception.UserActionableException)

Example 3 with Config

use of bio.terra.cli.businessobject.Config in project terra-cli by DataBiosphere.

the class AppLaunch method execute.

/**
 * Updates the command runner option property of the global context.
 */
@Override
protected void execute() {
    Config config = Context.getConfig();
    Config.CommandRunnerOption prevAppLaunchOption = config.getCommandRunnerOption();
    if (CommandRunnerOption.DOCKER_CONTAINER == mode) {
        String imageId = Context.getConfig().getDockerImageId();
        if (!new DockerClientWrapper().checkImageExists(imageId)) {
            ERR.printf("WARNING: Image %s was not found on the local machine. " + "Do `docker pull %s` to obtain it.%n", imageId, imageId);
        }
    }
    config.setCommandRunnerOption(mode);
    OUT.println("App launch mode is " + config.getCommandRunnerOption() + " (" + (config.getCommandRunnerOption() == prevAppLaunchOption ? "UNCHANGED" : "CHANGED") + ").");
}
Also used : Config(bio.terra.cli.businessobject.Config) CommandRunnerOption(bio.terra.cli.businessobject.Config.CommandRunnerOption) DockerClientWrapper(bio.terra.cli.app.utils.DockerClientWrapper)

Example 4 with Config

use of bio.terra.cli.businessobject.Config in project terra-cli by DataBiosphere.

the class Browser method execute.

/**
 * Updates the browser launch option property of the global context.
 */
@Override
protected void execute() {
    Config config = Context.getConfig();
    Config.BrowserLaunchOption prevBrowserLaunchOption = config.getBrowserLaunchOption();
    config.setBrowserLaunchOption(mode);
    OUT.println("Browser launch mode for login is " + config.getBrowserLaunchOption() + " (" + (config.getBrowserLaunchOption() == prevBrowserLaunchOption ? "UNCHANGED" : "CHANGED") + ").");
}
Also used : Config(bio.terra.cli.businessobject.Config)

Example 5 with Config

use of bio.terra.cli.businessobject.Config in project terra-cli by DataBiosphere.

the class Format method execute.

@Override
protected void execute() {
    Config config = Context.getConfig();
    FormatOptions previousFormatOption = config.getFormat();
    config.setFormat(format);
    OUT.println("Output format is " + config.getFormat() + " (" + (config.getFormat() == previousFormatOption ? "UNCHANGED" : "CHANGED") + ").");
}
Also used : Config(bio.terra.cli.businessobject.Config) FormatOptions(bio.terra.cli.command.shared.options.Format.FormatOptions)

Aggregations

Config (bio.terra.cli.businessobject.Config)5 DockerClientWrapper (bio.terra.cli.app.utils.DockerClientWrapper)2 CommandRunnerOption (bio.terra.cli.businessobject.Config.CommandRunnerOption)1 FormatOptions (bio.terra.cli.command.shared.options.Format.FormatOptions)1 UserActionableException (bio.terra.cli.exception.UserActionableException)1