Skip to content

Commit

Permalink
Add codespell job (netbirdio#1281)
Browse files Browse the repository at this point in the history
add codespell workflow and fixed spelling issues
  • Loading branch information
mlsmaycon authored Nov 7, 2023
1 parent a935975 commit c5c6883
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ concurrency:
cancel-in-progress: true

jobs:
codespell:
name: codespell
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: codespell
uses: codespell-project/actions-codespell@v2
with:
ignore_words_list: erro,clienta
skip: go.mod,go.sum
only_warn: 1
golangci:
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion client/internal/acl/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func TestDefaultManagerSquashRulesNoAffect(t *testing.T) {

manager := &DefaultManager{}
if rules, _ := manager.squashAcceptRules(networkMap); len(rules) != len(networkMap.FirewallRules) {
t.Errorf("we should got same amount of rules as intput, got %v", len(rules))
t.Errorf("we should get the same amount of rules as output, got %v", len(rules))
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/internal/dns/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func TestDNSFakeResolverHandleUpdates(t *testing.T) {

err = wgIface.Create()
if err != nil {
t.Errorf("crate and init wireguard interface: %v", err)
t.Errorf("create and init wireguard interface: %v", err)
return
}
defer func() {
Expand Down Expand Up @@ -789,7 +789,7 @@ func createWgInterfaceWithBind(t *testing.T) (*iface.WGIface, error) {

err = wgIface.Create()
if err != nil {
t.Fatalf("crate and init wireguard interface: %v", err)
t.Fatalf("create and init wireguard interface: %v", err)
return nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions client/internal/ebpf/ebpf/manager_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ func TestManager_setFeatureFlag(t *testing.T) {
mgr := GeneralManager{}
mgr.setFeatureFlag(featureFlagWGProxy)
if mgr.featureFlags != 1 {
t.Errorf("invalid faeture state")
t.Errorf("invalid feature state")
}

mgr.setFeatureFlag(featureFlagDnsForwarder)
if mgr.featureFlags != 3 {
t.Errorf("invalid faeture state")
t.Errorf("invalid feature state")
}
}

Expand All @@ -27,14 +27,14 @@ func TestManager_unsetFeatureFlag(t *testing.T) {
t.Errorf("unexpected error: %s", err)
}
if mgr.featureFlags != 2 {
t.Errorf("invalid faeture state, expected: %d, got: %d", 2, mgr.featureFlags)
t.Errorf("invalid feature state, expected: %d, got: %d", 2, mgr.featureFlags)
}

err = mgr.unsetFeatureFlag(featureFlagDnsForwarder)
if err != nil {
t.Errorf("unexpected error: %s", err)
}
if mgr.featureFlags != 0 {
t.Errorf("invalid faeture state, expected: %d, got: %d", 0, mgr.featureFlags)
t.Errorf("invalid feature state, expected: %d, got: %d", 0, mgr.featureFlags)
}
}
4 changes: 2 additions & 2 deletions client/internal/peer/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (conn *Conn) Open() error {
}
err := conn.statusRecorder.UpdatePeerState(peerState)
if err != nil {
log.Warnf("erro while updating the state of peer %s,err: %v", conn.config.Key, err)
log.Warnf("error while updating the state of peer %s,err: %v", conn.config.Key, err)
}

defer func() {
Expand Down Expand Up @@ -301,7 +301,7 @@ func (conn *Conn) Open() error {
}
err = conn.statusRecorder.UpdatePeerState(peerState)
if err != nil {
log.Warnf("erro while updating the state of peer %s,err: %v", conn.config.Key, err)
log.Warnf("error while updating the state of peer %s,err: %v", conn.config.Key, err)
}

err = conn.agent.GatherCandidates()
Expand Down
5 changes: 3 additions & 2 deletions client/ssh/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"strings"

"golang.org/x/crypto/ed25519"
gossh "golang.org/x/crypto/ssh"
"strings"
)

// KeyType is a type of SSH key
Expand Down Expand Up @@ -42,7 +43,7 @@ func GeneratePrivateKey(keyType KeyType) ([]byte, error) {
case RSA:
key, err = rsa.GenerateKey(rand.Reader, RSAKeySize)
default:
return nil, fmt.Errorf("unsupported ket type %s", keyType)
return nil, fmt.Errorf("unsupported key type %s", keyType)
}
if err != nil {
return nil, err
Expand Down
7 changes: 4 additions & 3 deletions dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ package dns

import (
"fmt"
"github.com/miekg/dns"
"golang.org/x/net/idna"
"net"
"regexp"
"strings"

"github.com/miekg/dns"
"golang.org/x/net/idna"
)

const (
Expand Down Expand Up @@ -95,7 +96,7 @@ func GetParsedDomainLabel(name string) (string, error) {
rawLabel := labels[0]
ascii, err := idna.Punycode.ToASCII(rawLabel)
if err != nil {
return "", fmt.Errorf("unable to convert host lavel to ASCII, error: %v", err)
return "", fmt.Errorf("unable to convert host label to ASCII, error: %v", err)
}

invalidHostMatcher := regexp.MustCompile(invalidHostLabel)
Expand Down
2 changes: 1 addition & 1 deletion iface/tun_adapter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package iface

// TunAdapter is an interface for create tun device from externel service
// TunAdapter is an interface for create tun device from external service
type TunAdapter interface {
ConfigureInterface(address string, mtu int, dns string, searchDomains string, routes string) (int, error)
UpdateAddr(address string) error
Expand Down
2 changes: 1 addition & 1 deletion infrastructure_files/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi

if [[ "x-$NETBIRD_DOMAIN" == "x-" ]]; then
echo NETBIRD_DOMAIN is not set, please update your setup.env file
echo If you are migrating from old versions, you migh need to update your variables prefixes from
echo If you are migrating from old versions, you might need to update your variables prefixes from
echo WIRETRUSTEE_.. TO NETBIRD_
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion infrastructure_files/getting-started-with-zitadel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ check_nb_domain() {

if [ "$DOMAIN" == "netbird.example.com" ]; then
echo "The NETBIRD_DOMAIN cannot be netbird.example.com" > /dev/stderr
retrun 1
return 1
fi
return 0
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure_files/turnserver.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ no-cli
#
#cli-password=$5$79a316b350311570$81df9cfb9af7f5e5a76eada31e7097b663a0670f99a3c07ded3f1c8e59c5658a
#
# Or unsecure form for the same password:
# Or insecure form for the same password:
#
# cli-password=CHANGE_ME

Expand Down
6 changes: 3 additions & 3 deletions management/server/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestAccountManager_GetOrCreateAccountByUser(t *testing.T) {
}

if account != nil && account.Users[userID] == nil {
t.Fatalf("expected to create an account for a user %s but no user was found after creation udner the account %s", userID, account.Id)
t.Fatalf("expected to create an account for a user %s but no user was found after creation under the account %s", userID, account.Id)
return
}

Expand Down Expand Up @@ -626,7 +626,7 @@ func TestAccountManager_PrivateAccount(t *testing.T) {
}

if account != nil && account.Users[userId] == nil {
t.Fatalf("expected to create an account for a user %s but no user was found after creation udner the account %s", userId, account.Id)
t.Fatalf("expected to create an account for a user %s but no user was found after creation under the account %s", userId, account.Id)
}
}

Expand Down Expand Up @@ -1385,7 +1385,7 @@ func TestAccount_Copy(t *testing.T) {
if err != nil {
t.Fatal(err)
}
account.Peers["peer1"].Status.Connected = false // we change original object to confirm that copy wont change
account.Peers["peer1"].Status.Connected = false // we change original object to confirm that copy won't change
accCopyBytes, err := json.Marshal(accountCopy)
if err != nil {
t.Fatal(err)
Expand Down
10 changes: 5 additions & 5 deletions management/server/jwtclaims/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ import (
"github.com/stretchr/testify/require"
)

func newTestRequestWithJWT(t *testing.T, claims AuthorizationClaims, audiance string) *http.Request {
func newTestRequestWithJWT(t *testing.T, claims AuthorizationClaims, audience string) *http.Request {
const layout = "2006-01-02T15:04:05.999Z"

claimMaps := jwt.MapClaims{}
if claims.UserId != "" {
claimMaps[UserIDClaim] = claims.UserId
}
if claims.AccountId != "" {
claimMaps[audiance+AccountIDSuffix] = claims.AccountId
claimMaps[audience+AccountIDSuffix] = claims.AccountId
}
if claims.Domain != "" {
claimMaps[audiance+DomainIDSuffix] = claims.Domain
claimMaps[audience+DomainIDSuffix] = claims.Domain
}
if claims.DomainCategory != "" {
claimMaps[audiance+DomainCategorySuffix] = claims.DomainCategory
claimMaps[audience+DomainCategorySuffix] = claims.DomainCategory
}
if claims.LastLogin != (time.Time{}) {
claimMaps[audiance+LastLoginSuffix] = claims.LastLogin.Format(layout)
claimMaps[audience+LastLoginSuffix] = claims.LastLogin.Format(layout)
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claimMaps)
r, err := http.NewRequest(http.MethodGet, "http://localhost", nil)
Expand Down
2 changes: 1 addition & 1 deletion sharedsock/sock_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (s *SharedSocket) ReadFrom(b []byte) (n int, addr net.Addr, err error) {
return int(udp.Length), remoteAddr, nil
}

// WriteTo builds a UDP packet and writes it using the specific IP version writter
// WriteTo builds a UDP packet and writes it using the specific IP version writer
func (s *SharedSocket) WriteTo(buf []byte, rAddr net.Addr) (n int, err error) {
rUDPAddr, ok := rAddr.(*net.UDPAddr)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion signal/client/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (c *GrpcClient) SendToStream(msg *proto.EncryptedMessage) error {
return fmt.Errorf("no connection to signal")
}
if c.stream == nil {
return fmt.Errorf("connection to the Signal Exchnage has not been established yet. Please call GrpcClient.Receive before sending messages")
return fmt.Errorf("connection to the Signal Exchange has not been established yet. Please call GrpcClient.Receive before sending messages")
}

err := c.stream.Send(msg)
Expand Down

0 comments on commit c5c6883

Please sign in to comment.