openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rab...@apache.org
Subject [incubator-openwhisk] branch master updated: Feature flag support to turn on/off support for provide-api-key annotation (#4334)
Date Thu, 14 Mar 2019 01:52:22 GMT
This is an automated email from the ASF dual-hosted git repository.

rabbah 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 bb4e4df  Feature flag support to turn on/off support for provide-api-key annotation
(#4334)
bb4e4df is described below

commit bb4e4dfad252c0700b37093d78e24f56e52b3a3f
Author: Chetan Mehrotra <chetanm@apache.org>
AuthorDate: Thu Mar 14 07:22:15 2019 +0530

    Feature flag support to turn on/off support for provide-api-key annotation (#4334)
---
 common/scala/src/main/resources/application.conf   |  7 ++++++
 .../org/apache/openwhisk/core/FeatureFlags.scala   | 26 ++++++++++++++++++++++
 .../org/apache/openwhisk/core/WhiskConfig.scala    |  1 +
 .../apache/openwhisk/core/controller/Actions.scala |  4 ++--
 4 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/common/scala/src/main/resources/application.conf b/common/scala/src/main/resources/application.conf
index f73d8ec..435dc94 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -398,6 +398,13 @@ whisk {
             polling-from-db: true
         }
     }
+
+    feature-flags {
+        # Enables support for `provide-api-key` annotation.
+        # See https://github.com/apache/incubator-openwhisk/pull/4284
+        # for details
+        require-api-key-annotation = true
+    }
 }
 #placeholder for test overrides so that tests can override defaults in application.conf (todo:
move all defaults to reference.conf)
 test {
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala
new file mode 100644
index 0000000..7a2b85c
--- /dev/null
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openwhisk.core
+import pureconfig.loadConfigOrThrow
+
+object FeatureFlags {
+  private case class FeatureFlagConfig(requireApiKeyAnnotation: Boolean)
+  private val config = loadConfigOrThrow[FeatureFlagConfig](ConfigKeys.featureFlags)
+
+  val requireApiKeyAnnotation: Boolean = config.requireApiKeyAnnotation
+}
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala
index 7fd0c98..1111e10 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala
@@ -249,4 +249,5 @@ object ConfigKeys {
   val activationStoreWithFileStorage = s"$activationStore.with-file-storage"
 
   val metrics = "whisk.metrics"
+  val featureFlags = "whisk.feature-flags"
 }
diff --git a/core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
b/core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
index d3e79c3..295cb43 100644
--- a/core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
+++ b/core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
@@ -33,7 +33,7 @@ import akka.http.scaladsl.unmarshalling._
 import spray.json._
 import spray.json.DefaultJsonProtocol._
 import org.apache.openwhisk.common.TransactionId
-import org.apache.openwhisk.core.WhiskConfig
+import org.apache.openwhisk.core.{FeatureFlags, WhiskConfig}
 import org.apache.openwhisk.core.controller.RestApiCommons.{ListLimit, ListSkip}
 import org.apache.openwhisk.core.controller.actions.PostActionActivation
 import org.apache.openwhisk.core.database.{ActivationStore, CacheChangeNotification, NoDocumentException}
@@ -67,7 +67,7 @@ object WhiskActionsApi {
    * 2. An [[execAnnotation]] consistent with the action kind; this annotation is always
added and overrides a pre-existing value
    */
   protected[core] def amendAnnotations(annotations: Parameters, exec: Exec, create: Boolean
= true): Parameters = {
-    val newAnnotations = if (create) {
+    val newAnnotations = if (create && FeatureFlags.requireApiKeyAnnotation) {
       // these annotations are only added on newly created actions
       // since they can break existing actions created before the
       // annotation was created


Mime
View raw message