Repository: google/go-github
Pull request #2818 (2023-06-23 19:15:01)

Add Runner to generate-jitconfig method
Provide full response for generate-jitconfig method instead of `encoded_jit_config` only. According to the [doc](https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-a-repository) there is a `runner` object in the API response.

why do we need it? since the generate-jitconfig API is just not generating jitconfig but also creating new self-hosted runner to the github so there is no way we can get the newly created runner id other than from this response.

cc @mkulke @gmlewis 

gmlewis: Please run `go generate ./...` and push (not force push) the changes.
See CONTRIBUTING.md for details.
prksu: Hi @gmlewis apologize, I thought it was not reviewed yet. I have run `go generate ./...` as you suggest and push the changes.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/2818?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2818](https://app.codecov.io/gh/google/go-github/pull/2818?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (dafc163) into [master](https://app.codecov.io/gh/google/go-github/commit/3220fa010cf242cff2f2bf0f850e928e4c911e24?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (3220fa0) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #2818   +/-   ##
=======================================
  Coverage   98.05%   98.05%           
=======================================
  Files         136      136           
  Lines       12263    12263           
=======================================
  Hits        12025    12025           
  Misses        162      162           
  Partials       76       76           
```


| [Impacted Files](https://app.codecov.io/gh/google/go-github/pull/2818?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/actions\_runners.go](https://app.codecov.io/gh/google/go-github/pull/2818?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FjdGlvbnNfcnVubmVycy5nbw==) | `100.00% <ø> (ø)` | |



Patch:
diff --git a/github/actions_runners.go b/github/actions_runners.go
index 3990a5a9..7427451c 100644
--- a/github/actions_runners.go
+++ b/github/actions_runners.go
@@ -58,6 +58,7 @@ type GenerateJITConfigRequest struct {
 
 // JITRunnerConfig represents encoded JIT configuration that can be used to bootstrap a self-hosted runner.
 type JITRunnerConfig struct {
+	Runner           *Runner `json:"runner,omitempty"`
 	EncodedJITConfig *string `json:"encoded_jit_config,omitempty"`
 }
 
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 8acb72b0..01b5796f 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -9406,6 +9406,14 @@ func (j *JITRunnerConfig) GetEncodedJITConfig() string {
 	return *j.EncodedJITConfig
 }
 
+// GetRunner returns the Runner field.
+func (j *JITRunnerConfig) GetRunner() *Runner {
+	if j == nil {
+		return nil
+	}
+	return j.Runner
+}
+
 // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise.
 func (j *Jobs) GetTotalCount() int {
 	if j == nil || j.TotalCount == nil {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 3f39d9c1..959edc4d 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -11029,6 +11029,13 @@ func TestJITRunnerConfig_GetEncodedJITConfig(tt *testing.T) {
 	j.GetEncodedJITConfig()
 }
 
+func TestJITRunnerConfig_GetRunner(tt *testing.T) {
+	j := &JITRunnerConfig{}
+	j.GetRunner()
+	j = nil
+	j.GetRunner()
+}
+
 func TestJobs_GetTotalCount(tt *testing.T) {
 	var zeroValue int
 	j := &Jobs{TotalCount: &zeroValue}