Skip to content

Commit

Permalink
chore: apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
restanrm committed Apr 25, 2022
1 parent 3d30244 commit 2c448d4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ func (h *Headscale) expireEphemeralNodesWorker() {
func (h *Headscale) grpcAuthenticationInterceptor(ctx context.Context,
req interface{},
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {
handler grpc.UnaryHandler,
) (interface{}, error) {
// Check if the request is coming from the on-server client.
// This is not secure, but it is to maintain maintainability
// with the "legacy" database-based client
Expand Down
4 changes: 2 additions & 2 deletions cmd/headscale/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,9 @@ func GetFileMode(key string) fs.FileMode {
return fs.FileMode(mode)
}

func contains[T string](ts []T, t T) bool {
func contains(ts []T, t T) bool {
for _, v := range ts {
if reflect.DeepEqual(v,t) {
if reflect.DeepEqual(v, t) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion derp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (h *Headscale) DERPHandler(ctx *gin.Context) {

if !fastStart {
pubKey := h.privateKey.Public()
pubKeyStr := pubKey.UntypedHexString() // nolint
pubKeyStr := pubKey.UntypedHexString()
fmt.Fprintf(conn, "HTTP/1.1 101 Switching Protocols\r\n"+
"Upgrade: DERP\r\n"+
"Connection: Upgrade\r\n"+
Expand Down
4 changes: 2 additions & 2 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ func (h *Headscale) UpdateMachine(machine *Machine) error {
// SetTags takes a Machine struct pointer and update the forced tags.
func (h *Headscale) SetTags(machine *Machine, tags []string) error {
machine.ForcedTags = tags
err := h.UpdateACLRules()
if err != nil {
if err := h.UpdateACLRules(); err != nil {
return err
}
h.setLastStateChangeToNow(machine.Namespace.Name)
Expand Down Expand Up @@ -670,6 +669,7 @@ func getTags(
owners, err := expandTagOwners(aclPolicy, tag, stripEmailDomain)
if errors.Is(err, errInvalidTag) {
invalidTagMap[tag] = true

continue
}
var found bool
Expand Down
14 changes: 12 additions & 2 deletions machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,23 @@ func Test_getTags(t *testing.T) {
)
for _, valid := range gotValid {
if !contains(test.wantValid, valid) {
t.Errorf("valids: getTags() = %v, want %v", gotValid, test.wantValid)
t.Errorf(
"valids: getTags() = %v, want %v",
gotValid,
test.wantValid,
)

break
}
}
for _, invalid := range gotInvalid {
if !contains(test.wantInvalid, invalid) {
t.Errorf("invalids: getTags() = %v, want %v", gotInvalid, test.wantInvalid)
t.Errorf(
"invalids: getTags() = %v, want %v",
gotInvalid,
test.wantInvalid,
)

break
}
}
Expand Down
2 changes: 1 addition & 1 deletion poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func (h *Headscale) scheduledPollWorker(
}
}

func closeChanWithLog[C chan []byte | chan struct{}](channel C, machine, name string) {
func closeChanWithLog(channel C, machine, name string) {
log.Trace().
Str("handler", "PollNetMap").
Str("machine", machine).
Expand Down
8 changes: 4 additions & 4 deletions proto/headscale/v1/machine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ message Machine {
// bytes endpoints = 16;
// bytes enabled_routes = 17;

repeated string forced_tags = 18;
repeated string forced_tags = 18;
repeated string invalid_tags = 19;
repeated string valid_tags = 20;
repeated string valid_tags = 20;
}

message RegisterMachineRequest {
Expand All @@ -63,8 +63,8 @@ message GetMachineResponse {
}

message SetTagsRequest {
uint64 machine_id = 1;
repeated string tags = 2;
uint64 machine_id = 1;
repeated string tags = 2;
}

message SetTagsResponse {
Expand Down

0 comments on commit 2c448d4

Please sign in to comment.