mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-12 16:39:09 +02:00
fix domain store slice retrieval
This commit is contained in:
@@ -61,7 +61,7 @@ func (h *handler) getAllDomains(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret []api.ReverseProxyDomain
|
ret := make([]api.ReverseProxyDomain, 0)
|
||||||
for _, d := range domains {
|
for _, d := range domains {
|
||||||
ret = append(ret, domainToApi(d))
|
ret = append(ret, domainToApi(d))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/netbirdio/netbird/management/server/types"
|
"github.com/netbirdio/netbird/management/server/types"
|
||||||
"github.com/netbirdio/netbird/shared/management/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type domainType string
|
type domainType string
|
||||||
@@ -59,10 +58,7 @@ func (m Manager) GetDomains(ctx context.Context, accountID string) ([]*Domain, e
|
|||||||
return nil, fmt.Errorf("list free domains: %w", err)
|
return nil, fmt.Errorf("list free domains: %w", err)
|
||||||
}
|
}
|
||||||
domains, err := m.store.ListCustomDomains(ctx, accountID)
|
domains, err := m.store.ListCustomDomains(ctx, accountID)
|
||||||
if statusErr, ok := status.FromError(err); ok && statusErr.Type() == status.NotFound {
|
if err != nil {
|
||||||
// This is fine, make sure domains are correctly set and continue.
|
|
||||||
domains = make([]*Domain, 0)
|
|
||||||
} else if err != nil {
|
|
||||||
return nil, fmt.Errorf("list custom domains: %w", err)
|
return nil, fmt.Errorf("list custom domains: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4715,7 +4715,7 @@ func (s *SqlStore) ListCustomDomains(ctx context.Context, accountID string) ([]*
|
|||||||
tx := s.db
|
tx := s.db
|
||||||
|
|
||||||
var domains []*domain.Domain
|
var domains []*domain.Domain
|
||||||
result := tx.Find(domains, accountIDCondition, accountID)
|
result := tx.Find(&domains, accountIDCondition, accountID)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.WithContext(ctx).Errorf("failed to get reverse proxy custom domains from the store: %s", result.Error)
|
log.WithContext(ctx).Errorf("failed to get reverse proxy custom domains from the store: %s", result.Error)
|
||||||
return nil, status.Errorf(status.Internal, "failed to get reverse proxy custom domains from store")
|
return nil, status.Errorf(status.Internal, "failed to get reverse proxy custom domains from store")
|
||||||
|
|||||||
Reference in New Issue
Block a user