Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpollet committed Nov 14, 2020
1 parent 76f674f commit ee9d994
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pkg/controller/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *ShadowServiceManager) LoadPortMapping() error {
for _, shadowSvc := range shadowSvcs {
// If the traffic-type annotation has been manually removed we can't load its ports.
trafficType, err := annotations.GetTrafficType(shadowSvc.Annotations)
if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
s.logger.Errorf("Unable to find traffic-type on shadow service %q", shadowSvc.Name)
continue
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func (s *ShadowServiceManager) deleteShadowService(ctx context.Context, namespac
s.logger.Debugf("Deleting shadow service %q...", shadowSvcName)

trafficType, err := annotations.GetTrafficType(shadowSvc.Annotations)
if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
s.logger.Errorf("Unable to find traffic-type of the shadow service for service %q in namespace %q", name, namespace)
return nil
}
Expand All @@ -128,12 +128,12 @@ func (s *ShadowServiceManager) deleteShadowService(ctx context.Context, namespac
// upsertShadowService updates or create the shadow service associated with the given user service.
func (s *ShadowServiceManager) upsertShadowService(ctx context.Context, svc *corev1.Service, shadowSvcName string) error {
trafficType, err := annotations.GetTrafficType(svc.Annotations)
if err != nil && err != annotations.ErrNotFound {
if err != nil && !errors.Is(err, annotations.ErrNotFound) {
s.logger.Errorf("Unable to create or update shadow services for service %q in namespace %q: %v", svc.Name, svc.Namespace, err)
return nil
}

if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
trafficType = s.defaultTrafficType
}

Expand Down Expand Up @@ -233,7 +233,7 @@ func (s *ShadowServiceManager) getServicePorts(svc *corev1.Service, trafficType
// cleanupShadowServicePorts unmap ports that have changed since the last update of the service.
func (s *ShadowServiceManager) cleanupShadowServicePorts(svc, shadowSvc *corev1.Service, trafficType string) {
oldTrafficType, err := annotations.GetTrafficType(shadowSvc.Annotations)
if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
s.logger.Errorf("Unable find traffic-type for shadow service %q", shadowSvc.Name)
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func newFakeShadowService(t *testing.T, svc *corev1.Service, ports map[int]int)
require.NoError(t, err)

trafficType, err := annotations.GetTrafficType(svc.Annotations)
if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
trafficType = testDefaultTrafficType
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ func (p *Provider) BuildConfig(t *topology.Topology) *dynamic.Configuration {
// buildConfigForService builds the dynamic configuration for the given service.
func (p *Provider) buildConfigForService(t *topology.Topology, cfg *dynamic.Configuration, svc *topology.Service) error {
trafficType, err := annotations.GetTrafficType(svc.Annotations)
if err != nil && err != annotations.ErrNotFound {
if err != nil && !errors.Is(err, annotations.ErrNotFound) {
return fmt.Errorf("unable to evaluate traffic-type annotation: %w", err)
}

if err == annotations.ErrNotFound {
if errors.Is(err, annotations.ErrNotFound) {
trafficType = p.config.DefaultTrafficType
}

Expand Down

0 comments on commit ee9d994

Please sign in to comment.