[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2018-02-14 Thread GitBox
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r168212354
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -122,19 +124,24 @@ protected[core] case class 
CodeExecMetaDataAsString(manifest: RuntimeManifest) e
 
 protected[core] case class CodeExecAsAttachment(manifest: RuntimeManifest,
 override val code: 
Attachment[String],
-override val entryPoint: 
Option[String])
+override val entryPoint: 
Option[String],
+override val binary: Boolean = 
false)
 extends CodeExec[Attachment[String]] {
   override val kind = manifest.kind
   override val image = manifest.image
   override val sentinelledLogs = manifest.sentinelledLogs.getOrElse(true)
   override val deprecated = manifest.deprecated.getOrElse(false)
   override val pull = false
-  override lazy val binary = true
   override def codeAsJson = code.toJson
 
   def inline(bytes: Array[Byte]): CodeExecAsAttachment = {
-val encoded = new String(bytes, StandardCharsets.UTF_8)
-copy(code = Inline(encoded))
+val code = new String(bytes, StandardCharsets.UTF_8)
+
+if (kind == "java" && !Exec.isBinaryCode(code)) {
 
 Review comment:
   Allows backward compatibility with old Java actions that have attachments 
that are not base64.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2017-12-08 Thread GitBox
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r144146877
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -241,21 +241,33 @@ protected[core] object Exec extends ArgNormalizer[Exec] 
with DefaultJsonProtocol
 
   manifest.attached
 .map { a =>
-  val jar: Attachment[String] = {
-// java actions once stored the attachment in "jar" instead of 
"code"
-obj.fields.get("code").orElse(obj.fields.get("jar"))
+  // java actions once stored the attachment in "jar" instead of 
"code"
+  val code = obj.fields.get("code").orElse(obj.fields.get("jar"))
+
+  val binary: Boolean = code match {
+case Some(JsString(c)) => isBinaryCode(c)
+case _ =>
+  obj.fields.get("binary") match {
+case Some(JsBoolean(b)) => b
+case _  => false
 
 Review comment:
   Should probably error here since code and binary property is not defined.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2017-12-08 Thread GitBox
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r143809511
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/WhiskAction.scala
 ##
 @@ -243,7 +242,7 @@ object WhiskAction extends DocumentFactory[WhiskAction] 
with WhiskEntityQueries[
   val newDoc = doc.copy(exec = exec.attach)
   newDoc.revision(doc.rev)
 
-  val stream = new 
ByteArrayInputStream(Base64.getDecoder().decode(code))
+  val stream = new ByteArrayInputStream(code.getBytes)
 
 Review comment:
   If this change is left in place, existing deployments will need to do a 
database migration in order to convert old Java action byte attachments to 
Base64 encoded attachments.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2017-11-27 Thread GitBox
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r153325540
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -278,21 +278,33 @@ protected[core] object Exec extends ArgNormalizer[Exec] 
with DefaultJsonProtocol
 
   manifest.attached
 .map { a =>
-  val jar: Attachment[String] = {
-// java actions once stored the attachment in "jar" instead of 
"code"
-obj.fields.get("code").orElse(obj.fields.get("jar"))
+  // java actions once stored the attachment in "jar" instead of 
"code"
+  val code = obj.fields.get("code").orElse(obj.fields.get("jar"))
 
 Review comment:
   As part of https://github.com/apache/incubator-openwhisk/pull/2938 I have 
normalized jar to code. Will have to remove the jar reference here.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2017-10-13 Thread git
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r144643287
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -241,21 +241,33 @@ protected[core] object Exec extends ArgNormalizer[Exec] 
with DefaultJsonProtocol
 
   manifest.attached
 .map { a =>
-  val jar: Attachment[String] = {
-// java actions once stored the attachment in "jar" instead of 
"code"
-obj.fields.get("code").orElse(obj.fields.get("jar"))
+  // java actions once stored the attachment in "jar" instead of 
"code"
+  val code = obj.fields.get("code").orElse(obj.fields.get("jar"))
+
+  val binary: Boolean = code match {
+case Some(JsString(c)) => isBinaryCode(c)
+case _ =>
+  obj.fields.get("binary") match {
+case Some(JsBoolean(b)) => b
+case _  => false
+  }
+  }
+
+  val attachment: Attachment[String] = {
+code
   } map {
 attFmt[String].read(_)
   } getOrElse {
-throw new DeserializationException(
-  s"'code' must be a valid base64 string in 'exec' for '$kind' 
actions")
+throw new DeserializationException(s"'code' must be a string 
defined in 'exec' for '$kind' actions")
 
 Review comment:
   Not sure we will ever get here. Since I think the function in map will work 
even for an empty string.
 

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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #2847: Treat action code as attachments for created/updated actions

2017-10-13 Thread git
dubeejw commented on a change in pull request #2847: Treat action code as 
attachments for created/updated actions
URL: 
https://github.com/apache/incubator-openwhisk/pull/2847#discussion_r144643287
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -241,21 +241,33 @@ protected[core] object Exec extends ArgNormalizer[Exec] 
with DefaultJsonProtocol
 
   manifest.attached
 .map { a =>
-  val jar: Attachment[String] = {
-// java actions once stored the attachment in "jar" instead of 
"code"
-obj.fields.get("code").orElse(obj.fields.get("jar"))
+  // java actions once stored the attachment in "jar" instead of 
"code"
+  val code = obj.fields.get("code").orElse(obj.fields.get("jar"))
+
+  val binary: Boolean = code match {
+case Some(JsString(c)) => isBinaryCode(c)
+case _ =>
+  obj.fields.get("binary") match {
+case Some(JsBoolean(b)) => b
+case _  => false
+  }
+  }
+
+  val attachment: Attachment[String] = {
+code
   } map {
 attFmt[String].read(_)
   } getOrElse {
-throw new DeserializationException(
-  s"'code' must be a valid base64 string in 'exec' for '$kind' 
actions")
+throw new DeserializationException(s"'code' must be a string 
defined in 'exec' for '$kind' actions")
 
 Review comment:
   Not sure we will ever get here.
 

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:
us...@infra.apache.org


With regards,
Apache Git Services