garm/runner/common/mocks/GithubEnterpriseClient.go
Gabriel Adrian Samfira 9a6770c3a3 Allow bypassing Unauthorized error when deleting runner
This change allows users to bypass GitHub Unauthorized errors when removing
github runners. This means that removing runners will now be possible even
if the pool manager is stopped.

There is a new flag added to the runner rm command and to the API that
tells GARM to bypass pool being stopped and any 401 error returned by
GitHub.

This means you will be able to remove the runners from garm and your
provider, but will mean that the runner will still exist in github as
"offline" if the credentials are not updated or the runner manually removed.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-10 15:21:39 +00:00

254 lines
7.8 KiB
Go

// Code generated by mockery v2.42.0. DO NOT EDIT.
package mocks
import (
context "context"
github "github.com/google/go-github/v57/github"
mock "github.com/stretchr/testify/mock"
)
// GithubEnterpriseClient is an autogenerated mock type for the GithubEnterpriseClient type
type GithubEnterpriseClient struct {
mock.Mock
}
// CreateRegistrationToken provides a mock function with given fields: ctx, enterprise
func (_m *GithubEnterpriseClient) CreateRegistrationToken(ctx context.Context, enterprise string) (*github.RegistrationToken, *github.Response, error) {
ret := _m.Called(ctx, enterprise)
if len(ret) == 0 {
panic("no return value specified for CreateRegistrationToken")
}
var r0 *github.RegistrationToken
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string) (*github.RegistrationToken, *github.Response, error)); ok {
return rf(ctx, enterprise)
}
if rf, ok := ret.Get(0).(func(context.Context, string) *github.RegistrationToken); ok {
r0 = rf(ctx, enterprise)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.RegistrationToken)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string) *github.Response); ok {
r1 = rf(ctx, enterprise)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string) error); ok {
r2 = rf(ctx, enterprise)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// GenerateEnterpriseJITConfig provides a mock function with given fields: ctx, enterprise, request
func (_m *GithubEnterpriseClient) GenerateEnterpriseJITConfig(ctx context.Context, enterprise string, request *github.GenerateJITConfigRequest) (*github.JITRunnerConfig, *github.Response, error) {
ret := _m.Called(ctx, enterprise, request)
if len(ret) == 0 {
panic("no return value specified for GenerateEnterpriseJITConfig")
}
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, enterprise, request)
}
if rf, ok := ret.Get(0).(func(context.Context, string, *github.GenerateJITConfigRequest) *github.JITRunnerConfig); ok {
r0 = rf(ctx, enterprise, 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, enterprise, 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, enterprise, request)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// ListRunnerApplicationDownloads provides a mock function with given fields: ctx, enterprise
func (_m *GithubEnterpriseClient) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*github.RunnerApplicationDownload, *github.Response, error) {
ret := _m.Called(ctx, enterprise)
if len(ret) == 0 {
panic("no return value specified for ListRunnerApplicationDownloads")
}
var r0 []*github.RunnerApplicationDownload
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string) ([]*github.RunnerApplicationDownload, *github.Response, error)); ok {
return rf(ctx, enterprise)
}
if rf, ok := ret.Get(0).(func(context.Context, string) []*github.RunnerApplicationDownload); ok {
r0 = rf(ctx, enterprise)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*github.RunnerApplicationDownload)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string) *github.Response); ok {
r1 = rf(ctx, enterprise)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string) error); ok {
r2 = rf(ctx, enterprise)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// ListRunnerGroups provides a mock function with given fields: ctx, enterprise, opts
func (_m *GithubEnterpriseClient) ListRunnerGroups(ctx context.Context, enterprise string, opts *github.ListEnterpriseRunnerGroupOptions) (*github.EnterpriseRunnerGroups, *github.Response, error) {
ret := _m.Called(ctx, enterprise, opts)
if len(ret) == 0 {
panic("no return value specified for ListRunnerGroups")
}
var r0 *github.EnterpriseRunnerGroups
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, *github.ListEnterpriseRunnerGroupOptions) (*github.EnterpriseRunnerGroups, *github.Response, error)); ok {
return rf(ctx, enterprise, opts)
}
if rf, ok := ret.Get(0).(func(context.Context, string, *github.ListEnterpriseRunnerGroupOptions) *github.EnterpriseRunnerGroups); ok {
r0 = rf(ctx, enterprise, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.EnterpriseRunnerGroups)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, *github.ListEnterpriseRunnerGroupOptions) *github.Response); ok {
r1 = rf(ctx, enterprise, opts)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, *github.ListEnterpriseRunnerGroupOptions) error); ok {
r2 = rf(ctx, enterprise, opts)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// ListRunners provides a mock function with given fields: ctx, enterprise, opts
func (_m *GithubEnterpriseClient) ListRunners(ctx context.Context, enterprise string, opts *github.ListOptions) (*github.Runners, *github.Response, error) {
ret := _m.Called(ctx, enterprise, opts)
if len(ret) == 0 {
panic("no return value specified for ListRunners")
}
var r0 *github.Runners
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, *github.ListOptions) (*github.Runners, *github.Response, error)); ok {
return rf(ctx, enterprise, opts)
}
if rf, ok := ret.Get(0).(func(context.Context, string, *github.ListOptions) *github.Runners); ok {
r0 = rf(ctx, enterprise, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.Runners)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, *github.ListOptions) *github.Response); ok {
r1 = rf(ctx, enterprise, opts)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, *github.ListOptions) error); ok {
r2 = rf(ctx, enterprise, opts)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// RemoveRunner provides a mock function with given fields: ctx, enterprise, runnerID
func (_m *GithubEnterpriseClient) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*github.Response, error) {
ret := _m.Called(ctx, enterprise, runnerID)
if len(ret) == 0 {
panic("no return value specified for RemoveRunner")
}
var r0 *github.Response
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, int64) (*github.Response, error)); ok {
return rf(ctx, enterprise, runnerID)
}
if rf, ok := ret.Get(0).(func(context.Context, string, int64) *github.Response); ok {
r0 = rf(ctx, enterprise, runnerID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.Response)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok {
r1 = rf(ctx, enterprise, runnerID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewGithubEnterpriseClient(t interface {
mock.TestingT
Cleanup(func())
}) *GithubEnterpriseClient {
mock := &GithubEnterpriseClient{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}