Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enterprise hosting support #53

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mattia
Copy link
Contributor

@mattia mattia commented Oct 4, 2023

Add the ability to specify an GitHub Enterprise Server URL so that users can use custom instances of self-hosted GitHub. The runner type enterprise is added so enterprises hosted on GitHub Cloud can add runners to the whole enterprise

Fixes #27

@mattia
Copy link
Contributor Author

mattia commented Oct 4, 2023

This PR is very much a WIP, there are a bunch of things to do before it is ready (code cleanup, duplication, etc.) but we need to verify that it is working before all and at the moment I don't have any ability to do it. Let's hope the community can share some feedback

@simonbs
Copy link
Contributor

simonbs commented Oct 6, 2023

@mattia Thanks a lot for opening this PR! I think it would be great to have this functionality in Tartelet. I'll make sure to review it once I have the time 😊

throw VirtualMachineResourcesServiceEphemeralError.invalidRunnerURL
}
// SEE https://docs.github.com/en/enterprise-server@3.10/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
return baseURL.appending(path: enterpriseName, directoryHint: .notDirectory)
Copy link
Contributor Author

@mattia mattia Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be checked, from my understating of the API the base URL should be set on your instance URL (and that's what I have done in code), but in the example link they hardcode github.com. If anyone can confirm/update me on this, please let me know

@hoon-prestolabs
Copy link

Any update?

@mattia
Copy link
Contributor Author

mattia commented Dec 21, 2023

Any update?

Hi @hoon-prestolabs! Unfortunately I don't have any news regarding this. The basic functionality is implemented and should work fine but I'm leaving the PR in draft because I don't want to propose this change without a feedback from users with this configuration.
If you are using GitHub Enterprise Server your feedback on this change would be welcome!

@mattia mattia force-pushed the feature/enterprise-hosting-support branch from 3fd34eb to 567b8a6 Compare December 21, 2023 20:30
@mattia
Copy link
Contributor Author

mattia commented Dec 21, 2023

(rebased the branch on main just to keep up with recent updates)

Copy link
Contributor

@simonbs simonbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, thank you for opening this PR and thank you for your patience. I apologize for the delay in responding.

I have added a few comments to the code changes. Some of the comments include required changes, such as ensuring texts are localized, and others include suggestions for improvements.

My main concern with merging these changes right now is that I am unable to test them myself, as I do not have access to an enterprise GitHub setup. I am also concerned about whether the new Version setting allows users to select an invalid combination of settings.

For example, is it valid to select the "github self hosted" and "organization" settings as shown in the screenshot below?

1

And is it valid to select the "github.com" and "enterprise" settings as shown below?

2

It is crucial that users cannot select an invalid combination of settings. However, since I have limited knowledge of GitHub's enterprise offerings, I am uncertain if this is achievable.

I am happy to continue with this PR if someone can verify that all combinations of settings are valid and that Tartelet exhibits the expected behavior.

@@ -12,6 +12,8 @@ struct GitHubPrivateKeyPicker: View {
L10n.Settings.Github.PrivateKey.Scopes.organization
case .repo:
L10n.Settings.Github.PrivateKey.Scopes.repository
case .enterpriseServer:
"Check permissions: `manage_runners:enterprise`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and formatted similar to the other texts listing required permissions.


if viewModel.version == .enterprise {
TextField(
"Self hosted URL",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and accessed through the L10n constant.

TextField(
"Self hosted URL",
text: $viewModel.selfHostedRaw,
prompt: Text("Github Service raw value")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and accessed through the L10n constant.

@@ -41,6 +56,13 @@ struct GitHubSettingsView: View {
prompt: Text(L10n.Settings.Github.RepositoryName.prompt)
)
.disabled(!viewModel.isSettingsEnabled)
case .enterpriseServer:
TextField(
"Enterprise name",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and accessed through the L10n constant.

@@ -77,6 +99,19 @@ private extension GitHubRunnerScope {
L10n.Settings.RunnerScope.organization
case .repo:
L10n.Settings.RunnerScope.repository
case .enterpriseServer:
"Enterprise"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and accessed through the L10n constant.

Comment on lines +4 to +5
case dotCom
case enterprise(URL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These enum cases don't seem to be used. Can we remove them and simplify this enum?

case .dotCom:
return "github.com"
case .enterprise:
return "github self hosted"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfamiliar with enterprise GitHub setups and self-hosting so please correct me if I'm wrong but the enterprise enum case seems to refer to GitHub Enterprise Server. Would it make sense to rename the case and the title to be more explicit about this and avoid confusion with the enterprise runner scope?

Comment on lines +75 to +78
let runnerScope = tuple.0
let organizationName = tuple.1
let ownerName = tuple.2
let repositoryName = tuple.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good opportunity to use tuple destructuring.

Suggested change
let runnerScope = tuple.0
let organizationName = tuple.1
let ownerName = tuple.2
let repositoryName = tuple.3
let (runnerScope, organizationName, ownerName, repositoryName) = tuple

@@ -14,6 +14,21 @@ struct GitHubSettingsView: View {
var body: some View {
Form {
Section {
Picker("Version", selection: $viewModel.version) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text needs to be localized and accessed through the L10n constant.

ForEach(GitHubServiceVersion.Kind.allCases, id: \.self) { scope in
Text(scope.title)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to turn this picker into a segmented control to align with the Runner Scope setting?

Suggested change
}
}
.pickerStyle(.segmented)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow GitHub URLs to be set in settings to support GitHub Enterprise and Enterprise Cloud
3 participants