This is an automated email from the ASF dual-hosted git repository. houshengbo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-swift.git
The following commit(s) were added to refs/heads/master by this push: new f404956 Last files to need ASF License headers. (#63) f404956 is described below commit f404956da2b99c3cddb37be2760a7ce90b11d2d9 Author: Matt Rutkowski <mrutk...@us.ibm.com> AuthorDate: Wed May 23 09:48:24 2018 -0500 Last files to need ASF License headers. (#63) * Last files to need ASF License headers. * Add ASF license header to .gradle files. * Fix .swift files with incorrect ASF license headers. --- ansible/environments/local/group_vars/all | 3 ++ build.gradle | 17 +++++++ core/swift3.1.1Action/build.gradle | 17 +++++++ core/swift3.1.1Action/spm-build/Package.swift | 11 +++-- .../spm-build/_WhiskJSONUtils.swift | 11 +++-- core/swift41Action/build.gradle | 17 +++++++ core/swift41Action/spm-build/Package.swift | 11 +++-- core/swift41Action/spm-build/_Whisk.swift | 54 +++++++++++----------- gradle/docker.gradle | 17 +++++++ gradle/wrapper/gradle-wrapper.properties | 3 ++ settings.gradle | 17 +++++++ tests/build.gradle | 17 +++++++ tests/dat/actions/HelloSwift3/Package.swift | 12 +++-- tests/dat/actions/HelloSwift4/Package.swift | 12 +++-- tests/dat/actions/HelloSwift4Codable/Package.swift | 12 +++-- tests/dat/actions/SwiftyRequest/Package.swift | 12 +++-- .../dat/actions/SwiftyRequestCodable/Package.swift | 12 +++-- 17 files changed, 191 insertions(+), 64 deletions(-) diff --git a/ansible/environments/local/group_vars/all b/ansible/environments/local/group_vars/all index 2085010..4cd7674 100755 --- a/ansible/environments/local/group_vars/all +++ b/ansible/environments/local/group_vars/all @@ -1,3 +1,6 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + whisk_version_name: local openwhisk_tmp_dir: "{{ lookup('env', 'OPENWHISK_TMP_DIR')|default('/tmp', true) }}" config_root_dir: "{{ openwhisk_tmp_dir }}/wskconf" diff --git a/build.gradle b/build.gradle index 300a1ce..4ebd4b8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,20 @@ +/* + * 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. + */ + buildscript { repositories { jcenter() diff --git a/core/swift3.1.1Action/build.gradle b/core/swift3.1.1Action/build.gradle index ecc3760..678d0ad 100755 --- a/core/swift3.1.1Action/build.gradle +++ b/core/swift3.1.1Action/build.gradle @@ -1,2 +1,19 @@ +/* + * 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. + */ + ext.dockerImageName = 'action-swift-v3.1.1' apply from: '../../gradle/docker.gradle' diff --git a/core/swift3.1.1Action/spm-build/Package.swift b/core/swift3.1.1Action/spm-build/Package.swift index 4f0a576..3931ba4 100755 --- a/core/swift3.1.1Action/spm-build/Package.swift +++ b/core/swift3.1.1Action/spm-build/Package.swift @@ -1,9 +1,12 @@ /* - * 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 + * 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 + * 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, diff --git a/core/swift3.1.1Action/spm-build/_WhiskJSONUtils.swift b/core/swift3.1.1Action/spm-build/_WhiskJSONUtils.swift index 6ab95d4..58fbe29 100644 --- a/core/swift3.1.1Action/spm-build/_WhiskJSONUtils.swift +++ b/core/swift3.1.1Action/spm-build/_WhiskJSONUtils.swift @@ -1,9 +1,12 @@ /* - * 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 + * 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 + * 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, diff --git a/core/swift41Action/build.gradle b/core/swift41Action/build.gradle index 7e91809..c70bc4c 100755 --- a/core/swift41Action/build.gradle +++ b/core/swift41Action/build.gradle @@ -1,2 +1,19 @@ +/* + * 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. + */ + ext.dockerImageName = 'action-swift-v4.1' apply from: '../../gradle/docker.gradle' diff --git a/core/swift41Action/spm-build/Package.swift b/core/swift41Action/spm-build/Package.swift index eb204a9..949fb7a 100755 --- a/core/swift41Action/spm-build/Package.swift +++ b/core/swift41Action/spm-build/Package.swift @@ -2,11 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* - * 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 + * 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 + * 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, diff --git a/core/swift41Action/spm-build/_Whisk.swift b/core/swift41Action/spm-build/_Whisk.swift index fe43f21..bcd54f6 100644 --- a/core/swift41Action/spm-build/_Whisk.swift +++ b/core/swift41Action/spm-build/_Whisk.swift @@ -19,56 +19,56 @@ import Foundation import Dispatch class Whisk { - + static var baseUrl = ProcessInfo.processInfo.environment["__OW_API_HOST"] static var apiKey = ProcessInfo.processInfo.environment["__OW_API_KEY"] // This will allow user to modify the default JSONDecoder and JSONEncoder used by epilogue static var jsonDecoder = JSONDecoder() static var jsonEncoder = JSONEncoder() - + class func invoke(actionNamed action : String, withParameters params : [String:Any], blocking: Bool = true) -> [String:Any] { let parsedAction = parseQualifiedName(name: action) let strBlocking = blocking ? "true" : "false" let path = "/api/v1/namespaces/\(parsedAction.namespace)/actions/\(parsedAction.name)?blocking=\(strBlocking)" - + return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "POST") } - + class func trigger(eventNamed event : String, withParameters params : [String:Any]) -> [String:Any] { let parsedEvent = parseQualifiedName(name: event) let path = "/api/v1/namespaces/\(parsedEvent.namespace)/triggers/\(parsedEvent.name)?blocking=true" - + return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "POST") } - + class func createTrigger(triggerNamed trigger: String, withParameters params : [String:Any]) -> [String:Any] { let parsedTrigger = parseQualifiedName(name: trigger) let path = "/api/v1/namespaces/\(parsedTrigger.namespace)/triggers/\(parsedTrigger.name)" return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "PUT") } - + class func createRule(ruleNamed ruleName: String, withTrigger triggerName: String, andAction actionName: String) -> [String:Any] { let parsedRule = parseQualifiedName(name: ruleName) let path = "/api/v1/namespaces/\(parsedRule.namespace)/rules/\(parsedRule.name)" let params = ["trigger":triggerName, "action":actionName] return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "PUT") } - + // handle the GCD dance to make the post async, but then obtain/return // the result from this function sync private class func sendWhiskRequestSyncronish(uriPath path: String, params : [String:Any], method: String) -> [String:Any] { var response : [String:Any]! - + let queue = DispatchQueue.global() let invokeGroup = DispatchGroup() - + invokeGroup.enter() queue.async { postUrlSession(uriPath: path, params: params, method: method, group: invokeGroup) { result in response = result } } - + // On one hand, FOREVER seems like an awfully long time... // But on the other hand, I think we can rely on the system to kill this // if it exceeds a reasonable execution time. @@ -78,46 +78,46 @@ class Whisk { case DispatchTimeoutResult.timedOut: break } - + return response } - - + + /** * Using new UrlSession */ private class func postUrlSession(uriPath: String, params : [String:Any], method: String,group: DispatchGroup, callback : @escaping([String:Any]) -> Void) { - + guard let encodedPath = uriPath.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else { callback(["error": "Error encoding uri path to make openwhisk REST call."]) return } - + let urlStr = "\(baseUrl!)\(encodedPath)" if let url = URL(string: urlStr) { var request = URLRequest(url: url) request.httpMethod = method - + do { request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.httpBody = try JSONSerialization.data(withJSONObject: params) - + let loginData: Data = apiKey!.data(using: String.Encoding.utf8, allowLossyConversion: false)! let base64EncodedAuthKey = loginData.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0)) request.addValue("Basic \(base64EncodedAuthKey)", forHTTPHeaderField: "Authorization") let session = URLSession(configuration: URLSessionConfiguration.default) - + let task = session.dataTask(with: request, completionHandler: {data, response, error -> Void in - + // exit group after we are done defer { group.leave() } - + if let error = error { callback(["error":error.localizedDescription]) } else { - + if let data = data { do { //let outputStr = String(data: data, encoding: String.Encoding.utf8) as String! @@ -134,22 +134,22 @@ class Whisk { } } }) - + task.resume() } catch { callback(["error":"Got error creating params body: \(error)"]) } } } - + // separate an OpenWhisk qualified name (e.g. "/whisk.system/samples/date") // into namespace and name components private class func parseQualifiedName(name qualifiedName : String) -> (namespace : String, name : String) { let defaultNamespace = "_" let delimiter = "/" - + let segments :[String] = qualifiedName.components(separatedBy: delimiter) - + if segments.count > 2 { return (segments[1], Array(segments[2..<segments.count]).joined(separator: delimiter)) } else if segments.count == 2 { @@ -160,5 +160,5 @@ class Whisk { return (defaultNamespace, segments[0]) } } - + } diff --git a/gradle/docker.gradle b/gradle/docker.gradle index f716c7b..6ad6850 100644 --- a/gradle/docker.gradle +++ b/gradle/docker.gradle @@ -1,3 +1,20 @@ +/* + * 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. + */ + import groovy.time.* /** diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f16d266..d7cc33f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,3 +1,6 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index bce3ebb..222efe1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,20 @@ +/* + * 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. + */ + include 'tests' include 'core:swift3.1.1Action' diff --git a/tests/build.gradle b/tests/build.gradle index 3b60d6c..1ae5a4b 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -1,3 +1,20 @@ +/* + * 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. + */ + apply plugin: 'scala' apply plugin: 'eclipse' compileTestScala.options.encoding = 'UTF-8' diff --git a/tests/dat/actions/HelloSwift3/Package.swift b/tests/dat/actions/HelloSwift3/Package.swift index 8a40c7d..e2437ec 100644 --- a/tests/dat/actions/HelloSwift3/Package.swift +++ b/tests/dat/actions/HelloSwift3/Package.swift @@ -2,12 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* + * 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 * - * 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 + * 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, diff --git a/tests/dat/actions/HelloSwift4/Package.swift b/tests/dat/actions/HelloSwift4/Package.swift index b9f14f9..949fb7a 100644 --- a/tests/dat/actions/HelloSwift4/Package.swift +++ b/tests/dat/actions/HelloSwift4/Package.swift @@ -2,12 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* + * 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 * - * 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 + * 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, diff --git a/tests/dat/actions/HelloSwift4Codable/Package.swift b/tests/dat/actions/HelloSwift4Codable/Package.swift index b9f14f9..949fb7a 100644 --- a/tests/dat/actions/HelloSwift4Codable/Package.swift +++ b/tests/dat/actions/HelloSwift4Codable/Package.swift @@ -2,12 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* + * 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 * - * 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 + * 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, diff --git a/tests/dat/actions/SwiftyRequest/Package.swift b/tests/dat/actions/SwiftyRequest/Package.swift index 032948d..f726836 100644 --- a/tests/dat/actions/SwiftyRequest/Package.swift +++ b/tests/dat/actions/SwiftyRequest/Package.swift @@ -2,12 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* + * 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 * - * 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 + * 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, diff --git a/tests/dat/actions/SwiftyRequestCodable/Package.swift b/tests/dat/actions/SwiftyRequestCodable/Package.swift index 109903b..d1af80c 100644 --- a/tests/dat/actions/SwiftyRequestCodable/Package.swift +++ b/tests/dat/actions/SwiftyRequestCodable/Package.swift @@ -2,12 +2,14 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. /* + * 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 * - * 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 + * 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, -- To stop receiving notification emails like this one, please contact houshen...@apache.org.