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 2020/01/07 03:38:52 UTC

[GitHub] [openwhisk] ningyougang commented on a change in pull request #4790: [WIP]Config runtime

ningyougang commented on a change in pull request #4790: [WIP]Config runtime
URL: https://github.com/apache/openwhisk/pull/4790#discussion_r363580086
 
 

 ##########
 File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
 ##########
 @@ -163,6 +164,65 @@ class Controller(val instance: ControllerInstanceId,
     LogLimit.config,
     runtimes,
     List(apiV1.basepath()))
+
+  private val controllerUsername = {
+    val source = scala.io.Source.fromFile("/conf/controllerauth.username");
+    try source.mkString.replaceAll("\r|\n", "")
+    finally source.close()
+  }
+  private val controllerPassword = {
+    val source = scala.io.Source.fromFile("/conf/controllerauth.password");
+    try source.mkString.replaceAll("\r|\n", "")
+    finally source.close()
+  }
+
+  /**
+   * config runtime
+   */
+  private val configRuntime = {
+    implicit val executionContext = actorSystem.dispatcher
+    (path("config" / "runtime") & post) {
+      extractCredentials {
+        case Some(BasicHttpCredentials(username, password)) =>
+          if (username == controllerUsername && password == controllerPassword) {
+            entity(as[String]) { runtime =>
 
 Review comment:
   Usually, entity(as[Runtimes]) may be better, but if we apply this, need to change `Runtimes` to support convert json to entity Runtimes, and on the other hand, runtime.json's format doesn't match Runtimes entity, need to change a lot if use `entity(as[Runtimes]) ` to receive the data.
   
   Fortunately,we can reuse openwhisk itself's initialize method, just convert the runtime string to Runtimes.
   
   So here, i think pass runtime string would be ok.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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