Rust 1.34 support (#1119)
* Verified working wskdeploy with rust
* Added unit tests
* Working tests; rs file extension still does not work
* Added headers to files and removed un-needed Cargo source files
* Merge resolution
Co-authored-by: Daniel Hartig <dhartig@Daniels-MacBook-Pro.local>
diff --git a/runtimes/runtimes.go b/runtimes/runtimes.go
index 76e083e..db1bea9 100644
--- a/runtimes/runtimes.go
+++ b/runtimes/runtimes.go
@@ -43,8 +43,8 @@
PHP_FILE_EXTENSION = "php"
ZIP_FILE_EXTENSION = "zip"
RUBY_FILE_EXTENSION = "rb"
- RUST_FILE_EXTENSION = "rs"
GO_FILE_EXTENSION = "go"
+ RUST_FILE_EXTENSION = "rs"
NODEJS_RUNTIME = "nodejs"
SWIFT_RUNTIME = SWIFT_FILE_EXTENSION
PYTHON_RUNTIME = "python"
@@ -52,8 +52,8 @@
DOTNET_RUNTIME = ZIP_FILE_EXTENSION
PHP_RUNTIME = PHP_FILE_EXTENSION
RUBY_RUNTIME = "ruby"
- RUST_RUNTIME = "rust"
GO_RUNTIME = GO_FILE_EXTENSION
+ RUST_RUNTIME = "rust"
HTTP_CONTENT_TYPE_KEY = "Content-Type"
HTTP_CONTENT_TYPE_VALUE = "application/json; charset=UTF-8"
RUNTIME_NOT_SPECIFIED = "NOT SPECIFIED"
@@ -214,6 +214,8 @@
} else if strings.Contains(k, DOTNET_RUNTIME) {
ext[CSHARP_FILE_EXTENSION] = k
ext[ZIP_FILE_EXTENSION] = k
+ } else if strings.Contains(k, RUST_RUNTIME) {
+ ext[RUST_FILE_EXTENSION] = k
}
}
return
@@ -243,6 +245,8 @@
rte[v[i].Kind] = GO_FILE_EXTENSION
} else if strings.Contains(k, DOTNET_RUNTIME) {
rte[v[i].Kind] = CSHARP_FILE_EXTENSION
+ } else if strings.Contains(k, RUST_RUNTIME) {
+ rte[v[i].Kind] = RUST_FILE_EXTENSION
}
}
}
@@ -503,6 +507,22 @@
"attachmentType": "text/plain"
}
}
+ ],
+ "rust": [
+ {
+ "kind": "rust:1.34",
+ "default": true,
+ "deprecated": false,
+ "attached": {
+ "attachmentName": "codefile",
+ "attachmentType": "text/plain"
+ },
+ "image": {
+ "prefix": "openwhisk",
+ "name": "actionloop-rust-v1.34",
+ "tag": "latest"
+ }
+ }
]
},
"blackboxes": [
diff --git a/specification/html/spec_actions.md b/specification/html/spec_actions.md
index 56920c6..6995348 100644
--- a/specification/html/spec_actions.md
+++ b/specification/html/spec_actions.md
@@ -168,6 +168,7 @@
| swift@3.1.1 **(deprecated)** | swift:3.1.1 | [openwhisk/action-swift-v3.1.1](https://hub.docker.com/r/openwhisk/action-swift-v3.1.1) | nightly | Swift 3.1.1 language runtime |
| dotnet | dotnet@2.2 (default) | dotnet:2.2 | [openwhisk/action-dotnet-v2.2](https://hub.docker.com/r/openwhisk/action-dotnet-v2.2) | nightly | .NET Core 2.2 runtime |
| dotnet@3.1 | dotnet:3.1 | [openwhisk/action-dotnet-v3.1](https://hub.docker.com/r/openwhisk/action-dotnet-v3.1) | nightly | .NET Core 3.1 runtime |
+| rust@1.34 | rust:1.34 | openwhisk/actionloop-rust-v1.34:latest | Latest Rust 1.34 language runtime |
| language:default | N/A | N/A | N/A | Permit the OpenWhisk platform to select the correct default language runtime. |
See the file [runtimes.json](https://github.com/apache/openwhisk/blob/master/ansible/files/runtimes.json) in
@@ -222,6 +223,11 @@
<td>ruby</td>
<td>Latest Ruby language runtime.</td>
</tr>
+ <tr>
+ <td>.rs</td>
+ <td>rust</td>
+ <td>Latest Rust language runtime.</td>
+ </tr>
</table>
</html>
diff --git a/tests/src/integration/runtimetests/manifest.yaml b/tests/src/integration/runtimetests/manifest.yaml
index 7cbf189..c2084a0 100644
--- a/tests/src/integration/runtimetests/manifest.yaml
+++ b/tests/src/integration/runtimetests/manifest.yaml
@@ -150,6 +150,8 @@
runtime: dotnet:2.2
main: Apache.OpenWhisk.Example.Dotnet::Apache.OpenWhisk.Example.Dotnet.Hello::Main
zipaction-with-explicit-runtime:
+ annotations:
+ web-export: true
function: src/helloworld
runtime: nodejs:default
inputs:
@@ -157,6 +159,22 @@
place: string
outputs:
payload: string
+ # hellorust134-with-explicit-runtime:
+ # function: src/lib.rs
+ # runtime: rust:1.34
+ # inputs:
+ # name: string
+ # place: string
+ # outputs:
+ # payload: string
+ hellocargo134-with-explicit-runtime:
+ function: src/helloCargo.zip
+ runtime: rust:1.34
+ inputs:
+ name: string
+ place: string
+ outputs:
+ payload: string
TestImplicitRuntimes:
actions:
greetingnodejs-without-explicit-runtime:
diff --git a/tests/src/integration/runtimetests/src/helloCargo.zip b/tests/src/integration/runtimetests/src/helloCargo.zip
new file mode 100644
index 0000000..53658a9
--- /dev/null
+++ b/tests/src/integration/runtimetests/src/helloCargo.zip
Binary files differ
diff --git a/tests/src/integration/runtimetests/src/lib.rs b/tests/src/integration/runtimetests/src/lib.rs
new file mode 100644
index 0000000..83598f8
--- /dev/null
+++ b/tests/src/integration/runtimetests/src/lib.rs
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+extern crate serde_json;
+
+use serde_derive::{Deserialize, Serialize};
+use serde_json::{Error, Value};
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+struct Input {
+ #[serde(default = "stranger")]
+ name: String,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+struct Output {
+ greeting: String,
+}
+
+fn stranger() -> String {
+ "stranger".to_string()
+}
+
+pub fn main(args: Value) -> Result<Value, Error> {
+ let input: Input = serde_json::from_value(args)?;
+ let output = Output {
+ greeting: format!("Hello, {}", input.name),
+ };
+ serde_json::to_value(output)
+}