fix: unused-parameter linter findings

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
This commit is contained in:
Mario Constanti 2024-02-22 08:38:44 +01:00
parent 3b9f8b555b
commit 0ab86a7e51
8 changed files with 21 additions and 22 deletions

View file

@ -161,12 +161,12 @@ func (_m *Provider) Start(ctx context.Context, instance string) error {
}
// Stop provides a mock function with given fields: ctx, instance, force
func (_m *Provider) Stop(ctx context.Context, instance string, force bool) error {
ret := _m.Called(ctx, instance, force)
func (_m *Provider) Stop(ctx context.Context, instance string) error {
ret := _m.Called(ctx, instance)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, bool) error); ok {
r0 = rf(ctx, instance, force)
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, instance)
} else {
r0 = ret.Error(0)
}

View file

@ -34,7 +34,7 @@ type Provider interface {
// RemoveAllInstances will remove all instances created by this provider.
RemoveAllInstances(ctx context.Context) error
// Stop shuts down the instance.
Stop(ctx context.Context, instance string, force bool) error
Stop(ctx context.Context, instance string) error
// Start boots up an instance.
Start(ctx context.Context, instance string) error
// DisableJITConfig tells us if the provider explicitly disables JIT configuration and

View file

@ -1,14 +1,11 @@
package metrics
import (
"context"
"github.com/cloudbase/garm/metrics"
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner"
)
func CollectHealthMetric(ctx context.Context, r *runner.Runner, controllerInfo params.ControllerInfo) error {
func CollectHealthMetric(controllerInfo params.ControllerInfo) error {
metrics.GarmHealth.WithLabelValues(
controllerInfo.MetadataURL, // label: metadata_url
controllerInfo.CallbackURL, // label: callback_url

View file

@ -82,7 +82,7 @@ func collectMetrics(ctx context.Context, r *runner.Runner, controllerInfo params
}
slog.DebugContext(ctx, "collecting health metrics")
err = CollectHealthMetric(ctx, r, controllerInfo)
err = CollectHealthMetric(controllerInfo)
if err != nil {
return err
}

View file

@ -77,7 +77,7 @@ type enterprise struct {
mux sync.Mutex
}
func (r *enterprise) findRunnerGroupByName(ctx context.Context, name string) (*github.EnterpriseRunnerGroup, error) {
func (r *enterprise) findRunnerGroupByName(name string) (*github.EnterpriseRunnerGroup, error) {
// TODO(gabriel-samfira): implement caching
opts := github.ListEnterpriseRunnerGroupOptions{
ListOptions: github.ListOptions{
@ -118,7 +118,7 @@ func (r *enterprise) findRunnerGroupByName(ctx context.Context, name string) (*g
func (r *enterprise) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) {
var rg int64 = 1
if pool.GitHubRunnerGroup != "" {
runnerGroup, err := r.findRunnerGroupByName(ctx, pool.GitHubRunnerGroup)
runnerGroup, err := r.findRunnerGroupByName(pool.GitHubRunnerGroup)
if err != nil {
return nil, nil, fmt.Errorf("failed to find runner group: %w", err)
}
@ -392,14 +392,14 @@ func (r *enterprise) ID() string {
return r.id
}
func (r *enterprise) InstallHook(ctx context.Context, req *github.Hook) (params.HookInfo, error) {
func (r *enterprise) InstallHook(_ context.Context, _ *github.Hook) (params.HookInfo, error) {
return params.HookInfo{}, fmt.Errorf("not implemented")
}
func (r *enterprise) UninstallHook(ctx context.Context, url string) error {
func (r *enterprise) UninstallHook(_ context.Context, _ string) error {
return fmt.Errorf("not implemented")
}
func (r *enterprise) GetHookInfo(ctx context.Context) (params.HookInfo, error) {
func (r *enterprise) GetHookInfo(_ context.Context) (params.HookInfo, error) {
return params.HookInfo{}, fmt.Errorf("not implemented")
}

View file

@ -89,7 +89,7 @@ type organization struct {
mux sync.Mutex
}
func (r *organization) findRunnerGroupByName(ctx context.Context, name string) (*github.RunnerGroup, error) {
func (r *organization) findRunnerGroupByName(name string) (*github.RunnerGroup, error) {
// TODO(gabriel-samfira): implement caching
opts := github.ListOrgRunnerGroupOptions{
ListOptions: github.ListOptions{
@ -130,7 +130,7 @@ func (r *organization) findRunnerGroupByName(ctx context.Context, name string) (
func (r *organization) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) {
var rg int64 = 1
if pool.GitHubRunnerGroup != "" {
runnerGroup, err := r.findRunnerGroupByName(ctx, pool.GitHubRunnerGroup)
runnerGroup, err := r.findRunnerGroupByName(pool.GitHubRunnerGroup)
if err != nil {
return nil, nil, fmt.Errorf("failed to find runner group: %w", err)
}

View file

@ -91,6 +91,8 @@ type repository struct {
mux sync.Mutex
}
// nolint:golint,revive
// pool is used in enterprise and organzation
func (r *repository) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) {
req := github.GenerateJITConfigRequest{
Name: instance,

View file

@ -50,7 +50,7 @@ type external struct {
environmentVariables []string
}
func (e *external) validateResult(ctx context.Context, inst commonParams.ProviderInstance) error {
func (e *external) validateResult(inst commonParams.ProviderInstance) error {
if inst.ProviderID == "" {
return garmErrors.NewProviderError("missing provider ID")
}
@ -104,7 +104,7 @@ func (e *external) CreateInstance(ctx context.Context, bootstrapParams commonPar
return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
}
if err := e.validateResult(ctx, param); err != nil {
if err := e.validateResult(param); err != nil {
metrics.InstanceOperationFailedCount.WithLabelValues(
"CreateInstance", // label: operation
e.cfg.Name, // label: provider
@ -181,7 +181,7 @@ func (e *external) GetInstance(ctx context.Context, instance string) (commonPara
return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
}
if err := e.validateResult(ctx, param); err != nil {
if err := e.validateResult(param); err != nil {
metrics.InstanceOperationFailedCount.WithLabelValues(
"GetInstance", // label: operation
e.cfg.Name, // label: provider
@ -227,7 +227,7 @@ func (e *external) ListInstances(ctx context.Context, poolID string) ([]commonPa
ret := make([]commonParams.ProviderInstance, len(param))
for idx, inst := range param {
if err := e.validateResult(ctx, inst); err != nil {
if err := e.validateResult(inst); err != nil {
metrics.InstanceOperationFailedCount.WithLabelValues(
"ListInstances", // label: operation
e.cfg.Name, // label: provider
@ -265,7 +265,7 @@ func (e *external) RemoveAllInstances(ctx context.Context) error {
}
// Stop shuts down the instance.
func (e *external) Stop(ctx context.Context, instance string, force bool) error {
func (e *external) Stop(ctx context.Context, instance string) error {
asEnv := []string{
fmt.Sprintf("GARM_COMMAND=%s", execution.StopInstanceCommand),
fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID),