Skip to content

Commit

Permalink
fix golint failures
Browse files Browse the repository at this point in the history
  • Loading branch information
FayerZhang committed Nov 2, 2019
1 parent dbab85c commit 40fdeed
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pkg/common/operator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (op *ServicesOperator) ReferencesBackendConfig(beConfig *backendconfigv1bet
return Services(s)
}

// ReferencedBackendIngress returns the Services that are referenced by the passed in Ingress.
// ReferencedByIngress returns the Services that are referenced by the passed in Ingress.
func (op *ServicesOperator) ReferencedByIngress(ing *v1beta1.Ingress) *ServicesOperator {
dupes := map[string]bool{}

Expand Down
4 changes: 2 additions & 2 deletions pkg/composite/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/legacy-cloud-providers/gce"
)

// CreateKey() is a helper function for creating a meta.Key when interacting with the
// CreateKey is a helper function for creating a meta.Key when interacting with the
// composite functions. For regional scopes, this function looks up
// the region of the gceCloud object. You should use this wherever possible to avoid
// creating a resource in the wrong region or creating a global resource accidentally.
Expand All @@ -46,7 +46,7 @@ func CreateKey(gceCloud *gce.Cloud, name string, scope meta.KeyType) (*meta.Key,
return nil, fmt.Errorf("invalid resource type: %s", scope)
}

// IsRegionalResource() returns true if the resource URL is regional
// IsRegionalResource returns true if the resource URL is regional
func IsRegionalResource(selfLink string) (bool, error) {
scope, err := ScopeFromSelfLink(selfLink)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func EnsureEchoService(s *Sandbox, name string, annotations map[string]string, s
return svc, nil
}

// Ensures that the Echo deployment with the given description is set up
// EnsureEchoDeployment ensures that the Echo deployment with the given description is set up
func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify func(deployment *apps.Deployment)) error {
podTemplate := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -307,9 +307,8 @@ func trySubnetCreate(s *Sandbox, name, ipCidrRange string) error {
if utils.IsHTTPErrorCode(err, http.StatusConflict) {
klog.V(3).Infof("ILB subnet already exists: %v", err)
return ErrSubnetExists
} else {
return fmt.Errorf("Error creating ILB subnet: %v", err)
}
return fmt.Errorf("Error creating ILB subnet: %v", err)
}

klog.V(3).Infof("ILB Subnet created in region %q: %v", s.f.Region, subnet)
Expand Down
4 changes: 2 additions & 2 deletions pkg/fuzz/default_validator_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func (e *DefaultValidatorEnv) Services() (map[string]*v1.Service, error) {
return ret, nil
}

// DefaultValidatorEnv implements ValidatorEnv.
// Cloud implements ValidatorEnv.
func (e *DefaultValidatorEnv) Cloud() cloud.Cloud {
return e.gce
}

// DefaultValidatorEnv implements ValidatorEnv.
// Namer implements ValidatorEnv.
func (e *DefaultValidatorEnv) Namer() *namer.Namer {
return e.namer
}
3 changes: 1 addition & 2 deletions pkg/fuzz/features/neg.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ func (v *negValidator) CheckResponse(host, path string, resp *http.Response, bod
return fuzz.CheckResponseContinue, verifyNegRegionBackend(v.env, negName, negName, urlMapName, v.region)
}
return fuzz.CheckResponseContinue, verifyNegBackend(v.env, negName, urlMapName)
} else {
return fuzz.CheckResponseContinue, verifyIgBackend(v.env, v.env.Namer().IGBackend(int64(svcPort.NodePort)), urlMapName)
}
return fuzz.CheckResponseContinue, verifyIgBackend(v.env, v.env.Namer().IGBackend(int64(svcPort.NodePort)), urlMapName)
}

// getNegNameForServicePort returns the NEG name for the service port if it exists.
Expand Down
2 changes: 1 addition & 1 deletion pkg/fuzz/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (g *GCLB) CheckResourceDeletion(ctx context.Context, c cloud.Cloud, options
return nil
}

// Check that all NEGs associated with the GCLB have been deleted
// CheckNEGDeletion checks all NEGs associated with the GCLB have been deleted
func (g *GCLB) CheckNEGDeletion(ctx context.Context, c cloud.Cloud, options *GCLBDeleteOptions) error {
var resources []meta.Key

Expand Down
2 changes: 1 addition & 1 deletion pkg/instances/fakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (f *FakeInstanceGroups) ListInstancesInInstanceGroup(name, zone string, sta
return f.listResult.Items, nil
}

// ListInstancesGroups fakes listing instancegroups in a zone
// ListInstanceGroups fakes listing instancegroups in a zone
func (f *FakeInstanceGroups) ListInstanceGroups(zone string) ([]*compute.InstanceGroup, error) {
return f.instanceGroups, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loadbalancers/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func ScopeFromIngress(ing *v1beta1.Ingress) meta.KeyType {
return scopeFromFeatures(featuresFromIngress(ing))
}

// VersionFromIngress returns a ResourceVersions struct containing all of the resources per version
// VersionsFromIngress returns a ResourceVersions struct containing all of the resources per version
func VersionsFromIngress(ing *v1beta1.Ingress) *ResourceVersions {
return versionsFromFeatures(featuresFromIngress(ing))
}
4 changes: 2 additions & 2 deletions pkg/loadbalancers/features/l7ilb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

var ErrSubnetNotFound = errors.New("active subnet not found")

// Get Subnet source range for ILB
// ILBSubnetSourceRange gets Subnet source range for ILB
// TODO: (shance) refactor to use filter
func ILBSubnetSourceRange(cloud *gce.Cloud, region string) (string, error) {
subnets, err := cloud.Compute().BetaSubnetworks().List(context.Background(), region, filter.None)
Expand Down Expand Up @@ -65,7 +65,7 @@ func isSameNetwork(l, r string) (bool, error) {
return lID.Equal(rID), nil
}

// L7ILBVersion is a helper to get the version of L7-ILB
// L7ILBVersions is a helper to get the version of L7-ILB
func L7ILBVersions() *ResourceVersions {
return versionsFromFeatures([]string{FeatureL7ILB})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loadbalancers/l7.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (l *L7) String() string {
return l.namer.LbName()
}

// Version() returns the struct listing the versions for every resource
// Versions returns the struct listing the versions for every resource
func (l *L7) Versions() *features.ResourceVersions {
return features.VersionsFromIngress(&l.ingress)
}
Expand Down
18 changes: 8 additions & 10 deletions pkg/neg/syncers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ func ensureNetworkEndpointGroup(svcNamespace, svcName, negName, zone, negService
err = cloud.DeleteNetworkEndpointGroup(negName, zone)
if err != nil {
return err
} else {
if recorder != nil && serviceLister != nil {
if svc := getService(serviceLister, svcNamespace, svcName); svc != nil {
recorder.Eventf(svc, apiv1.EventTypeNormal, "Delete", "Deleted NEG %q for %s in %q.", negName, negServicePortName, zone)
}
}
if recorder != nil && serviceLister != nil {
if svc := getService(serviceLister, svcNamespace, svcName); svc != nil {
recorder.Eventf(svc, apiv1.EventTypeNormal, "Delete", "Deleted NEG %q for %s in %q.", negName, negServicePortName, zone)
}
}
}
Expand All @@ -158,11 +157,10 @@ func ensureNetworkEndpointGroup(svcNamespace, svcName, negName, zone, negService
}, zone)
if err != nil {
return err
} else {
if recorder != nil && serviceLister != nil {
if svc := getService(serviceLister, svcNamespace, svcName); svc != nil {
recorder.Eventf(svc, apiv1.EventTypeNormal, "Create", "Created NEG %q for %s in %q.", negName, negServicePortName, zone)
}
}
if recorder != nil && serviceLister != nil {
if svc := getService(serviceLister, svcNamespace, svcName); svc != nil {
recorder.Eventf(svc, apiv1.EventTypeNormal, "Create", "Created NEG %q for %s in %q.", negName, negServicePortName, zone)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/namer/namer.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (n *Namer) shortUID() string {
return uid[:8]
}

// GetFirewallName returns the firewall name of this cluster.
// Firewall returns the firewall name of this cluster.
func (n *Namer) Firewall() string {
n.nameLock.Lock()
defer n.nameLock.Unlock()
Expand Down

0 comments on commit 40fdeed

Please sign in to comment.