Skip to content

Commit

Permalink
Fix headscale errorcheck (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Sep 13, 2022
1 parent 5236b60 commit 57f462b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/metal-api/internal/headscale/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package headscale

import (
"context"
"errors"
"fmt"
"strings"
"time"

"go.uber.org/zap"
Expand Down Expand Up @@ -97,7 +97,8 @@ func (h *HeadscaleClient) CreateNamespace(name string) error {
Name: name,
}
_, err := h.client.CreateNamespace(h.ctx, req)
if err != nil && !errors.Is(headscalecore.ErrNamespaceExists, err) {
// TODO: this error check is pretty rough, but it's not easily possible to compare the proto error directly :/
if err != nil && !strings.Contains(err.Error(), headscalecore.ErrNamespaceExists.Error()) {
return fmt.Errorf("failed to create new VPN namespace: %w", err)
}

Expand Down

0 comments on commit 57f462b

Please sign in to comment.