Skip to content

Commit

Permalink
Merge pull request #1 from czechboy0/master
Browse files Browse the repository at this point in the history
Update to Head.
  • Loading branch information
Higgcz committed Jun 16, 2015
2 parents 7f4d115 + 0f030a4 commit 95d859e
Show file tree
Hide file tree
Showing 72 changed files with 3,953 additions and 952 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ build/
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

**/report.xml

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
Expand Down
1 change: 0 additions & 1 deletion BuildaCIServer/Integration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ extension Integration : Hashable {
return self.number
}
}

}

public func ==(lhs: Integration, rhs: Integration) -> Bool {
Expand Down
16 changes: 13 additions & 3 deletions BuildaCIServer/SourceControlBlueprint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class SourceControlBlueprint : XcodeServerEntity {
public let commitSHA: String?
public let privateSSHKey: String?
public let publicSSHKey: String?

public let sshPassphrase: String?

public required init(json: NSDictionary) {

self.wCCName = json.stringForKey(XcodeBlueprintNameKey)
Expand Down Expand Up @@ -55,12 +56,13 @@ public class SourceControlBlueprint : XcodeServerEntity {

self.privateSSHKey = nil
self.publicSSHKey = nil
self.sshPassphrase = nil

super.init(json: json)
}

public init(branch: String, projectWCCIdentifier: String, wCCName: String, projectName: String,
projectURL: String, projectPath: String, publicSSHKey: String?, privateSSHKey: String?)
projectURL: String, projectPath: String, publicSSHKey: String?, privateSSHKey: String?, sshPassphrase: String?)
{
self.branch = branch
self.projectWCCIdentifier = projectWCCIdentifier
Expand All @@ -71,10 +73,17 @@ public class SourceControlBlueprint : XcodeServerEntity {
self.commitSHA = nil
self.publicSSHKey = publicSSHKey
self.privateSSHKey = privateSSHKey
self.sshPassphrase = sshPassphrase

super.init()
}

//for credentials verification only
public convenience init(projectWCCIdentifier: String, projectURL: String, publicSSHKey: String?, privateSSHKey: String?, sshPassphrase: String?) {

self.init(branch: "", projectWCCIdentifier: projectWCCIdentifier, wCCName: "", projectName: "", projectURL: projectURL, projectPath: "", publicSSHKey: publicSSHKey, privateSSHKey: privateSSHKey, sshPassphrase: sshPassphrase)
}

public override func dictionarify() -> NSDictionary {

var dictionary = NSMutableDictionary()
Expand All @@ -91,6 +100,7 @@ public class SourceControlBlueprint : XcodeServerEntity {
let branch = self.branch
let sshPublicKey = self.publicSSHKey?.base64Encoded ?? ""
let sshPrivateKey = self.privateSSHKey?.base64Encoded ?? ""
let sshPassphrase = self.sshPassphrase ?? ""

//locations on the branch
dictionary[XcodeBlueprintLocationsKey] = [
Expand Down Expand Up @@ -140,7 +150,7 @@ public class SourceControlBlueprint : XcodeServerEntity {
repoId: [
XcodeRepoAuthenticationTypeKey: XcodeRepoSSHKeysAuthenticationStrategy,
XcodeRepoUsernameKey: "git", //TODO: see how to add https support?
XcodeRepoPasswordKey: "", //TODO: is this basic auth? we could use the github token for that instead of SSH
XcodeRepoPasswordKey: sshPassphrase, //this is where the passphrase goes
XcodeRepoAuthenticationStrategiesKey: sshPrivateKey,
XcodeRepoPublicKeyDataKey: sshPublicKey
]
Expand Down
32 changes: 16 additions & 16 deletions BuildaCIServer/XcodeServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public extension XcodeServer {
self.http.sendRequest(request, completion: { (response, body, error) -> () in

if response == nil {
let e = error ?? Errors.errorWithInfo("Nil response")
let e = error ?? Error.withInfo("Nil response")
completion(response: nil, body: body, error: e)
return
}
Expand All @@ -156,7 +156,7 @@ public extension XcodeServer {
})

} else {
completion(response: nil, body: nil, error: Errors.errorWithInfo("Couldn't create Request"))
completion(response: nil, body: nil, error: Error.withInfo("Couldn't create Request"))
}
}

Expand All @@ -173,11 +173,11 @@ public extension XcodeServer {
if response.statusCode == 204 {
completion(success: true, error: nil)
} else {
completion(success: false, error: Errors.errorWithInfo("Wrong status code: \(response.statusCode)"))
completion(success: false, error: Error.withInfo("Wrong status code: \(response.statusCode)"))
}
return
}
completion(success: false, error: Errors.errorWithInfo("Nil response"))
completion(success: false, error: Error.withInfo("Nil response"))
}
}

Expand All @@ -194,11 +194,11 @@ public extension XcodeServer {
if response.statusCode == 204 {
completion(success: true, error: nil)
} else {
completion(success: false, error: Errors.errorWithInfo("Wrong status code: \(response.statusCode)"))
completion(success: false, error: Error.withInfo("Wrong status code: \(response.statusCode)"))
}
return
}
completion(success: false, error: Errors.errorWithInfo("Nil response"))
completion(success: false, error: Error.withInfo("Nil response"))
}
}

Expand All @@ -217,7 +217,7 @@ public extension XcodeServer {
let bot = Bot(json: body as NSDictionary)
completion(bot: bot, error: nil)
} else {
completion(bot: nil, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(bot: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand All @@ -239,7 +239,7 @@ public extension XcodeServer {
let bot = Bot(json: body)
completion(bot: bot, error: nil)
} else {
completion(bot: nil, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(bot: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand All @@ -262,10 +262,10 @@ public extension XcodeServer {
if response.statusCode == 204 {
completion(success: true, error: nil)
} else {
completion(success: false, error: Errors.errorWithInfo("Wrong status code: \(response.statusCode)"))
completion(success: false, error: Error.withInfo("Wrong status code: \(response.statusCode)"))
}
} else {
completion(success: false, error: Errors.errorWithInfo("Nil response"))
completion(success: false, error: Error.withInfo("Nil response"))
}
}
}
Expand All @@ -283,7 +283,7 @@ public extension XcodeServer {
let bots: [Bot] = XcodeServerArray(body)
completion(bots: bots, error: nil)
} else {
completion(bots: nil, error: Errors.errorWithInfo("Wrong data returned: \(body)"))
completion(bots: nil, error: Error.withInfo("Wrong data returned: \(body)"))
}
}
}
Expand All @@ -305,7 +305,7 @@ public extension XcodeServer {
let integrations: [Integration] = XcodeServerArray(body)
completion(integrations: integrations, error: nil)
} else {
completion(integrations: nil, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(integrations: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand All @@ -332,7 +332,7 @@ public extension XcodeServer {
let integration = Integration(json: body)
completion(integration: integration, error: nil)
} else {
completion(integration: nil, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(integration: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ public extension XcodeServer {
let devices: [Device] = XcodeServerArray(array)
completion(devices: devices, error: error)
} else {
completion(devices: nil, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(devices: nil, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand All @@ -385,10 +385,10 @@ public extension XcodeServer {
if let canCreateBots = body["result"] as? Bool where canCreateBots == true {
completion(canCreateBots: true, error: nil)
} else {
completion(canCreateBots: false, error: Errors.errorWithInfo("Specified user cannot create bots"))
completion(canCreateBots: false, error: Error.withInfo("Specified user cannot create bots"))
}
} else {
completion(canCreateBots: false, error: Errors.errorWithInfo("Wrong body \(body)"))
completion(canCreateBots: false, error: Error.withInfo("Wrong body \(body)"))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion BuildaGitServer/GitHubEndpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class GitHubEndpoints {
private let baseURL: String
private let token: String?

init(baseURL: String, token: String?) {
public init(baseURL: String, token: String?) {
self.baseURL = baseURL
self.token = token
}
Expand Down
Loading

0 comments on commit 95d859e

Please sign in to comment.