com.google.cloud.tools.managedcloudsdk.Version Java Examples

The following examples show how to use com.google.cloud.tools.managedcloudsdk.Version. 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: SdkInstaller.java    From appengine-plugins-core with Apache License 2.0 6 votes vote down vote up
/**
 * Configure and create a new Installer instance.
 *
 * @param managedSdkDirectory home directory of google cloud java managed cloud SDKs
 * @param version version of the Cloud SDK we want to install
 * @param osInfo target operating system for installation
 * @param userAgentString user agent string for https requests
 * @param usageReporting enable client side usage reporting on gcloud
 * @return a new configured Cloud SDK Installer
 */
public static SdkInstaller newInstaller(
    Path managedSdkDirectory,
    Version version,
    OsInfo osInfo,
    String userAgentString,
    boolean usageReporting) {
  DownloaderFactory downloaderFactory = new DownloaderFactory(userAgentString);
  ExtractorFactory extractorFactory = new ExtractorFactory();

  InstallerFactory installerFactory =
      version == Version.LATEST ? new InstallerFactory(osInfo, usageReporting) : null;

  FileResourceProviderFactory fileResourceProviderFactory =
      new FileResourceProviderFactory(version, osInfo, managedSdkDirectory);

  return new SdkInstaller(
      fileResourceProviderFactory, downloaderFactory, extractorFactory, installerFactory);
}
 
Example #2
Source File: FileResourceProviderFactory.java    From appengine-plugins-core with Apache License 2.0 6 votes vote down vote up
public FileResourceProvider newFileResourceProvider() throws MalformedURLException {
  Path downloads = managedSdkDirectory.resolve("downloads");
  if (version.equals(Version.LATEST)) {
    return new FileResourceProvider(
        new URL(LATEST_BASE_URL + getLatestFilename()),
        downloads.resolve(getLatestFilename()),
        managedSdkDirectory.resolve(version.getVersion()),
        getGcloudExecutableName());
  } else { // versioned
    return new FileResourceProvider(
        new URL(VERSIONED_BASE_URL + getVersionedFilename()),
        downloads.resolve(getVersionedFilename()),
        managedSdkDirectory.resolve(version.getVersion()),
        getGcloudExecutableName());
  }
}
 
Example #3
Source File: FileResourceProviderFactoryTest.java    From appengine-plugins-core with Apache License 2.0 6 votes vote down vote up
@Test
public void testNewFileResourceProvider_latest() throws MalformedURLException {
  FileResourceProviderFactory factory =
      new FileResourceProviderFactory(Version.LATEST, osInfo, fakeSdkHome);
  FileResourceProvider provider = factory.newFileResourceProvider();

  Assert.assertEquals(
      new URL(FileResourceProviderFactory.LATEST_BASE_URL + latestFilename),
      provider.getArchiveSource());
  Assert.assertEquals(fakeDownloadsDir.resolve(latestFilename), provider.getArchiveDestination());
  Assert.assertEquals(fakeSdkHome.resolve("LATEST"), provider.getArchiveExtractionDestination());
  Assert.assertEquals(
      fakeSdkHome.resolve("LATEST").resolve("google-cloud-sdk"), provider.getExtractedSdkHome());
  Assert.assertEquals(
      fakeSdkHome
          .resolve("LATEST")
          .resolve("google-cloud-sdk")
          .resolve("bin")
          .resolve(gcloudExecutable),
      provider.getExtractedGcloud());
}
 
Example #4
Source File: ManagedCloudSdkFactory.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
/** Build a new ManagedCloudSdk from a given version. */
public ManagedCloudSdk newManagedSdk()
    throws UnsupportedOsException, BadCloudSdkVersionException {
  if (Strings.isNullOrEmpty(version)) {
    return ManagedCloudSdk.newManagedSdk();
  } else {
    return ManagedCloudSdk.newManagedSdk(new Version(version));
  }
}
 
Example #5
Source File: ManagedCloudSdkFactoryTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testNewManagedSdk_specific()
    throws UnsupportedOsException, BadCloudSdkVersionException {
  ManagedCloudSdk sdk = new ManagedCloudSdkFactory("191.0.0").newManagedSdk();
  Assert.assertEquals(
      ManagedCloudSdk.newManagedSdk(new Version("191.0.0")).getSdkHome(), sdk.getSdkHome());
}
 
Example #6
Source File: FileResourceProviderFactoryTest.java    From appengine-plugins-core with Apache License 2.0 5 votes vote down vote up
@Test
public void testNewFileResourceProvider_versioned()
    throws MalformedURLException, BadCloudSdkVersionException {
  FileResourceProviderFactory factory =
      new FileResourceProviderFactory(new Version("123.123.123"), osInfo, fakeSdkHome);
  FileResourceProvider provider = factory.newFileResourceProvider();

  Assert.assertEquals(
      new URL(
          FileResourceProviderFactory.VERSIONED_BASE_URL
              + "google-cloud-sdk-123.123.123-"
              + versionedFilenameTail),
      provider.getArchiveSource());
  Assert.assertEquals(
      fakeDownloadsDir.resolve("google-cloud-sdk-123.123.123-" + versionedFilenameTail),
      provider.getArchiveDestination());
  Assert.assertEquals(
      fakeSdkHome.resolve("123.123.123"), provider.getArchiveExtractionDestination());
  Assert.assertEquals(
      fakeSdkHome.resolve("123.123.123").resolve("google-cloud-sdk"),
      provider.getExtractedSdkHome());
  Assert.assertEquals(
      fakeSdkHome
          .resolve("123.123.123")
          .resolve("google-cloud-sdk")
          .resolve("bin")
          .resolve(gcloudExecutable),
      provider.getExtractedGcloud());
}
 
Example #7
Source File: CloudSdkDownloader.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
static Function<String, ManagedCloudSdk> newManagedSdkFactory() {
  return (version) -> {
    try {
      if (Strings.isNullOrEmpty(version)) {
        return ManagedCloudSdk.newManagedSdk();
      } else {
        return ManagedCloudSdk.newManagedSdk(new Version(version));
      }
    } catch (UnsupportedOsException | BadCloudSdkVersionException ex) {
      throw new RuntimeException(ex);
    }
  };
}
 
Example #8
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testNewManagedSdk_specific()
    throws UnsupportedOsException, BadCloudSdkVersionException {
  ManagedCloudSdk sdk = CloudSdkDownloader.newManagedSdkFactory().apply("191.0.0");
  Assert.assertEquals(
      ManagedCloudSdk.newManagedSdk(new Version("191.0.0")).getSdkHome(), sdk.getSdkHome());
}
 
Example #9
Source File: FileResourceProviderFactory.java    From appengine-plugins-core with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new factory.
 *
 * @param version cloud SDK version
 * @param osInfo the target operating system information
 * @param managedSdkDirectory the managed sdk base directory
 */
public FileResourceProviderFactory(Version version, OsInfo osInfo, Path managedSdkDirectory) {
  this.version = version;
  os = osInfo;
  this.managedSdkDirectory = managedSdkDirectory;
}