Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ linters:
- EncryptedSecret
- EnterpriseSecurityAnalysisSettings
- ExternalGroup
- GenerateJITConfigRequest
- Hook
- HookConfig
- ImpersonateUserOptions
Expand Down
27 changes: 15 additions & 12 deletions github/actions_runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, own
return rads, resp, nil
}

// GenerateJITConfigRequest specifies body parameters to GenerateRepoJITConfig.
type GenerateJITConfigRequest struct {
// CreateJITConfigRequest specifies body parameters to CreateOrgJITConfig, CreateRepoJITConfig, and CreateEnterpriseJITConfig.
type CreateJITConfigRequest struct {
Name string `json:"name"`
RunnerGroupID int64 `json:"runner_group_id"`
WorkFolder *string `json:"work_folder,omitempty"`
Expand All @@ -58,12 +58,12 @@ type JITRunnerConfig struct {
EncodedJITConfig *string `json:"encoded_jit_config,omitempty"`
}

// GenerateOrgJITConfig generate a just-in-time configuration for an organization.
// CreateOrgJITConfig creates a just-in-time configuration for an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/runners/generate-jitconfig
func (s *ActionsService) GenerateOrgJITConfig(ctx context.Context, org string, body *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
func (s *ActionsService) CreateOrgJITConfig(ctx context.Context, org string, body CreateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/runners/generate-jitconfig", org)
req, err := s.client.NewRequest(ctx, "POST", u, body)
if err != nil {
Expand All @@ -79,12 +79,12 @@ func (s *ActionsService) GenerateOrgJITConfig(ctx context.Context, org string, b
return jitConfig, resp, nil
}

// GenerateRepoJITConfig generates a just-in-time configuration for a repository.
// CreateRepoJITConfig creates a just-in-time configuration for a repository.
//
// GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-a-repository
//
//meta:operation POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig
func (s *ActionsService) GenerateRepoJITConfig(ctx context.Context, owner, repo string, body *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
func (s *ActionsService) CreateRepoJITConfig(ctx context.Context, owner, repo string, body CreateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runners/generate-jitconfig", owner, repo)
req, err := s.client.NewRequest(ctx, "POST", u, body)
if err != nil {
Expand Down Expand Up @@ -130,12 +130,15 @@ func (s *ActionsService) CreateRegistrationToken(ctx context.Context, owner, rep

// Runner represents a self-hosted runner registered with a repository.
type Runner struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
OS *string `json:"os,omitempty"`
Status *string `json:"status,omitempty"`
Busy *bool `json:"busy,omitempty"`
Labels []*RunnerLabels `json:"labels,omitempty"`
ID *int64 `json:"id,omitempty"`
RunnerGroupID *int64 `json:"runner_group_id,omitempty"`
Name *string `json:"name,omitempty"`
OS *string `json:"os,omitempty"`
Status *string `json:"status,omitempty"`
Busy *bool `json:"busy,omitempty"`
Labels []*RunnerLabels `json:"labels,omitempty"`
Ephemeral *bool `json:"ephemeral,omitempty"`
Version *string `json:"version,omitempty"`
}

// RunnerLabels represents a collection of labels attached to each runner.
Expand Down
32 changes: 16 additions & 16 deletions github/actions_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func TestActionsService_ListRunnerApplicationDownloads(t *testing.T) {
})
}

func TestActionsService_GenerateOrgJITConfig(t *testing.T) {
func TestActionsService_CreateOrgJITConfig(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &GenerateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}
input := CreateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}

mux.HandleFunc("/orgs/o/actions/runners/generate-jitconfig", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand All @@ -67,36 +67,36 @@ func TestActionsService_GenerateOrgJITConfig(t *testing.T) {
})

ctx := t.Context()
jitConfig, _, err := client.Actions.GenerateOrgJITConfig(ctx, "o", input)
jitConfig, _, err := client.Actions.CreateOrgJITConfig(ctx, "o", input)
if err != nil {
t.Errorf("Actions.GenerateOrgJITConfig returned error: %v", err)
t.Errorf("Actions.CreateOrgJITConfig returned error: %v", err)
}

want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")}
if !cmp.Equal(jitConfig, want) {
t.Errorf("Actions.GenerateOrgJITConfig returned %+v, want %+v", jitConfig, want)
t.Errorf("Actions.CreateOrgJITConfig returned %+v, want %+v", jitConfig, want)
}

const methodName = "GenerateOrgJITConfig"
const methodName = "CreateOrgJITConfig"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GenerateOrgJITConfig(ctx, "\n", input)
_, _, err = client.Actions.CreateOrgJITConfig(ctx, "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.GenerateOrgJITConfig(ctx, "o", input)
got, resp, err := client.Actions.CreateOrgJITConfig(ctx, "o", input)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestActionsService_GenerateRepoJITConfig(t *testing.T) {
func TestActionsService_CreateRepoJITConfig(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &GenerateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}
input := CreateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}

mux.HandleFunc("/repos/o/r/actions/runners/generate-jitconfig", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand All @@ -105,24 +105,24 @@ func TestActionsService_GenerateRepoJITConfig(t *testing.T) {
})

ctx := t.Context()
jitConfig, _, err := client.Actions.GenerateRepoJITConfig(ctx, "o", "r", input)
jitConfig, _, err := client.Actions.CreateRepoJITConfig(ctx, "o", "r", input)
if err != nil {
t.Errorf("Actions.GenerateRepoJITConfig returned error: %v", err)
t.Errorf("Actions.CreateRepoJITConfig returned error: %v", err)
}

want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")}
if !cmp.Equal(jitConfig, want) {
t.Errorf("Actions.GenerateRepoJITConfig returned %+v, want %+v", jitConfig, want)
t.Errorf("Actions.CreateRepoJITConfig returned %+v, want %+v", jitConfig, want)
}

const methodName = "GenerateRepoJITConfig"
const methodName = "CreateRepoJITConfig"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GenerateRepoJITConfig(ctx, "\n", "\n", input)
_, _, err = client.Actions.CreateRepoJITConfig(ctx, "\n", "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.GenerateRepoJITConfig(ctx, "o", "r", input)
got, resp, err := client.Actions.CreateRepoJITConfig(ctx, "o", "r", input)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down
4 changes: 2 additions & 2 deletions github/enterprise_actions_runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context,
return rads, resp, nil
}

// GenerateEnterpriseJITConfig generates a just-in-time configuration for an enterprise.
// CreateEnterpriseJITConfig creates a just-in-time configuration for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-configuration-for-a-just-in-time-runner-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/runners/generate-jitconfig
func (s *EnterpriseService) GenerateEnterpriseJITConfig(ctx context.Context, enterprise string, body *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
func (s *EnterpriseService) CreateEnterpriseJITConfig(ctx context.Context, enterprise string, body CreateJITConfigRequest) (*JITRunnerConfig, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners/generate-jitconfig", enterprise)

req, err := s.client.NewRequest(ctx, "POST", u, body)
Expand Down
16 changes: 8 additions & 8 deletions github/enterprise_actions_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/google/go-cmp/cmp"
)

func TestEnterpriseService_GenerateEnterpriseJITConfig(t *testing.T) {
func TestEnterpriseService_CreateEnterpriseJITConfig(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &GenerateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}
input := CreateJITConfigRequest{Name: "test", RunnerGroupID: 1, Labels: []string{"one", "two"}}

mux.HandleFunc("/enterprises/o/actions/runners/generate-jitconfig", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand All @@ -26,24 +26,24 @@ func TestEnterpriseService_GenerateEnterpriseJITConfig(t *testing.T) {
})

ctx := t.Context()
jitConfig, _, err := client.Enterprise.GenerateEnterpriseJITConfig(ctx, "o", input)
jitConfig, _, err := client.Enterprise.CreateEnterpriseJITConfig(ctx, "o", input)
if err != nil {
t.Errorf("Enterprise.GenerateEnterpriseJITConfig returned error: %v", err)
t.Errorf("Enterprise.CreateEnterpriseJITConfig returned error: %v", err)
}

want := &JITRunnerConfig{EncodedJITConfig: Ptr("foo")}
if !cmp.Equal(jitConfig, want) {
t.Errorf("Enterprise.GenerateEnterpriseJITConfig returned %+v, want %+v", jitConfig, want)
t.Errorf("Enterprise.CreateEnterpriseJITConfig returned %+v, want %+v", jitConfig, want)
}

const methodName = "GenerateEnterpriseJITConfig"
const methodName = "CreateEnterpriseJITConfig"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Enterprise.GenerateEnterpriseJITConfig(ctx, "\n", input)
_, _, err = client.Enterprise.CreateEnterpriseJITConfig(ctx, "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Enterprise.GenerateEnterpriseJITConfig(ctx, "o", input)
got, resp, err := client.Enterprise.CreateEnterpriseJITConfig(ctx, "o", input)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down
88 changes: 56 additions & 32 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading