Skip to content

Commit

Permalink
fixed go linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
astelmashenko committed Jul 26, 2024
1 parent cc51393 commit 4992797
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
9 changes: 5 additions & 4 deletions pkg/channel/jetstream/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"time"

"k8s.io/utils/ptr"

"knative.dev/pkg/configmap"
"knative.dev/pkg/reconciler"

Expand All @@ -32,8 +34,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/pointer"

kubeclient "knative.dev/pkg/client/injection/kube/client"
deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment"
endpointsinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/endpoints"
Expand Down Expand Up @@ -146,9 +146,9 @@ func getControllerOwnerRef(ctx context.Context) (*metav1.OwnerReference, error)
ownerRef := metav1.OwnerReference{
APIVersion: "rbac.authorization.k8s.io/v1",
Kind: "ClusterRole",
Controller: pointer.BoolPtr(true),
Controller: ptr.To(true),

Check warning on line 149 in pkg/channel/jetstream/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/channel/jetstream/controller/controller.go#L149

Added line #L149 was not covered by tests
}
err := wait.PollImmediate(interval, timeout, func() (bool, error) {
err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (done bool, err error) {

Check warning on line 151 in pkg/channel/jetstream/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/channel/jetstream/controller/controller.go#L151

Added line #L151 was not covered by tests
k8sClient := kubeclient.Get(ctx)
clusterRole, err := k8sClient.RbacV1().ClusterRoles().Get(ctx, jetstream.ControllerName, metav1.GetOptions{})
if err != nil {
Expand All @@ -158,6 +158,7 @@ func getControllerOwnerRef(ctx context.Context) (*metav1.OwnerReference, error)
ownerRef.UID = clusterRole.UID
return true, nil
})

if err != nil {
return nil, err
}
Expand Down
10 changes: 3 additions & 7 deletions pkg/channel/jetstream/controller/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"context"
"fmt"

"knative.dev/pkg/ptr"

"github.com/google/go-cmp/cmp"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/utils/pointer"
"knative.dev/eventing/pkg/apis/eventing"
"knative.dev/pkg/apis"
"knative.dev/pkg/controller"
Expand Down Expand Up @@ -64,13 +65,8 @@ const (
dispatcherServiceCreated = "DispatcherServiceCreated"
dispatcherServiceFailed = "DispatcherServiceFailed"
dispatcherServiceUpdated = "DispatcherServiceUpdated"
natsJetStreamChannelReconciled = "NatsJetStreamChannelReconciled"
)

func newReconciledNormal(namespace, name string) reconciler.Event {
return reconciler.NewEvent(corev1.EventTypeNormal, natsJetStreamChannelReconciled, "NatsJetStreamChannel reconciled: \"%s/%s\"", namespace, name)
}

func newDeploymentWarn(err error) reconciler.Event {
return reconciler.NewEvent(corev1.EventTypeWarning, dispatcherDeploymentFailed, "Reconciling dispatcher Deployment failed with: %s", err)
}
Expand Down Expand Up @@ -500,7 +496,7 @@ func (r *Reconciler) cleanDispatcherResources(ctx context.Context, namespace str
}

toUpdate := deployment.DeepCopy()
toUpdate.Spec.Replicas = pointer.Int32(0)
toUpdate.Spec.Replicas = ptr.Int32(0)

Check warning on line 499 in pkg/channel/jetstream/controller/reconciler.go

View check run for this annotation

Codecov / codecov/patch

pkg/channel/jetstream/controller/reconciler.go#L499

Added line #L499 was not covered by tests

_, err = r.kubeClientSet.AppsV1().Deployments(namespace).Update(ctx, toUpdate, metav1.UpdateOptions{})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/channel/jetstream/dispatcher/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
logger.Panicf("unable to process required environment variables: %v", err)
}

err := tracing.SetupDynamicPublishing(logger, cmw, "jetstream-ch-dispatcher", "config-tracing")
_, err := tracing.SetupPublishingWithDynamicConfig(logger, cmw, "jetstream-ch-dispatcher", "config-tracing")

Check warning on line 59 in pkg/channel/jetstream/dispatcher/controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/channel/jetstream/dispatcher/controller.go#L59

Added line #L59 was not covered by tests
if err != nil {
logger.Fatalw("failed to setup tracing", zap.Error(err))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/error/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (e *SubscriberErrors) AddError(uid string, err error) {
}

func (e SubscriberErrors) Error() string {
if e == nil || len(e) == 0 {
if len(e) == 0 {

Check warning on line 36 in pkg/common/error/subscriber.go

View check run for this annotation

Codecov / codecov/patch

pkg/common/error/subscriber.go#L36

Added line #L36 was not covered by tests
return ""
}

Expand Down

0 comments on commit 4992797

Please sign in to comment.