-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handling of
enterprise
self hosted runner
- Loading branch information
Showing
8 changed files
with
88 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,22 +102,25 @@ public struct VirtualMachineResourcesServiceEphemeral: VirtualMachineResourcesSe | |
|
||
private extension VirtualMachineResourcesServiceEphemeral { | ||
private func getRunnerURL() async throws -> URL { | ||
let baseURL = await gitHubCredentialsStore.selfHostedURL ?? .gitHub | ||
switch runnerScope { | ||
case .organization: | ||
let organizationName = try await getOrganizationName() | ||
guard let runnerURL = URL(string: "https://github.com/" + organizationName) else { | ||
throw VirtualMachineResourcesServiceEphemeralError.invalidRunnerURL | ||
} | ||
return runnerURL | ||
return baseURL.appending(path: organizationName, directoryHint: .notDirectory) | ||
case .repo: | ||
guard | ||
let ownerName = await gitHubCredentialsStore.ownerName, | ||
let repositoryName = await gitHubCredentialsStore.repositoryName, | ||
let runnerURL = URL(string: "https://github.com/\(ownerName)/\(repositoryName)") | ||
let repositoryName = await gitHubCredentialsStore.repositoryName | ||
else { | ||
throw VirtualMachineResourcesServiceEphemeralError.invalidRunnerURL | ||
} | ||
return runnerURL | ||
return baseURL.appending(path: "\(ownerName)/\(repositoryName)", directoryHint: .notDirectory) | ||
case .enterpriseServer: | ||
guard let enterpriseName = await gitHubCredentialsStore.enterpriseName else { | ||
throw VirtualMachineResourcesServiceEphemeralError.invalidRunnerURL | ||
} | ||
// SEE https://docs.github.com/en/[email protected]/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise | ||
return baseURL.appending(path: enterpriseName, directoryHint: .notDirectory) | ||
} | ||
} | ||
|
||
|
@@ -129,3 +132,7 @@ private extension VirtualMachineResourcesServiceEphemeral { | |
} | ||
} | ||
} | ||
|
||
private extension URL { | ||
static let gitHub = URL(string: "https://github.com/")! | ||
} |