Skip to content

Commit

Permalink
feat(provider/gae): Modify deploy description and validators for arti…
Browse files Browse the repository at this point in the history
…facts.
  • Loading branch information
jtk54 committed Oct 5, 2017
1 parent a1bd15b commit 98bfb0c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
apply plugin: 'groovy'

ext {
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.111.0'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.111.1'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
1 change: 1 addition & 0 deletions clouddriver-appengine/clouddriver-appengine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies {
compile spinnaker.dependency("frigga")
compile spinnaker.dependency("bootActuator")
compile spinnaker.dependency("bootWeb")
compile spinnaker.dependency("korkArtifacts")

// TODO(dpeach): move to spinnaker/spinnaker-dependencies.
compile "com.google.apis:google-api-services-appengine:v1-rev4-1.22.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package com.netflix.spinnaker.clouddriver.appengine.deploy.ops

import com.netflix.spinnaker.clouddriver.appengine.AppengineJobExecutor
import com.netflix.spinnaker.clouddriver.appengine.gcsClient.AppengineGcsRepositoryClient
import com.netflix.spinnaker.clouddriver.appengine.deploy.AppengineMutexRepository
import com.netflix.spinnaker.clouddriver.appengine.deploy.AppengineServerGroupNameResolver
import com.netflix.spinnaker.clouddriver.appengine.deploy.description.DeployAppengineDescription
import com.netflix.spinnaker.clouddriver.appengine.deploy.exception.AppengineOperationException
import com.netflix.spinnaker.clouddriver.appengine.storage.config.StorageConfigurationProperties
import com.netflix.spinnaker.clouddriver.appengine.gcsClient.AppengineGcsRepositoryClient
import com.netflix.spinnaker.clouddriver.appengine.storage.GcsStorageService
import com.netflix.spinnaker.clouddriver.appengine.storage.config.StorageConfigurationProperties
import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
import com.netflix.spinnaker.clouddriver.deploy.DeploymentResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DeployAppengineDescriptionValidator extends DescriptionValidator<DeployApp
helper.validateStack(description.stack, "stack")
helper.validateDetails(description.freeFormDetails, "freeFormDetails")
helper.validateNotEmpty(description.repositoryUrl, "repositoryUrl")

if (!(description.configFilepaths || description.configFiles)) {
helper.validateNotEmpty(description.configFilepaths, "configFilepaths")
helper.validateNotEmpty(description.configFiles, "configFiles")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import com.netflix.spinnaker.clouddriver.appengine.AppengineJobExecutor
import com.netflix.spinnaker.clouddriver.appengine.model.AppengineRepositoryClient
import com.netflix.spinnaker.clouddriver.appengine.storage.GcsStorageService
import com.netflix.spinnaker.clouddriver.appengine.storage.StorageUtils

import groovy.transform.TupleConstructor
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
import org.apache.commons.io.IOUtils

@TupleConstructor
class AppengineGcsRepositoryClient implements AppengineRepositoryClient {
Expand All @@ -46,13 +47,29 @@ class AppengineGcsRepositoryClient implements AppengineRepositoryClient {
}

def dest = targetDirectory + File.separator + applicationDirectoryRoot
def fullPath = repositoryUrl.substring(gsPrefix.length()) + '/' + applicationDirectoryRoot
def slash = fullPath.indexOf("/");
def bucketName = fullPath.substring(0, slash);
def bucketPath = fullPath.substring(slash + 1);

def fullPath = repositoryUrl.substring(gsPrefix.length())
if (applicationDirectoryRoot) {
fullPath + '/' + applicationDirectoryRoot
}
def slash = fullPath.indexOf("/")
def bucketName = fullPath.substring(0, slash)
def bucketPath = fullPath.substring(slash + 1)

if (fullPath.endsWith(".tar")) {
StorageUtils.untarStreamToPath(storage.openObjectStream(bucketName, bucketPath), dest)
InputStream tas = storage.openObjectStream(bucketName, bucketPath)

// NOTE: We write the tar file out to an intermediate temp file because the tar input stream
// directly from openObjectStream() closes unexpectedly when accessed from untarStreamToPath()
// for some reason.
File tempFile = File.createTempFile("app", "tar")
FileOutputStream fos = new FileOutputStream(tempFile)
IOUtils.copy(tas, fos)
tas.close()
fos.close()

StorageUtils.untarStreamToPath(new FileInputStream(tempFile), dest)
tempFile.delete()
} else {
storage.visitObjects(bucketName, bucketPath, { obj -> storage.downloadStorageObject(obj, dest) })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,25 @@
package com.netflix.spinnaker.clouddriver.appengine.storage;

import com.netflix.spinnaker.clouddriver.appengine.storage.config.StorageConfigurationProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.security.GeneralSecurityException;


@Configuration
@EnableConfigurationProperties
@EnableScheduling
@ConditionalOnProperty("storage.gcs.enabled")
@EnableConfigurationProperties(StorageConfigurationProperties.class)
@EnableScheduling
class StorageConfiguration {
@Autowired
StorageConfigurationProperties storageAccountInfo;

@Bean
@ConfigurationProperties("storage.gcs")
StorageConfigurationProperties storageConfigurationProperties() {
return new StorageConfigurationProperties();
}

@Bean
GcsStorageService.Factory storageServiceFactory(String clouddriverUserAgentApplicationName) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
package com.netflix.spinnaker.clouddriver.appengine.storage.config;

import groovy.transform.ToString;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import retrofit.client.Response;
import retrofit.mime.TypedByteArray;

import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

import lombok.Data;

@Data
@ConfigurationProperties("storage.gcs")
public class StorageConfigurationProperties {
@Data
@ToString(includeNames = true)
Expand Down

0 comments on commit 98bfb0c

Please sign in to comment.