This is an automated email from the ASF dual-hosted git repository.

markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new d3bd9e6  Introduce Entitlement SPI. (#3822)
d3bd9e6 is described below

commit d3bd9e61c2d8e6f906cdbc39f8939e53106d1aad
Author: Martin Henke <martin.he...@web.de>
AuthorDate: Thu Jul 12 10:01:37 2018 +0200

    Introduce Entitlement SPI. (#3822)
---
 ansible/group_vars/all                                   |  2 ++
 ansible/roles/controller/tasks/deploy.yml                |  2 ++
 common/scala/src/main/resources/reference.conf           |  1 +
 .../main/scala/whisk/core/controller/Controller.scala    |  2 +-
 .../main/scala/whisk/core/entitlement/Entitlement.scala  |  7 +++++++
 .../scala/whisk/core/entitlement/LocalEntitlement.scala  | 16 ++++++++++------
 6 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index b59aa3b..b36d2e4 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -79,6 +79,8 @@ controller:
   loadbalancer:
     spi: "{{ controller_loadbalancer_spi | default('') }}"
   loglevel: "{{ controller_loglevel | default(whisk_loglevel) | 
default('INFO') }}"
+  entitlement:
+    spi: "{{ controller_entitlement_spi | default('') }}"
   protocol: "{{ controllerProtocolForSetup }}"
   ssl:
     cn: openwhisk-controllers
diff --git a/ansible/roles/controller/tasks/deploy.yml 
b/ansible/roles/controller/tasks/deploy.yml
index 8201821..9d14751 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -231,6 +231,8 @@
       "CONFIG_whisk_spi_LogStoreProvider": "{{ userLogs.spi }}"
       "CONFIG_whisk_spi_LoadBalancerProvider":
         "{{ controller.loadbalancer.spi }}"
+      "CONFIG_whisk_spi_EntitlementSpiProvider": "{{ 
controller.entitlement.spi }}"
+
       "CONFIG_logback_log_level": "{{ controller.loglevel }}"
 
       "CONFIG_whisk_transactions_header": "{{ transactions.header }}"
diff --git a/common/scala/src/main/resources/reference.conf 
b/common/scala/src/main/resources/reference.conf
index 22c0dff..b658f87 100644
--- a/common/scala/src/main/resources/reference.conf
+++ b/common/scala/src/main/resources/reference.conf
@@ -8,6 +8,7 @@ whisk.spi {
   ContainerFactoryProvider = 
whisk.core.containerpool.docker.DockerContainerFactoryProvider
   LogStoreProvider = 
whisk.core.containerpool.logging.DockerToActivationLogStoreProvider
   LoadBalancerProvider = whisk.core.loadBalancer.ShardingContainerPoolBalancer
+  EntitlementSpiProvider = whisk.core.entitlement.LocalEntitlementProvider
 }
 
 dispatchers {
diff --git 
a/core/controller/src/main/scala/whisk/core/controller/Controller.scala 
b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
index 4b4fc37..d3260ed 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Controller.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
@@ -119,7 +119,7 @@ class Controller(val instance: ControllerInstanceId,
   logging.info(this, s"loadbalancer initialized: 
${loadBalancer.getClass.getSimpleName}")(TransactionId.controller)
 
   private implicit val entitlementProvider =
-    new LocalEntitlementProvider(whiskConfig, loadBalancer, instance)
+    SpiLoader.get[EntitlementSpiProvider].instance(whiskConfig, loadBalancer, 
instance)
   private implicit val activationIdFactory = new ActivationIdGenerator {}
   private implicit val logStore = 
SpiLoader.get[LogStoreProvider].logStore(actorSystem)
   private implicit val activationStore =
diff --git 
a/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala 
b/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
index 116f3ef..f65ebda 100644
--- a/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
+++ b/core/controller/src/main/scala/whisk/core/entitlement/Entitlement.scala
@@ -38,6 +38,7 @@ import whisk.http.Messages
 import whisk.http.Messages._
 import whisk.core.connector.MessagingProvider
 import whisk.spi.SpiLoader
+import whisk.spi.Spi
 
 package object types {
   type Entitlements = TrieMap[(Subject, String), Set[Privilege]]
@@ -62,6 +63,12 @@ protected[core] case class Resource(namespace: EntityPath,
   override def toString: String = id
 }
 
+trait EntitlementSpiProvider extends Spi {
+  def instance(config: WhiskConfig, loadBalancer: LoadBalancer, instance: 
ControllerInstanceId)(
+    implicit actorSystem: ActorSystem,
+    logging: Logging): EntitlementProvider
+}
+
 protected[core] object EntitlementProvider {
 
   val requiredProperties = Map(
diff --git 
a/core/controller/src/main/scala/whisk/core/entitlement/LocalEntitlement.scala 
b/core/controller/src/main/scala/whisk/core/entitlement/LocalEntitlement.scala
index 4f240c6..d344427 100644
--- 
a/core/controller/src/main/scala/whisk/core/entitlement/LocalEntitlement.scala
+++ 
b/core/controller/src/main/scala/whisk/core/entitlement/LocalEntitlement.scala
@@ -26,12 +26,6 @@ import whisk.core.WhiskConfig
 import whisk.core.entity.{ControllerInstanceId, Subject}
 import whisk.core.loadBalancer.LoadBalancer
 
-private object LocalEntitlementProvider {
-
-  /** Poor mans entitlement matrix. Must persist to datastore eventually. */
-  private val matrix = TrieMap[(Subject, String), Set[Privilege]]()
-}
-
 protected[core] class LocalEntitlementProvider(
   private val config: WhiskConfig,
   private val loadBalancer: LoadBalancer,
@@ -72,3 +66,13 @@ protected[core] class LocalEntitlementProvider(
     one || any
   }
 }
+
+private object LocalEntitlementProvider extends EntitlementSpiProvider {
+
+  /** Poor mans entitlement matrix. Must persist to datastore eventually. */
+  private val matrix = TrieMap[(Subject, String), Set[Privilege]]()
+  override def instance(config: WhiskConfig, loadBalancer: LoadBalancer, 
instance: ControllerInstanceId)(
+    implicit actorSystem: ActorSystem,
+    logging: Logging) =
+    new LocalEntitlementProvider(config: WhiskConfig, loadBalancer: 
LoadBalancer, instance)
+}

Reply via email to