From 1fcf4d39683c39acbf4523480ff63247aae47508 Mon Sep 17 00:00:00 2001 From: Zach Smith Date: Wed, 12 Sep 2018 17:14:53 -0700 Subject: Add project to AliCloud platform --- .../src/main/scala/xyz/driver/core/init/CloudServices.scala | 6 +++--- core-init/src/main/scala/xyz/driver/core/init/Platform.scala | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'core-init') diff --git a/core-init/src/main/scala/xyz/driver/core/init/CloudServices.scala b/core-init/src/main/scala/xyz/driver/core/init/CloudServices.scala index 8419f90..8c51e38 100644 --- a/core-init/src/main/scala/xyz/driver/core/init/CloudServices.scala +++ b/core-init/src/main/scala/xyz/driver/core/init/CloudServices.scala @@ -76,8 +76,8 @@ trait CloudServices extends AkkaBootable { self => platform match { case p @ Platform.GoogleCloud(keyfile, _) => GcsBlobStorage.fromKeyfile(keyfile, s"${p.project}-$bucketName") - case Platform.AliCloud(_, accessId, accessKey, region, _) => - AliyunBlobStorage(accessId, accessKey, region, bucketName, java.time.Clock.systemDefaultZone()) + case Platform.AliCloud(project, _, accessId, accessKey, region, _) => + AliyunBlobStorage(accessId, accessKey, region, s"$project-$bucketName", java.time.Clock.systemDefaultZone()) case Platform.Dev => new FileSystemBlobStorage(Paths.get(s".data-$bucketName")) } @@ -88,7 +88,7 @@ trait CloudServices extends AkkaBootable { self => def messageBus: StreamBus = platform match { case p @ Platform.GoogleCloud(_, namespace) => new GoogleBus(p.credentials, namespace) with StreamBus with CreateOnDemand - case Platform.AliCloud(accountId, accessId, accessKey, region, namespace) => + case Platform.AliCloud(_, accountId, accessId, accessKey, region, namespace) => new AliyunBus(accountId, accessId, accessKey, region, namespace) with StreamBus with CreateOnDemand case Platform.Dev => new QueueBus()(self.system) with StreamBus diff --git a/core-init/src/main/scala/xyz/driver/core/init/Platform.scala b/core-init/src/main/scala/xyz/driver/core/init/Platform.scala index dced0e9..8f8ef83 100644 --- a/core-init/src/main/scala/xyz/driver/core/init/Platform.scala +++ b/core-init/src/main/scala/xyz/driver/core/init/Platform.scala @@ -29,12 +29,19 @@ object Platform { } } - case class AliCloud(accountId: String, accessId: String, accessKey: String, region: String, namespace: String) + case class AliCloud( + project: String, + accountId: String, + accessId: String, + accessKey: String, + region: String, + namespace: String) extends Platform object AliCloud { lazy val fromEnv: AliCloud = { AliCloud( + project = sys.env("CLOUD_PROJECT"), accountId = sys.env("ALICLOUD_ACCOUNT_ID"), accessId = sys.env("ALICLOUD_ACCESS_ID"), accessKey = sys.env("ALICLOUD_ACCESS_KEY"), -- cgit v1.2.3