Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Fix linter issues and clean up unused param
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <jstur@microsoft.com>
  • Loading branch information
jsturtevant committed Aug 5, 2022
1 parent 8181675 commit 228078c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/osm-bootstrap/osm-bootstrap.go
Expand Up @@ -242,7 +242,7 @@ func main() {
}

// Initialize the crd conversion webhook server to support the conversion of OSM's CRDs
if err := crdconversion.NewConversionWebhook(ctx, kubeClient, crdClient, certManager, osmNamespace, enableReconciler); err != nil {
if err := crdconversion.NewConversionWebhook(ctx, crdClient, certManager, osmNamespace, enableReconciler); err != nil {
events.GenericEventRecorder().FatalEvent(err, events.InitializationError, "Error creating crd conversion webhook")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/environment.go
Expand Up @@ -8,15 +8,15 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2020 The OSM contributors
Copyright 2020 The OSM contributors.
Licensed under the MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
3 changes: 1 addition & 2 deletions pkg/crdconversion/crdconversion.go
Expand Up @@ -7,7 +7,6 @@ import (
apiv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/pointer"

"github.com/openservicemesh/osm/pkg/certificate"
Expand Down Expand Up @@ -38,7 +37,7 @@ var apiKindToPath = map[string]string{
var conversionReviewVersions = []string{"v1beta1", "v1"}

// NewConversionWebhook starts a new web server handling requests from the CRD's
func NewConversionWebhook(ctx context.Context, kubeClient kubernetes.Interface, crdClient apiclient.ApiextensionsV1Interface, certManager *certificate.Manager, osmNamespace string, enableReconciler bool) error {
func NewConversionWebhook(ctx context.Context, crdClient apiclient.ApiextensionsV1Interface, certManager *certificate.Manager, osmNamespace string, enableReconciler bool) error {
srv, err := webhook.NewServer(constants.OSMBootstrapName, osmNamespace, constants.CRDConversionWebhookPort, certManager, map[string]http.HandlerFunc{
meshConfigConverterPath: serveMeshConfigConversion,
trafficAccessConverterPath: serveTrafficAccessConversion,
Expand Down
4 changes: 1 addition & 3 deletions pkg/crdconversion/crdconversion_test.go
Expand Up @@ -10,7 +10,6 @@ import (
apiv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8sfake "k8s.io/client-go/kubernetes/fake"

"github.com/openservicemesh/osm/pkg/certificate"
"github.com/openservicemesh/osm/pkg/certificate/pem"
Expand Down Expand Up @@ -96,14 +95,13 @@ func TestUpdateCrdConfiguration(t *testing.T) {
func TestNewConversionWebhook(t *testing.T) {
assert := tassert.New(t)
crdClient := fake.NewSimpleClientset()
kubeClient := k8sfake.NewSimpleClientset()
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()

fakeCertManager := tresorFake.NewFake(1 * time.Hour)
osmNamespace := "-osm-namespace-"
enablesReconciler := false

actualErr := NewConversionWebhook(context.Background(), kubeClient, crdClient.ApiextensionsV1(), fakeCertManager, osmNamespace, enablesReconciler)
actualErr := NewConversionWebhook(context.Background(), crdClient.ApiextensionsV1(), fakeCertManager, osmNamespace, enablesReconciler)
assert.NotNil(actualErr)
}
2 changes: 1 addition & 1 deletion pkg/envoy/rds/route/route_config.go
Expand Up @@ -247,7 +247,7 @@ func BuildEgressRouteConfiguration(portSpecificRouteConfigs map[int][]*trafficpo
return routeConfigs
}

//NewRouteConfigurationStub creates the route configuration placeholder
// NewRouteConfigurationStub creates the route configuration placeholder
func NewRouteConfigurationStub(routeConfigName string) *xds_route.RouteConfiguration {
routeConfiguration := xds_route.RouteConfiguration{
Name: routeConfigName,
Expand Down
6 changes: 3 additions & 3 deletions pkg/tests/stream.go
Expand Up @@ -53,9 +53,9 @@ func (s *XDSServer) Recv() (*xds_discovery.DiscoveryRequest, error) {
// SetHeader sets the header metadata. It may be called multiple times.
// When call multiple times, all the provided metadata will be merged.
// All the metadata will be sent out when one of the following happens:
// - ServerStream.SendHeader() is called;
// - The first response is sent out;
// - An RPC status is sent out (error or success).
// - ServerStream.SendHeader() is called;
// - The first response is sent out;
// - An RPC status is sent out (error or success).
func (s *XDSServer) SetHeader(metadata.MD) error {
return nil
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/trafficpolicy/trafficpolicy.go
Expand Up @@ -83,9 +83,10 @@ func (rwc *RouteWeightedClusters) TotalClustersWeight() int {
return totalWeight
}

// AddRoute adds a route to an OutboundTrafficPolicy given an HTTP route match and weighted cluster. If a Route with the given HTTP route match
// already exists, an error will be returned. If a Route with the given HTTP route match does not exist,
// a Route with the given HTTP route match and weighted clusters will be added to the Routes on the OutboundTrafficPolicy
// AddRoute adds a route to an OutboundTrafficPolicy given an HTTP route match and weighted cluster.
// If a Route with the given HTTP route match already exists, an error will be returned.
// If a Route with the given HTTP route match does not exist,
// a Route with the given HTTP route match and weighted clusters will be added to the Routes on the OutboundTrafficPolicy
func (out *OutboundTrafficPolicy) AddRoute(httpRouteMatch HTTPRouteMatch, retryPolicy *policyv1alpha1.RetryPolicySpec, weightedClusters ...service.WeightedCluster) error {
wc := mapset.NewSet()
for _, c := range weightedClusters {
Expand Down Expand Up @@ -137,7 +138,7 @@ func MergeInboundPolicies(original []*InboundTrafficPolicy, latest ...*InboundTr
}

// MergeRules merges the give slices of rules such that there is one Rule for a Route with all allowed service accounts listed in the
// returned slice of rules
// returned slice of rules
func MergeRules(originalRules, latestRules []*Rule) []*Rule {
for _, latest := range latestRules {
foundRoute := false
Expand All @@ -156,8 +157,8 @@ func MergeRules(originalRules, latestRules []*Rule) []*Rule {
}

// mergeRoutesWeightedClusters merges two slices of RouteWeightedClusters and returns a slice where there is one RouteWeightedCluster
// for any HTTPRouteMatch. Where there is an overlap in HTTPRouteMatch between the originalRoutes and latestRoutes, the WeightedClusters
// will be unioned as there can only be one set of WeightedClusters per HTTPRouteMatch.
// for any HTTPRouteMatch. Where there is an overlap in HTTPRouteMatch between the originalRoutes and latestRoutes, the WeightedClusters
// will be unioned as there can only be one set of WeightedClusters per HTTPRouteMatch.
func mergeRoutesWeightedClusters(originalRoutes, latestRoutes []*RouteWeightedClusters) []*RouteWeightedClusters {
for _, latest := range latestRoutes {
foundRoute := false
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/common_apps.go
Expand Up @@ -851,7 +851,7 @@ func (td *OsmTestData) InstallNginxIngress() (string, error) {
}

// RandomNameWithPrefix generates a random string with the given prefix.
// If the prefix is empty, the default prefix "test" will be used
// If the prefix is empty, the default prefix "test" will be used
func RandomNameWithPrefix(prefix string) string {
if prefix == "" || len(prefix) > 100 {
prefix = "test"
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/types.go
Expand Up @@ -140,7 +140,7 @@ type InstallOsmOpt func(*InstallOSMOpts)
// CleanupType identifies what triggered the cleanup
type CleanupType string

//DockerConfig and other configs are docker-specific container registry secret structures.
// DockerConfig and other configs are docker-specific container registry secret structures.
// Most of it is taken or referenced from kubectl source itself
type DockerConfig map[string]DockerConfigEntry

Expand Down

0 comments on commit 228078c

Please sign in to comment.