Skip to content

Commit

Permalink
style: Fixed Misspells (#223)
Browse files Browse the repository at this point in the history
Fixed the various misspells which were present in the code pointed out by Go Report Card
Fixes #198

Signed-off-by: Kartik-Garg <kartik.garg@infracloud.io>
  • Loading branch information
Kartik-Garg committed May 26, 2023
1 parent c4a7ebe commit 59674a2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (a *applier) Apply(ctx context.Context, obj ctrlclient.Object, opts ...Opti
f(applyOpts)
}

// added to preserve backward compatability with other code
// added to preserve backward compatibility with other code
if !applyOpts.UseUpdate {
applyOpts.UseUpdate = isApplyUpdate(obj)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/util/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func isKnowMergePatchGroup(gvk schema.GroupVersionKind) bool {
return false
}

// IsStrategicMergePatch returns true if gvk is present in the registerd scheme
// IsStrategicMergePatch returns true if gvk is present in the registered scheme
func IsStrategicMergePatch(gvk schema.GroupVersionKind) bool {
return scheme.Scheme.Recognizes(gvk) && !isKnowMergePatchGroup(gvk)
}
Expand Down Expand Up @@ -59,7 +59,7 @@ func CreateStrategicMergePatch(gvk schema.GroupVersionKind, original, current, m
return ret, err
}

// ApplyStrategicMergePatch applies strategic merge patch on orginal
// ApplyStrategicMergePatch applies strategic merge patch on original
func ApplyStrategicMergePatch(gvk schema.GroupVersionKind, original, patch []byte) ([]byte, error) {
obj, err := scheme.Scheme.New(gvk)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gateway/httpbody.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewHTTPBodyMarshaler() runtime.Marshaler {
}
}

// ContentType implementation to keep backwards compatability with marshal interface
// ContentType implementation to keep backwards compatibility with marshal interface
func (h *httpBodyMarshaler) ContentType(v interface{}) string {
return h.ContentTypeFromMessage(nil)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/sentry/authz/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func GetAuthorization(ctx context.Context, req *sentryrpc.GetUserAuthorizationRe
return nil, err
}

rp := sentry.GetKubeConfigPermissionPrivilage(permission)
rp := sentry.GetKubeConfigPermissionPrivilege(permission)
if rp > rolePrevilage {
rolePrevilage = rp
highestRole = permission
Expand All @@ -574,7 +574,7 @@ func GetAuthorization(ctx context.Context, req *sentryrpc.GetUserAuthorizationRe
}
for _, permission := range permissions {

rp := sentry.GetKubeConfigPermissionPrivilage(permission)
rp := sentry.GetKubeConfigPermissionPrivilege(permission)
if rp > rolePrevilage {
rolePrevilage = rp
highestRole = permission
Expand Down Expand Up @@ -787,7 +787,7 @@ func verifyClusterKubectlSettings(ctx context.Context, bs service.BootstrapServi
}

if cnAttr.SessionType == "" || cnAttr.SessionType == kubeconfig.TerminalShell {
// backward combatibility treat "" as terminal session for old kubeconfigs
// backward compatibility treat "" as terminal session for old kubeconfigs
if kc.DisableCLIKubectl {
_log.Infow("kubectl cli is not authorized for ", "cnAttr", cnAttr)
return fmt.Errorf("kubectl cli is not authorized") //deny
Expand Down Expand Up @@ -815,7 +815,7 @@ func verifyKubectlSettings(cnAttr kubeconfig.CNAttributes, ks *sentry.Kubeconfig
}

if cnAttr.SessionType == "" || cnAttr.SessionType == kubeconfig.TerminalShell {
// backward combatibility treat "" as terminal session for old kubeconfigs
// backward compatibility treat "" as terminal session for old kubeconfigs
if ks.DisableCLIKubectl {
_log.Infow("kubectl cli is not authorized for ", "cnAttr", cnAttr, " by ", level, "config")
return fmt.Errorf("kubectl cli is not authorized" + " by " + level + "config") //deny
Expand Down
2 changes: 1 addition & 1 deletion pkg/sentry/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func GetConfigForUser(ctx context.Context, bs service.BootstrapService, aps serv
org, err := os.GetByName(ctx, opts.Organization)
if err != nil {
_log.Errorw("error getting organization data", "error", err.Error())
return nil, fmt.Errorf("failed to retrieve organziation %s", err.Error())
return nil, fmt.Errorf("failed to retrieve organization %s", err.Error())
}
oid = uuid.MustParse(org.Metadata.Id)
opts.Organization = oid.String()
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/metro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestMetroDeleteNonExist(t *testing.T) {
}
_, err := ps.Delete(context.Background(), metro)
if err == nil {
t.Fatal("deleted non existant metro")
t.Fatal("deleted non existent metro")
}
}

Expand Down
4 changes: 2 additions & 2 deletions proto/types/sentry/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func GetKubeConfigPermissionIsRead(permission string) bool {
return false
}

// GetKubeConfigPermissionPrivilage privilage order
func GetKubeConfigPermissionPrivilage(permission string) int {
// GetKubeConfigPermissionprivilege privilege order
func GetKubeConfigPermissionPrivilege(permission string) int {
switch permission {
case KubeconfigReadPermission:
return 0
Expand Down
26 changes: 13 additions & 13 deletions server/relaypeerservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
// - Each relay object has a survey send chnl. Use this chnl to send survey requests.
// - Each relay obect has a probe chnl. Use this chnl to send probe response

//used for survey broadcasting
// used for survey broadcasting
type surveyBroadCastRequest struct {
clustersni string
relayuuid string // relay requsting the survey
ou string
}

//used to maintain list of connected relays
// used to maintain list of connected relays
type relayObject struct {
timeStamp int64
refCnt uint8
Expand All @@ -42,7 +42,7 @@ type relayObject struct {
surveyRequestChnl chan sentryrpc.PeerSurveyRequest
}

//relayPeerService relay peer service
// relayPeerService relay peer service
type relayPeerService struct {
cert []byte // rpc server certifciate
key []byte // rpc server key
Expand Down Expand Up @@ -138,7 +138,7 @@ func RunRelaySurveyHandler(stop <-chan struct{}, svc interface{}) {
}
}

//process the survey request.
// process the survey request.
func (s *relayPeerService) handleSurveyReq(req surveyBroadCastRequest) {
// Get All relay objects
// Send survey request to all.
Expand Down Expand Up @@ -253,7 +253,7 @@ func (s *relayPeerService) handleSurveyReq(req surveyBroadCastRequest) {

}

//maintains the timestamp of relays heart beat
// maintains the timestamp of relays heart beat
func (s *relayPeerService) updateRelayIfExist(relayuuid, ou string) bool {
s.relayMutex.RLock()
defer s.relayMutex.RUnlock()
Expand Down Expand Up @@ -332,7 +332,7 @@ func (s *relayPeerService) handleHelloRequest(relayuuid, relayip, ou string) {
s.insertRelayObject(robj, relayuuid, ou)
}

//getServiceIP ..
// getServiceIP ..
func getServiceIP() string {
name, err := os.Hostname()
if err == nil {
Expand All @@ -344,7 +344,7 @@ func getServiceIP() string {
return ""
}

//RelayPeerHelloRPC handles PeerHelloMsg
// RelayPeerHelloRPC handles PeerHelloMsg
func (s *relayPeerService) RelayPeerHelloRPC(stream sentryrpc.RelayPeerService_RelayPeerHelloRPCServer) error {
_log.Infow("RelayPeerHelloRPC stream")
name, err := grpc.GetClientName(stream.Context())
Expand Down Expand Up @@ -382,7 +382,7 @@ func (s *relayPeerService) RelayPeerHelloRPC(stream sentryrpc.RelayPeerService_R
}
}

//relayPeerProbeSender send routine to handle sending probe messges
// relayPeerProbeSender send routine to handle sending probe messges
func (s *relayPeerService) relayPeerProbeSender(ctx context.Context, stream sentryrpc.RelayPeerService_RelayPeerProbeRPCServer, relayuuid string, robj *relayObject) {
for {
select {
Expand All @@ -399,7 +399,7 @@ func (s *relayPeerService) relayPeerProbeSender(ctx context.Context, stream sent
}
}

//try to fill the response form cache
// try to fill the response form cache
func (s *relayPeerService) tryResponseFromCache(relayuuid, clustersni, ou string) bool {
var relayids []string
var connInfo []*sentryrpc.RelayClusterConnectionInfo
Expand Down Expand Up @@ -445,7 +445,7 @@ func (s *relayPeerService) tryResponseFromCache(relayuuid, clustersni, ou string
return false
}

//RelayPeerProbeRPC handles PeerHelloMsg
// RelayPeerProbeRPC handles PeerHelloMsg
func (s *relayPeerService) RelayPeerProbeRPC(stream sentryrpc.RelayPeerService_RelayPeerProbeRPCServer) error {
var initSend bool

Expand Down Expand Up @@ -495,7 +495,7 @@ func (s *relayPeerService) RelayPeerProbeRPC(stream sentryrpc.RelayPeerService_R
continue
}

// find respone either from cache or via survey
// find response either from cache or via survey
go func() {
if clustersni != "" && relayuuid != "" {
if !s.tryResponseFromCache(relayuuid, clustersni, ou) {
Expand All @@ -514,7 +514,7 @@ func (s *relayPeerService) RelayPeerProbeRPC(stream sentryrpc.RelayPeerService_R

}

//relayPeerSurveySender send routine to handle sending probe messges
// relayPeerSurveySender send routine to handle sending probe messges
func (s *relayPeerService) relayPeerSurveySender(ctx context.Context, stream sentryrpc.RelayPeerService_RelayPeerSurveyRPCServer, relayuuid string, robj *relayObject) {
_log.Debugw("started relayPeerSurveySender")
for {
Expand All @@ -533,7 +533,7 @@ func (s *relayPeerService) relayPeerSurveySender(ctx context.Context, stream sen
}
}

//RelayPeerSurveyRPC handles relay survey rpc
// RelayPeerSurveyRPC handles relay survey rpc
func (s *relayPeerService) RelayPeerSurveyRPC(stream sentryrpc.RelayPeerService_RelayPeerSurveyRPCServer) error {
var initSend bool

Expand Down

0 comments on commit 59674a2

Please sign in to comment.