From 1b58ebe7e5ff861737d1a1d4c6f7112c7b1552c4 Mon Sep 17 00:00:00 2001 From: Rodric Rabbah <rabbah@us.ibm.com> Date: Sun, 26 Feb 2017 11:21:35 -0500 Subject: [PATCH] Remove swift 2 action proxy. Remove rotted script. --- .gitignore | 4 - core/swiftAction/Dockerfile | 46 ------ core/swiftAction/build.gradle | 13 -- core/swiftAction/epilogue.swift | 143 ------------------ core/swiftAction/swiftrunner.py | 63 -------- settings.gradle | 1 - tests/build.gradle | 1 - .../SwiftActionContainerTests.scala | 2 +- 8 files changed, 1 insertion(+), 272 deletions(-) delete mode 100644 core/swiftAction/Dockerfile delete mode 100644 core/swiftAction/build.gradle delete mode 100644 core/swiftAction/epilogue.swift delete mode 100644 core/swiftAction/swiftrunner.py diff --git a/.gitignore b/.gitignore index 4fb8a00b..256d2184 100644 --- a/.gitignore +++ b/.gitignore @@ -48,10 +48,6 @@ ansible/tmp/* ansible/roles/nginx/files/*.csr ansible/roles/nginx/files/*cert.pem -# Action proxies copied during build -core/swiftAction/actionproxy.py -core/swift3Action/actionproxy.py - # .zip files must be explicited whitelisted *.zip !tests/dat/actions/blackbox.zip diff --git a/core/swiftAction/Dockerfile b/core/swiftAction/Dockerfile deleted file mode 100644 index 5f3c76dd..00000000 --- a/core/swiftAction/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -# Dockerfile for swift3 actions, overrides and extends ActionRunner from actionProxy -# This Dockerfile is partially based on: https://github.com/swiftdocker/docker-swift/ -FROM buildpack-deps:trusty - -ENV DEBIAN_FRONTEND noninteractive - -# Upgrade and install basic Python dependencies -RUN apt-get -y purge \ - && apt-get -y update \ - && apt-get -y install --fix-missing python2.7 python-gevent python-flask \ -\ -# Upgrade and install Swift dependencies - && apt-get -y install --fix-missing build-essential wget clang libedit-dev libicu52 libxml2-dev \ -\ -# Clean up - && apt-get clean - -# Install Swift keys -RUN wget --no-verbose -O - https://swift.org/keys/all-keys.asc | gpg --import - && \ - gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift - -# Install Swift Ubuntu 14.04 Snapshot -ENV SWIFT_VERSION 2.2-SNAPSHOT-2016-01-11-a -ENV SWIFT_PLATFORM ubuntu14.04 - -RUN SWIFT_ARCHIVE_NAME=swift-$SWIFT_VERSION-$SWIFT_PLATFORM && \ - SWIFT_URL=https://swift.org/builds/$(echo "$SWIFT_PLATFORM" | tr -d .)/swift-$SWIFT_VERSION/$SWIFT_ARCHIVE_NAME.tar.gz && \ - wget --no-verbose $SWIFT_URL && \ - wget --no-verbose $SWIFT_URL.sig && \ - gpg --verify $SWIFT_ARCHIVE_NAME.tar.gz.sig && \ - tar -xzf $SWIFT_ARCHIVE_NAME.tar.gz --directory / --strip-components=1 && \ - rm -rf $SWIFT_ARCHIVE_NAME* /tmp/* /var/tmp/* - -# Add the action proxy -RUN mkdir -p /actionProxy -ADD actionproxy.py /actionProxy - -# Add swift action runner -RUN mkdir -p /swiftAction -RUN touch /swiftAction/action.swift -ADD epilogue.swift /swiftAction -ADD swiftrunner.py /swiftAction - -ENV FLASK_PROXY_PORT 8080 - -CMD ["/bin/bash", "-c", "cd swiftAction && python -u swiftrunner.py"] diff --git a/core/swiftAction/build.gradle b/core/swiftAction/build.gradle deleted file mode 100644 index 7c71b5ae..00000000 --- a/core/swiftAction/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -ext.dockerImageName = 'swiftaction' -apply from: '../../gradle/docker.gradle' -distDocker.dependsOn 'copyProxy' -distDocker.finalizedBy('rmProxy') - -task copyProxy(type: Copy) { - from '../actionProxy/actionproxy.py' - into './actionproxy.py' -} - -task rmProxy(type: Delete) { - delete 'actionproxy.py' -} diff --git a/core/swiftAction/epilogue.swift b/core/swiftAction/epilogue.swift deleted file mode 100644 index 3488a0a2..00000000 --- a/core/swiftAction/epilogue.swift +++ /dev/null @@ -1,143 +0,0 @@ - -/* - * Copyright 2015-2016 IBM Corporation - * - * Licensed 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. - */ - -// Deliberate whitespaces above. - -/* This code is appended to user-supplied action code. - It reads from the standard input, deserializes into JSON and invokes the - main function. Currently, actions print strings to stdout. This can evolve once - JSON serialization is available in Foundation. */ - -import Foundation - -func _whisk_json2dict(txt: String) -> [String:Any]? { - if let data = txt.dataUsingEncoding(NSUTF8StringEncoding) { - do { - return try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? [String:Any] - } catch { - return nil - } - } - return nil -} - -class _Whisk_JSONSerialization { - enum JSONSerializationError: ErrorType { - case UnsupportedValue(value: Any) - } - - private class func escStr(str: String) -> String { - return (str - .bridge() - .stringByReplacingOccurrencesOfString("\\", withString: "\\\\") - .bridge() - .stringByReplacingOccurrencesOfString("\"", withString: "\\\"")) - } - - class func serialize(value: Any) throws -> String { - if let _ = value as? NSNull { - return "null" - } - - if let str = value as? String { - return "\"\(escStr(str))\"" - } - - if let num = value as? Double { - return "\(num)" - } - - if let num = value as? Int { - return "\(num)" - } - - if let b = value as? Bool { - return b ? "true" : "false" - } - - // More numeric types should go above. - - let mirror = Mirror(reflecting: value) - - if mirror.displayStyle == .Collection { - return try serializeArray(mirror.children.map({ return $0.value })) - } - - if mirror.displayStyle == .Dictionary { - return try serializeObject(mirror.children.map({ return $0.value })) - } - - print("Couldn't handle \(value) of type \(value.dynamicType)") - throw JSONSerializationError.UnsupportedValue(value: value) - } - - private class func serializeArray(array: [Any]) throws -> String { - if array.count == 0 { - return "[]" - } - var out = "[" - var sep = " " - for e in array { - let es = try serialize(e) - out = out + sep + es - sep = ", " - } - out = out + " ]" - return out - } - - private class func serializeObject(pairs: [Any]) throws -> String { - if pairs.count == 0 { - return "{}" - } - var out = "{" - var sep = " " - for pair in pairs { - let pairMirror = Mirror(reflecting: pair) - if pairMirror.displayStyle == .Tuple && pairMirror.children.count == 2 { - let g = pairMirror.children.generate() - let k = g.next()!.value - let v = g.next()!.value - let ks = escStr(k as! String) - let vs = try serialize(v) - out = out + sep + "\"\(ks)\": " + vs - sep = ", " - } else { - throw JSONSerializationError.UnsupportedValue(value: pairs) - } - } - out = out + " }" - return out - } -} - -func _run_main(mainFunction: [String: Any] -> [String: Any]) -> Void { - let env = NSProcessInfo.processInfo().environment - let inputStr: String = env["WHISK_INPUT"] ?? "{}" - - if let parsed = _whisk_json2dict(inputStr) { - let result = mainFunction(parsed) - do { - try print(_Whisk_JSONSerialization.serialize(result)) - } catch { - print("Serialization failed (\(result)).") - } - } else { - print("Error: couldn't parse JSON input.") - } -} - diff --git a/core/swiftAction/swiftrunner.py b/core/swiftAction/swiftrunner.py deleted file mode 100644 index 5bc859d0..00000000 --- a/core/swiftAction/swiftrunner.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright 2015-2016 IBM Corporation -# -# Licensed 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. -# - -import sys -import subprocess -import codecs -import json -sys.path.append('../actionProxy') -from actionproxy import ActionRunner, main, setRunner - -SRC_EPILOGUE_FILE = "./epilogue.swift" -DEST_SCRIPT_FILE = "/swiftAction/action.swift" -DEST_BIN_FILE = "/swiftAction/action" -BUILD_PROCESS = [ "swiftc", "-O", DEST_SCRIPT_FILE, "-o", DEST_BIN_FILE ] - -class SwiftRunner(ActionRunner): - - def __init__(self): - ActionRunner.__init__(self, DEST_SCRIPT_FILE, DEST_BIN_FILE) - - def epilogue(self, fp, init_message): - if "main" in init_message: - main_function = init_message["main"] - else: - main_function = "main" - - with codecs.open(SRC_EPILOGUE_FILE, "r", "utf-8") as ep: - fp.write(ep.read()) - - fp.write("_run_main(%s)\n" % main_function) - - def build(self): - p = subprocess.Popen(BUILD_PROCESS) - (o, e) = p.communicate() - - if o is not None: - sys.stdout.write(o) - - if e is not None: - sys.stderr.write(e) - - def env(self, message): - env = ActionRunner.env(self, message) - args = message.get('value', {}) if message else {} - env['WHISK_INPUT'] = json.dumps(args) - return env - -if __name__ == "__main__": - setRunner(SwiftRunner()) - main() diff --git a/settings.gradle b/settings.gradle index 3d7fb394..a7164551 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,6 @@ include 'core:nodejsAction' include 'core:nodejs6Action' include 'core:actionProxy' include 'core:pythonAction' -include 'core:swiftAction' include 'core:swift3Action' include 'core:javaAction' diff --git a/tests/build.gradle b/tests/build.gradle index dd2332eb..b3f3bbb5 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -41,7 +41,6 @@ test.dependsOn([ ':core:actionProxy:distDocker', ':core:pythonAction:distDocker', ':core:javaAction:distDocker', - ':core:swiftAction:distDocker', ':core:swift3Action:distDocker', ':sdk:docker:distDocker', ':tests:dat:blackbox:badaction:distDocker', diff --git a/tests/src/actionContainers/SwiftActionContainerTests.scala b/tests/src/actionContainers/SwiftActionContainerTests.scala index a93e55e5..73f6a20f 100644 --- a/tests/src/actionContainers/SwiftActionContainerTests.scala +++ b/tests/src/actionContainers/SwiftActionContainerTests.scala @@ -76,7 +76,7 @@ class SwiftActionContainerTests extends BasicActionRunnerTests with WskActorSyst | } """.stripMargin - // Helpers specific to swiftaction + // Helpers specific to swift actions override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = { withContainer(swiftContainerImageName, env)(code) } -- GitLab