From 09d2f1b061eb27c19a6b624e9f583b0c6811b378 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Sat, 19 Aug 2023 16:49:41 +0000 Subject: [PATCH] Add Jit functions to GH client interface Signed-off-by: Gabriel Adrian Samfira --- runner/common/mocks/GithubClient.go | 70 +++++++++++++++++++++++++++++ runner/common/util.go | 4 ++ 2 files changed, 74 insertions(+) diff --git a/runner/common/mocks/GithubClient.go b/runner/common/mocks/GithubClient.go index f351b58e..918c60ff 100644 --- a/runner/common/mocks/GithubClient.go +++ b/runner/common/mocks/GithubClient.go @@ -206,6 +206,76 @@ func (_m *GithubClient) DeleteRepoHook(ctx context.Context, owner string, repo s return r0, r1 } +// GenerateOrgJITConfig provides a mock function with given fields: ctx, owner, request +func (_m *GithubClient) GenerateOrgJITConfig(ctx context.Context, owner string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error) { + ret := _m.Called(ctx, owner, request) + + var r0 *github.JITRunnerConfig + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error)); ok { + return rf(ctx, owner, request) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *github.GenerateJITConfigRequest) *github.JITRunnerConfig); ok { + r0 = rf(ctx, owner, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.JITRunnerConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *github.GenerateJITConfigRequest) *github.Response); ok { + r1 = rf(ctx, owner, request) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, *github.GenerateJITConfigRequest) error); ok { + r2 = rf(ctx, owner, request) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// GenerateRepoJITConfig provides a mock function with given fields: ctx, owner, repo, request +func (_m *GithubClient) GenerateRepoJITConfig(ctx context.Context, owner string, repo string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error) { + ret := _m.Called(ctx, owner, repo, request) + + var r0 *github.JITRunnerConfig + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error)); ok { + return rf(ctx, owner, repo, request) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, *github.GenerateJITConfigRequest) *github.JITRunnerConfig); ok { + r0 = rf(ctx, owner, repo, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.JITRunnerConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, *github.GenerateJITConfigRequest) *github.Response); ok { + r1 = rf(ctx, owner, repo, request) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string, string, *github.GenerateJITConfigRequest) error); ok { + r2 = rf(ctx, owner, repo, request) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // GetOrgHook provides a mock function with given fields: ctx, org, id func (_m *GithubClient) GetOrgHook(ctx context.Context, org string, id int64) (*github.Hook, *github.Response, error) { ret := _m.Called(ctx, org, id) diff --git a/runner/common/util.go b/runner/common/util.go index 42f1cc08..7637fb1c 100644 --- a/runner/common/util.go +++ b/runner/common/util.go @@ -41,6 +41,8 @@ type GithubClient interface { RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*github.Response, error) // CreateRegistrationToken creates a runner registration token for one repository. CreateRegistrationToken(ctx context.Context, owner, repo string) (*github.RegistrationToken, *github.Response, error) + // GenerateRepoJITConfig generates a just-in-time configuration for a repository. + GenerateRepoJITConfig(ctx context.Context, owner, repo string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error) // ListOrganizationRunners lists all runners within an organization. ListOrganizationRunners(ctx context.Context, owner string, opts *github.ListOptions) (*github.Runners, *github.Response, error) @@ -51,6 +53,8 @@ type GithubClient interface { RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*github.Response, error) // CreateOrganizationRegistrationToken creates a runner registration token for an organization. CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*github.RegistrationToken, *github.Response, error) + // GenerateOrgJITConfig generate a just-in-time configuration for an organization. + GenerateOrgJITConfig(ctx context.Context, owner string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error) } type GithubEnterpriseClient interface {