com.google.cloud.tools.appengine.operations.Gcloud Java Examples

The following examples show how to use com.google.cloud.tools.appengine.operations.Gcloud. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudSdkOperations.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Operations factory for Cloud Sdk based actions.
 *
 * @param cloudSdkHome path to cloud sdk
 * @param credentialFile optional path to a credential file
 * @throws CloudSdkNotFoundException when cloud sdk path cannot be validated
 */
public CloudSdkOperations(File cloudSdkHome, File credentialFile)
    throws CloudSdkNotFoundException {
  cloudSdk = new CloudSdk.Builder().sdkPath(cloudSdkHome.toPath()).build();
  gcloud =
      Gcloud.builder(cloudSdk)
          .setCredentialFile(NullSafe.convert(credentialFile, File::toPath))
          .setMetricsEnvironment(
              getClass().getPackage().getImplementationTitle(),
              getClass().getPackage().getImplementationVersion())
          .build();
}
 
Example #2
Source File: AbstractMojoIntegrationTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
protected void deleteService(String service)
    throws CloudSdkNotFoundException, IOException, ProcessHandlerException {
  CloudSdk cloudSdk = new CloudSdk.Builder().build();
  Gcloud.builder(cloudSdk)
      .build()
      .runCommand(Arrays.asList("app", "services", "delete", service));
}
 
Example #3
Source File: CloudSdkAppEngineFactory.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
/** Return a Gcloud instance using global configuration. */
public Gcloud getGcloud() {
  return Gcloud.builder(buildCloudSdkMinimal())
      .setMetricsEnvironment(mojo.getArtifactId(), mojo.getArtifactVersion())
      .setCredentialFile(mojo.getServiceAccountKeyFile())
      .build();
}
 
Example #4
Source File: CloudSdkProcessWrapper.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up a {@link CloudSdk} to be used for App Engine deploy.
 */
public Deployment getAppEngineDeployment(Path credentialFile,
    MessageConsoleStream normalOutputStream) throws CloudSdkNotFoundException {
  Preconditions.checkNotNull(credentialFile, "credential required for deploying");
  Preconditions.checkArgument(Files.exists(credentialFile), "non-existing credential file");
  Preconditions.checkState(!initialized, "process wrapper already set up");
  initialized = true;

  CloudSdk cloudSdk = new CloudSdk.Builder().build();
  Gcloud gcloud = Gcloud.builder(cloudSdk)
      .setCredentialFile(credentialFile.toFile().toPath())
      .setMetricsEnvironment(CloudToolsInfo.METRICS_NAME, CloudToolsInfo.getToolsVersion())
      .setShowStructuredLogs("always")  // turns on gcloud structured log
      .setOutputFormat("json")  // Deploy result will be in JSON.
      .build();

  // Gcloud sends structured deploy result (in JSON format) to stdout, so prepare to capture that.
  stdOutCaptor = StringBuilderProcessOutputLineListener.newListenerWithNewlines();
  // Gcloud sends structured gcloud logs (in JSON format) to stderr, so prepare to capture them.
  gcloudErrorMessageCollector = new GcloudStructuredLogErrorMessageCollector();

  ProcessHandler processHandler = LegacyProcessHandler.builder()
      .setStartListener(this::storeProcessObject)
      .setExitListener(this::recordProcessExitCode)
      // Gcloud sends normal operation output to stderr.
      .addStdErrLineListener(new MessageConsoleWriterListener(normalOutputStream))
      .addStdErrLineListener(gcloudErrorMessageCollector)
      .addStdOutLineListener(stdOutCaptor)
      .build();

  return gcloud.newDeployment(processHandler);
}
 
Example #5
Source File: AppEngineAppYamlPluginIntegrationTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
private static void deleteProject()
    throws UnsupportedOsException, CloudSdkNotFoundException, IOException,
        ProcessHandlerException {
  Path sdkHome = ManagedCloudSdk.newManagedSdk().getSdkHome();
  CloudSdk cloudSdk = new CloudSdk.Builder().sdkPath(sdkHome).build();
  Gcloud.builder(cloudSdk)
      .build()
      .runCommand(Arrays.asList("app", "services", "delete", "appyaml-project", "--quiet"));
}
 
Example #6
Source File: AppEngineStandardPluginIntegrationTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
private static void deleteProject()
    throws UnsupportedOsException, CloudSdkNotFoundException, IOException,
        ProcessHandlerException {
  Path sdkHome = ManagedCloudSdk.newManagedSdk().getSdkHome();
  CloudSdk cloudSdk = new CloudSdk.Builder().sdkPath(sdkHome).build();
  Gcloud.builder(cloudSdk)
      .build()
      .runCommand(Arrays.asList("app", "services", "delete", "standard-project", "--quiet"));
}
 
Example #7
Source File: DeployQueueTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #8
Source File: DeployAllTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #9
Source File: DeployDosTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #10
Source File: DeployIndexTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #11
Source File: CloudSdkOperations.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public Gcloud getGcloud() {
  return gcloud;
}
 
Example #12
Source File: CloudSdkLoginTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #13
Source File: DeployCronTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #14
Source File: DeployTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #15
Source File: DeployDispatchTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #16
Source File: GenRepoInfoFileTask.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
public void setGcloud(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #17
Source File: ConfigReader.java    From app-maven-plugin with Apache License 2.0 4 votes vote down vote up
ConfigReader(Gcloud gcloud) {
  this.gcloud = gcloud;
}
 
Example #18
Source File: GcloudTask.java    From app-gradle-plugin with Apache License 2.0 votes vote down vote up
public abstract void setGcloud(Gcloud gcloud);