Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Typos #143

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

//
// kubeconfig provides methods to read and write kuberentes kubectl-config-files.
// kubeconfig provides methods to read and write kubernetes kubectl-config-files.
// It must not depend on the k8s.io-client due to the dependency-hell surrounding it.
// So we tried to be generic and structure agnostic, so that we can read a config,
// modify just the parts we need and write it back and do not loose anything,
Expand Down
2 changes: 1 addition & 1 deletion bus/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
parameters as JSON and invoke the corresponding function with nsq. You can start many services
which implement the same function (identified by its name), so you will have something like a
balancing. Note: As the functions are asynchronuous, you cannot return a result. Only errors
are used to signal if the function was successfull.
are used to signal if the function was successful.

When you create a function with `Unique` the consumer will be connected to a unique, ephemeral
topic and channel. Create unique functions if you want your services to respond with values. You
Expand Down
2 changes: 1 addition & 1 deletion bus/eventbus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestTimeoutWrapper_FailTimeoutWithTimeoutFunc(t *testing.T) {

err := twTimeout.handleWithTimeout(messageFromQueue)
if err != nil {
t.Errorf("no error expected because the onTimeout retuns nil")
t.Errorf("no error expected because the onTimeout returns nil")
}
if !handlerCalled {
t.Errorf("timeoutfunction expected ")
Expand Down
10 changes: 5 additions & 5 deletions bus/functools.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (e *Endpoints) Client(name string) (*Function, Func, error) {
return e.function(name, "function", nil)
}

// Unique uses an unique, ephemeral topic so the topic will be deregisted when there is no
// Unique uses an unique, ephemeral topic so the topic will be deregistered when there is no
// consumer any more for this function. Use this function to create a unique receiver, so function
// invocations will not be distributed and the topic only exists as long as the registration
// process is active. The computed unique name of this function is returned so it can be used with the
Expand Down Expand Up @@ -164,20 +164,20 @@ func (f *Function) receive(par interface{}) error {
pkind = f.fn.Type().In(0).Kind()
}

parms := []reflect.Value{v}
params := []reflect.Value{v}
if vkind != pkind {
if pkind == reflect.Ptr {
// function wants a ptr but we got a value
// --> copy value and pass pointer to this copy
nv := reflect.New(reflect.TypeOf(par))
nv.Elem().Set(v)
parms = []reflect.Value{nv}
params = []reflect.Value{nv}
} else if vkind == reflect.Ptr {
// function wants value
parms = []reflect.Value{v.Elem()}
params = []reflect.Value{v.Elem()}
}
}
res := f.fn.Call(parms)
res := f.fn.Call(params)
if res[0].IsNil() {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions bus/functools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestTwoProcessesFunctionHelloWorld(t *testing.T) {
cmd.Env = append([]string{"PUBLISH=1", "NO_NSQD_START=1"}, os.Environ()...)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("error occured: %s", string(out))
log.Fatalf("error occurred: %s", string(out))
}
}()
var wg sync.WaitGroup
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestUniqueTargetFunctionWithResponse(t *testing.T) {
cmd.Env = append([]string{"PRODUCER=1", "NO_NSQD_START=1"}, os.Environ()...)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("error occured: %s", string(out))
log.Fatalf("error occurred: %s", string(out))
}
}()
var wg sync.WaitGroup
Expand Down
2 changes: 1 addition & 1 deletion bus/testenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ We can now connect to NSQD and create a test topic:
curl -v -X POST --key client_key.pem --cert client_cert.pem --cacert server_cert.pem --resolve metal-control-plane-nsqd:4152:127.0.0.1 https://metal-control-plane-nsqd:4152/topic/create?topic=test
```

Verifiy with
Verify with

```
curl -v --key client_key.pem --cert client_cert.pem --cacert server_cert.pem --resolve metal-control-plane-nsqd:4152:127.0.0.1 https://metal-control-plane-nsqd:4152/stats?format=json&topic=test
Expand Down
5 changes: 3 additions & 2 deletions jwt/sec/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package sec

import (
"errors"
"strings"

"github.com/metal-stack/metal-lib/jwt/grp"
"github.com/metal-stack/security"
"strings"
)

const OidcDirectory = "oidc.metal-stack.io/directory"
Expand Down Expand Up @@ -160,7 +161,7 @@ func (p *Plugin) HasGroupExpression(user *security.User, resourceTenant string,
continue
}

// check if group maches for any of the tenants
// check if group matches for any of the tenants
if resourceTenant == grp.Any {
if groupExpression.Matches(*grpCtx) {
return true
Expand Down
4 changes: 2 additions & 2 deletions pkg/genericcli/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ type CmdsConfig[C any, U any, R any] struct {
// Aliases provides additional aliases for the root cmd.
Aliases []string

// DescribePrinter is the printer that is used for describing the entity. It's a function because printers potentially get intialized later in the game.
// DescribePrinter is the printer that is used for describing the entity. It's a function because printers potentially get initialized later in the game.
DescribePrinter func() printers.Printer
// ListPrinter is the printer that is used for listing multiple entities. It's a function because printers potentially get intialized later in the game.
// ListPrinter is the printer that is used for listing multiple entities. It's a function because printers potentially get initialized later in the game.
ListPrinter func() printers.Printer

// CreateRequestFromCLI if not nil, this function uses the returned create request to create the entity.
Expand Down
2 changes: 1 addition & 1 deletion pkg/genericcli/printers/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type CSVPrinter struct {
type CSVPrinterConfig struct {
// ToHeaderAndRows is called during print to obtain the headers and rows for the given data.
ToHeaderAndRows func(data any) ([]string, [][]string, error)
// NoHeaders will omit headers during pring when set to true
// NoHeaders will omit headers during print when set to true
NoHeaders bool
// Out defines the output writer for the printer, will default to os.stdout
Out io.Writer
Expand Down
2 changes: 1 addition & 1 deletion pkg/genericcli/printers/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type TablePrinterConfig struct {
Wide bool
// Markdown will print the table in Markdown format
Markdown bool
// NoHeaders will omit headers during pring when set to true
// NoHeaders will omit headers during print when set to true
NoHeaders bool
// Out defines the output writer for the printer, will default to os.stdout
Out io.Writer
Expand Down
44 changes: 22 additions & 22 deletions pkg/genericcli/truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ type Truncatable interface {
~string
}

const TruncateElipsis = "..."
const TruncateEllipsis = "..."

// TruncateMiddle will trim a string in the middle.
func TruncateMiddle[T Truncatable](input T, maxlength int) T {
return TruncateMiddleElipsis(input, TruncateElipsis, maxlength)
return TruncateMiddleEllipsis(input, TruncateEllipsis, maxlength)
}

// TruncateMiddleElipsis will trim a string in the middle and replace it with elipsis.
func TruncateMiddleElipsis[T Truncatable](input T, elipsis T, maxlength int) T {
if elipsis == "" {
elipsis = TruncateElipsis
// TruncateMiddleEllipsis will trim a string in the middle and replace it with ellipsis.
func TruncateMiddleEllipsis[T Truncatable](input T, ellipsis T, maxlength int) T {
if ellipsis == "" {
ellipsis = TruncateEllipsis
}
if maxlength < 0 || len(input) <= maxlength {
return input
}

finalLength := float64(maxlength - len(elipsis))
finalLength := float64(maxlength - len(ellipsis))
if finalLength <= 0 {
return input[:maxlength]
}
Expand All @@ -31,49 +31,49 @@ func TruncateMiddleElipsis[T Truncatable](input T, elipsis T, maxlength int) T {
start = int(math.Ceil(finalLength / 2))
end = int(math.Floor(finalLength / 2))
)
return input[:start] + elipsis + input[len(input)-end:]
return input[:start] + ellipsis + input[len(input)-end:]
}

// TruncateEnd will trim a string at the end.
func TruncateEnd[T Truncatable](input T, maxlength int) T {
return TruncateEndElipsis(input, TruncateElipsis, maxlength)
return TruncateEndEllipsis(input, TruncateEllipsis, maxlength)
}

// TruncateEndElipsis will trim a string at the end and replace it with elipsis.
func TruncateEndElipsis[T Truncatable](input T, elipsis T, maxlength int) T {
if elipsis == "" {
elipsis = TruncateElipsis
// TruncateEndEllipsis will trim a string at the end and replace it with ellipsis.
func TruncateEndEllipsis[T Truncatable](input T, ellipsis T, maxlength int) T {
if ellipsis == "" {
ellipsis = TruncateEllipsis
}
if maxlength < 0 || len(input) <= maxlength {
return input
}

finalLength := maxlength - len(elipsis)
finalLength := maxlength - len(ellipsis)
if finalLength <= 0 {
return input[:maxlength]
}

return input[:finalLength] + elipsis
return input[:finalLength] + ellipsis
}

// TruncateStart will trim a string at the start.
func TruncateStart[T Truncatable](input T, maxlength int) T {
return TruncateStartElipsis(input, TruncateElipsis, maxlength)
return TruncateStartEllipsis(input, TruncateEllipsis, maxlength)
}

// TruncateStartElipsis will trim a string at the start and replace it with elipsis.
func TruncateStartElipsis[T Truncatable](input T, elipsis T, maxlength int) T {
if elipsis == "" {
elipsis = TruncateElipsis
// TruncateStartEllipsis will trim a string at the start and replace it with ellipsis.
func TruncateStartEllipsis[T Truncatable](input T, ellipsis T, maxlength int) T {
if ellipsis == "" {
ellipsis = TruncateEllipsis
}
if maxlength < 0 || len(input) <= maxlength {
return input
}

finalLength := maxlength - len(elipsis)
finalLength := maxlength - len(ellipsis)
if finalLength <= 0 {
return input[len(input)-maxlength:]
}

return elipsis + input[len(input)-finalLength:]
return ellipsis + input[len(input)-finalLength:]
}
Loading
Loading