feat: add github_enterprise_actions_hosted_runner#3017
feat: add github_enterprise_actions_hosted_runner#3017nico34638 wants to merge 6 commits intointegrations:mainfrom
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
|
Hey @nico34638 👋 Thank you very much for your contribution! We're currently working on a major release of the provider and that will possibly delay getting this PR merged. While that's happening, could I bother you for a few changes?
Support for Hosted runners for enterprises was added in v70 of go-github. Our upcoming major release will upgrade to v77. Could you rebase your branch on top of #2891 and use the SDK methods instead of manual HTTP requests? :) |
|
Okay, I made the changes you requested. I rebased on your branch with go github/v77 and changed the description fields. Is that okay with you? I tested it, and with the changes, it still works. |
|
Hey @nico34638 |
|
Hey @deiga, It's done. Do you have any idea when the provider's next release will be? |
deiga
left a comment
There was a problem hiding this comment.
Please ensure the test structure follows the current pattern
36951d4 to
9ac9b53
Compare
|
I have corrected the comments |
|
Hi @deiga do you any news ? |
stevehipwell
left a comment
There was a problem hiding this comment.
Thanks for the PR @nico34638, I've added some initial review comments.
|
Following the last review, I'm taking this opportunity to add two data sources for hosted enterprise runners: |
|
Hi @stevehipwell @deiga Do you have any news ? |
deiga
left a comment
There was a problem hiding this comment.
Please ensure to propagate comments to other places where they would be applicable
06b9a9c to
54d4fbe
Compare
deiga
left a comment
There was a problem hiding this comment.
Please read through your own code and see to it that it's consistent with itself.
I don't know if you use an LLM to generate code or are just in a hurry, but please don't make us comment multiple times on the same issues
|
Thanks for the feedback. I apologize for the inconsistencies. I am really trying my best to keep this PR clean, but it is not that simple. Reviews are spaced about many weeks apart. It is hard to keep track of comments made two months ago. The requirements also keep changing mid-flight. For example, we now need datasources in addition to resources to get merged. On top of that, the codebase is being refactored. I have reviewed the code again and updated a few more details on my end. However, I would really appreciate more specific information on what exactly still needs to change |
| "size": { | ||
| Type: schema.TypeString, | ||
| Required: true, | ||
| Description: "Machine size for the hosted runner (e.g., '4-core', '8-core'). This determines the CPU, memory, and storage resources allocated to the runner. Can be updated to scale the runner. To list available sizes, use the GitHub API: GET /enterprises/{enterprise}/actions/hosted-runners/machine-sizes.", |
There was a problem hiding this comment.
question: would this benefit from having a validation that the string ends in <number>-core?
There was a problem hiding this comment.
I don't think that's necessary, the API error is already clear.
There was a problem hiding this comment.
But validation happens before API call, which means less wasted rate limit usage
faa7c93 to
4572819
Compare
| `, testAccConf.enterpriseSlug, testResourcePrefix, randomID, testResourcePrefix, randomID) | ||
|
|
||
| resource.Test(t, resource.TestCase{ | ||
| PreCheck: func() { skipUnlessMode(t, enterprise) }, |
There was a problem hiding this comment.
| PreCheck: func() { skipUnlessMode(t, enterprise) }, | |
| PreCheck: func() { skipUnlessEnterprise(t) }, |
|
|
||
| func dataSourceGithubEnterpriseActionsHostedRunner() *schema.Resource { | ||
| return &schema.Resource{ | ||
| ReadContext: dataSourceGithubEnterpriseActionsHostedRunnerRead, |
There was a problem hiding this comment.
Please add a top-level Description
| runnerData := map[string]any{ | ||
| "name": runner.GetName(), | ||
| "runner_group_id": int(runner.GetRunnerGroupID()), | ||
| "platform": runner.GetPlatform(), | ||
| "status": runner.GetStatus(), | ||
| "maximum_runners": int(runner.GetMaximumRunners()), | ||
| "public_ip_enabled": runner.GetPublicIPEnabled(), | ||
| "image_details": flattenHostedRunnerImage(runner.ImageDetails), | ||
| "machine_size_details": flattenHostedRunnerMachineSpec(runner.MachineSizeDetails), | ||
| "public_ips": flattenHostedRunnerPublicIPs(runner.PublicIPs), | ||
| } | ||
|
|
||
| if runner.LastActiveOn != nil { | ||
| runnerData["last_active_on"] = runner.LastActiveOn.Format(time.RFC3339) | ||
| } | ||
|
|
||
| for k, v := range runnerData { | ||
| if err := d.Set(k, v); err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
| } |
There was a problem hiding this comment.
issue: Please simplify this structure to just use d.Set without this map. This does not improve clarity, nor does it win us anything
|
|
||
| func dataSourceGithubEnterpriseActionsHostedRunners() *schema.Resource { | ||
| return &schema.Resource{ | ||
| ReadContext: dataSourceGithubEnterpriseActionsHostedRunnersRead, |
There was a problem hiding this comment.
Please add a top-level Description
| Delete: schema.DefaultTimeout(15 * time.Minute), | ||
| }, | ||
|
|
||
| Schema: map[string]*schema.Schema{ |
There was a problem hiding this comment.
Please add a top-level Description
| return diag.Errorf("error updating enterprise hosted runner: %s", err.Error()) | ||
| } | ||
|
|
||
| return resourceGithubEnterpriseActionsHostedRunnerRead(ctx, d, meta) |
There was a problem hiding this comment.
Never call any CRUD functions in any part of the code
| return resourceGithubEnterpriseActionsHostedRunnerRead(ctx, d, meta) | |
| return nil |
| enterpriseSlug, runnerIDStr, err := parseID2(d.Id()) | ||
| if err != nil { | ||
| return diag.FromErr(err) | ||
| } | ||
|
|
||
| runnerID, err := strconv.ParseInt(runnerIDStr, 10, 64) | ||
| if err != nil { | ||
| return diag.Errorf("invalid runner ID %q: %s", runnerIDStr, err.Error()) | ||
| } |
There was a problem hiding this comment.
issue: both fields exists in State already, there should be no need to have parsing code here
| } | ||
| `, testAccConf.enterpriseSlug, randomID, randomID) | ||
|
|
||
| configUpdated := fmt.Sprintf(` |
There was a problem hiding this comment.
Use only one template string and fmt.Sprintf to build the config
| return nil | ||
| } | ||
|
|
||
| imageMap := imageList[0].(map[string]any) |
There was a problem hiding this comment.
Please add some explanation why we are only accessing the first item.
There was a problem hiding this comment.
These functions are missing tests, please add them
Resolves #3016
Before the change?
After the change?
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!