mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 19:50:30 +00:00
Get RunnerScaleSet based on both RunnerGroupId and Name. (#2413)
This commit is contained in:
@@ -31,7 +31,7 @@ const (
|
||||
|
||||
//go:generate mockery --inpackage --name=ActionsService
|
||||
type ActionsService interface {
|
||||
GetRunnerScaleSet(ctx context.Context, runnerScaleSetName string) (*RunnerScaleSet, error)
|
||||
GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)
|
||||
GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)
|
||||
GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)
|
||||
CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
|
||||
@@ -285,8 +285,8 @@ func (c *Client) NewActionsServiceRequest(ctx context.Context, method, path stri
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetRunnerScaleSet(ctx context.Context, runnerScaleSetName string) (*RunnerScaleSet, error) {
|
||||
path := fmt.Sprintf("/%s?name=%s", scaleSetEndpoint, runnerScaleSetName)
|
||||
func (c *Client) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error) {
|
||||
path := fmt.Sprintf("/%s?runnerGroupId=%d&name=%s", scaleSetEndpoint, runnerGroupId, runnerScaleSetName)
|
||||
req, err := c.NewActionsServiceRequest(ctx, http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
got, err := client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
got, err := client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, want, got)
|
||||
})
|
||||
@@ -50,7 +50,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
_, err = client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedPath := "/tenant/123/_apis/runtime/runnerscalesets"
|
||||
@@ -67,7 +67,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
_, err = client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
assert.NotNil(t, err)
|
||||
})
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
_, err = client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
assert.NotNil(t, err)
|
||||
})
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
_, err = client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
assert.NotNil(t, err)
|
||||
expectedRetry := retryMax + 1
|
||||
assert.Equalf(t, actualRetry, expectedRetry, "A retry was expected after the first request but got: %v", actualRetry)
|
||||
@@ -118,7 +118,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
got, err := client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
got, err := client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, want, got)
|
||||
})
|
||||
@@ -133,7 +133,7 @@ func TestGetRunnerScaleSet(t *testing.T) {
|
||||
client, err := actions.NewClient(server.configURLForOrg("my-org"), auth)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.GetRunnerScaleSet(ctx, scaleSetName)
|
||||
_, err = client.GetRunnerScaleSet(ctx, 1, scaleSetName)
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, wantErr.Error(), err.Error())
|
||||
})
|
||||
|
||||
@@ -215,7 +215,7 @@ func (f *FakeClient) applyDefaults() {
|
||||
f.getRunnerByNameResult.RunnerReference = defaultRunnerReference
|
||||
}
|
||||
|
||||
func (f *FakeClient) GetRunnerScaleSet(ctx context.Context, runnerScaleSetName string) (*actions.RunnerScaleSet, error) {
|
||||
func (f *FakeClient) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*actions.RunnerScaleSet, error) {
|
||||
return f.getRunnerScaleSetResult.RunnerScaleSet, f.getRunnerScaleSetResult.err
|
||||
}
|
||||
|
||||
|
||||
@@ -263,13 +263,13 @@ func (_m *MockActionsService) GetRunnerGroupByName(ctx context.Context, runnerGr
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSetName
|
||||
func (_m *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerScaleSetName string) (*RunnerScaleSet, error) {
|
||||
ret := _m.Called(ctx, runnerScaleSetName)
|
||||
// GetRunnerScaleSet provides a mock function with given fields: ctx, runnerGroupId, runnerScaleSetName
|
||||
func (_m *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error) {
|
||||
ret := _m.Called(ctx, runnerGroupId, runnerScaleSetName)
|
||||
|
||||
var r0 *RunnerScaleSet
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) *RunnerScaleSet); ok {
|
||||
r0 = rf(ctx, runnerScaleSetName)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int, string) *RunnerScaleSet); ok {
|
||||
r0 = rf(ctx, runnerGroupId, runnerScaleSetName)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*RunnerScaleSet)
|
||||
@@ -277,8 +277,8 @@ func (_m *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerScale
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, runnerScaleSetName)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int, string) error); ok {
|
||||
r1 = rf(ctx, runnerGroupId, runnerScaleSetName)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user