Skip to content

Commit

Permalink
satisfy linter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmeranda committed Feb 10, 2023
1 parent ecbc812 commit 6f1e119
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
15 changes: 8 additions & 7 deletions pkg/gateway/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func (d *DelegateServer) Request(ctx context.Context, req *streamv1.DelegatedMes
"request", req.GetRequest().QualifiedMethodName(),
)
lg.Debug("delegating rpc request")
if target, ok := d.activeAgents[targetId]; ok {
target, ok := d.activeAgents[targetId]
if ok {
fwdResp := &totem.RPC{}
err := target.Invoke(ctx, totem.Forward, req.GetRequest(), fwdResp)
if err != nil {
Expand All @@ -108,13 +109,13 @@ func (d *DelegateServer) Request(ctx context.Context, req *streamv1.DelegatedMes
}

return resp, nil
} else {
err := status.Error(codes.NotFound, "target not found")
lg.With(
zap.Error(err),
).Warn("delegating rpc request failed")
return nil, err
}

err := status.Error(codes.NotFound, "target not found")
lg.With(
zap.Error(err),
).Warn("delegating rpc request failed")
return nil, err
}

func (d *DelegateServer) Broadcast(ctx context.Context, req *streamv1.BroadcastMessage) (*streamv1.BroadcastReplyList, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/opni/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func completeBootstrapTokens(cmd *cobra.Command, args []string, toComplete strin
return comps, cobra.ShellCompDirectiveNoFileComp
}

func completeImportTargets(cmd *cobra.Command, args []string, toComplete string, filters ...func(token *corev1.BootstrapToken) bool) ([]string, cobra.ShellCompDirective) {
func completeImportTargets(cmd *cobra.Command, args []string, toComplete string, _ ...func(token *corev1.BootstrapToken) bool) ([]string, cobra.ShellCompDirective) {
if err := importPreRunE(cmd, nil); err != nil {
return nil, cobra.ShellCompDirectiveError | cobra.ShellCompDirectiveNoFileComp
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/opni/commands/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ func BuildImportListCmd() *cobra.Command {
Use: "list <cluster>",
Short: "List available import targets",
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
case 0:
if len(args) == 0 {
return completeClusters(cmd, args, toComplete)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/opni/commands/setup_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ConfigureImportCommand(cmd *cobra.Command) {
}
}

func importPreRunE(cmd *cobra.Command, args []string) error {
func importPreRunE(cmd *cobra.Command, _ []string) error {
if managementListenAddress == "" {
panic("bug: managementListenAddress is empty")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/apis/apiextensions/stream/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ func (w *targetedDelegatingClient[T]) Invoke(ctx context.Context, method string,
return nil
}

func (w *targetedDelegatingClient[T]) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) {
func (w *targetedDelegatingClient[T]) NewStream(_ context.Context, _ *grpc.StreamDesc, _ string, _ ...grpc.CallOption) (grpc.ClientStream, error) {
panic("not implemented")
}
2 changes: 1 addition & 1 deletion plugins/metrics/pkg/agent/drivers/embedded_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ func (d *EmbeddedManagerNodeDriver) ConfigureNode(_ *node.MetricsCapabilityConfi

}

func (d *EmbeddedManagerNodeDriver) DiscoverPrometheuses(ctx context.Context, namespace string) ([]*remoteread.DiscoveryEntry, error) {
func (d *EmbeddedManagerNodeDriver) DiscoverPrometheuses(_ context.Context, _ string) ([]*remoteread.DiscoveryEntry, error) {
return []*remoteread.DiscoveryEntry{}, nil
}
6 changes: 3 additions & 3 deletions plugins/metrics/pkg/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (m *MetricsNode) GetHealth(_ context.Context, _ *emptypb.Empty) (*corev1.He

// Start Implements remoteread.RemoteReadServer

func (m *MetricsNode) Start(ctx context.Context, request *remoteread.StartReadRequest) (*emptypb.Empty, error) {
func (m *MetricsNode) Start(_ context.Context, request *remoteread.StartReadRequest) (*emptypb.Empty, error) {
m.targetRunnerMu.Lock()
defer m.targetRunnerMu.Unlock()

Expand All @@ -194,7 +194,7 @@ func (m *MetricsNode) Start(ctx context.Context, request *remoteread.StartReadRe
return &emptypb.Empty{}, nil
}

func (m *MetricsNode) Stop(ctx context.Context, request *remoteread.StopReadRequest) (*emptypb.Empty, error) {
func (m *MetricsNode) Stop(_ context.Context, request *remoteread.StopReadRequest) (*emptypb.Empty, error) {
m.targetRunnerMu.Lock()
defer m.targetRunnerMu.Unlock()

Expand All @@ -205,7 +205,7 @@ func (m *MetricsNode) Stop(ctx context.Context, request *remoteread.StopReadRequ
return &emptypb.Empty{}, nil
}

func (m *MetricsNode) GetTargetStatus(ctx context.Context, request *remoteread.TargetStatusRequest) (*remoteread.TargetStatus, error) {
func (m *MetricsNode) GetTargetStatus(_ context.Context, request *remoteread.TargetStatusRequest) (*remoteread.TargetStatus, error) {
m.targetRunnerMu.RLock()
defer m.targetRunnerMu.RUnlock()

Expand Down
27 changes: 14 additions & 13 deletions plugins/metrics/pkg/agent/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ type targetStore struct {
inner map[string]*corev1.TaskStatus
}

func (store *targetStore) Put(ctx context.Context, key string, value *corev1.TaskStatus) error {
func (store *targetStore) Put(_ context.Context, key string, value *corev1.TaskStatus) error {
store.innerMu.Lock()
defer store.innerMu.Unlock()
store.inner[key] = value
return nil
}

func (store *targetStore) Get(ctx context.Context, key string) (*corev1.TaskStatus, error) {
func (store *targetStore) Get(_ context.Context, key string) (*corev1.TaskStatus, error) {
store.innerMu.RLock()
defer store.innerMu.RUnlock()

Expand All @@ -104,14 +104,14 @@ func (store *targetStore) Get(ctx context.Context, key string) (*corev1.TaskStat
return status, nil
}

func (store *targetStore) Delete(ctx context.Context, key string) error {
func (store *targetStore) Delete(_ context.Context, key string) error {
store.innerMu.Lock()
defer store.innerMu.Unlock()
delete(store.inner, key)
return nil
}

func (store *targetStore) ListKeys(ctx context.Context, prefix string) ([]string, error) {
func (store *targetStore) ListKeys(_ context.Context, prefix string) ([]string, error) {
store.innerMu.RLock()
defer store.innerMu.RUnlock()
keys := make([]string, 0, len(store.inner))
Expand Down Expand Up @@ -141,11 +141,11 @@ func (tr *taskRunner) SetRemoteReaderClient(client RemoteReader) {
tr.remoteReader = client
}

func (tr *taskRunner) OnTaskPending(ctx context.Context, activeTask task.ActiveTask) error {
func (tr *taskRunner) OnTaskPending(_ context.Context, _ task.ActiveTask) error {
return nil
}

func (tr *taskRunner) OnTaskRunning(ctx context.Context, activeTask task.ActiveTask) error {
func (tr *taskRunner) OnTaskRunning(_ context.Context, activeTask task.ActiveTask) error {
run := &TargetRunMetadata{}
activeTask.LoadTaskMetadata(run)

Expand Down Expand Up @@ -231,7 +231,7 @@ func (tr *taskRunner) OnTaskRunning(ctx context.Context, activeTask task.ActiveT
return nil
}

func (tr *taskRunner) OnTaskCompleted(ctx context.Context, activeTask task.ActiveTask, state task.State, args ...any) {
func (tr *taskRunner) OnTaskCompleted(_ context.Context, activeTask task.ActiveTask, state task.State, _ ...any) {
switch state {
case task.StateCompleted:
activeTask.AddLogEntry(zapcore.InfoLevel, "completed")
Expand Down Expand Up @@ -307,13 +307,14 @@ func (runner *taskingTargetRunner) Start(target *remoteread.Target, query *remot
}

func (runner *taskingTargetRunner) Stop(name string) error {
if status, err := runner.controller.TaskStatus(name); err != nil {
status, err := runner.controller.TaskStatus(name)
if err != nil {
return fmt.Errorf("target not found")
} else {
switch status.State {
case corev1.TaskState_Canceled, corev1.TaskState_Completed, corev1.TaskState_Failed:
return fmt.Errorf("target is not running")
}
}

switch status.State {
case corev1.TaskState_Canceled, corev1.TaskState_Completed, corev1.TaskState_Failed:
return fmt.Errorf("target is not running")
}

runner.controller.CancelTask(name)
Expand Down

0 comments on commit 6f1e119

Please sign in to comment.