You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/07/12 08:01:39 UTC
[GitHub] markusthoemmes closed pull request #3822: Introduce entitlement spi
markusthoemmes closed pull request #3822: Introduce entitlement spi
URL: https://github.com/apache/incubator-openwhisk/pull/3822
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index b59aa3b3fe..b36d2e498f 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 82018210ea..9d14751eb2 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 22c0dff03f..b658f8736f 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 4b4fc37279..d3260ed1f6 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 116f3efa53..f65ebdad00 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 4f240c6ed7..d344427775 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)
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services