Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer committed Dec 11, 2024
1 parent f3ad7e6 commit cbb3ffa
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 79 deletions.
3 changes: 0 additions & 3 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import (

"github.com/eko/gocache/v3/cache"
cacheStore "github.com/eko/gocache/v3/store"
"github.com/hashicorp/go-multierror"
"github.com/miekg/dns"
"github.com/netbirdio/netbird/management/server/networks"
gocache "github.com/patrickmn/go-cache"
"github.com/rs/xid"
log "github.com/sirupsen/logrus"
Expand Down
12 changes: 8 additions & 4 deletions management/server/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import (
"time"

"github.com/golang-jwt/jwt"
"github.com/netbirdio/netbird/management/server/networks"

resourceTypes "github.com/netbirdio/netbird/management/server/networks/resources/types"
routerTypes "github.com/netbirdio/netbird/management/server/networks/routers/types"
networkTypes "github.com/netbirdio/netbird/management/server/networks/types"

log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1790,12 +1794,12 @@ func TestAccount_Copy(t *testing.T) {
},
},
Settings: &types.Settings{},
Networks: []*networks.Network{
Networks: []*networkTypes.Network{
{
ID: "network1",
},
},
NetworkRouters: []*networks.NetworkRouter{
NetworkRouters: []*routerTypes.NetworkRouter{
{
ID: "router1",
NetworkID: "network1",
Expand All @@ -1804,7 +1808,7 @@ func TestAccount_Copy(t *testing.T) {
Metric: 0,
},
},
NetworkResources: []*networks.NetworkResource{
NetworkResources: []*resourceTypes.NetworkResource{
{
ID: "resource1",
NetworkID: "network1",
Expand Down
5 changes: 3 additions & 2 deletions management/server/http/handlers/networks/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/netbirdio/netbird/management/server/http/util"
"github.com/netbirdio/netbird/management/server/jwtclaims"
"github.com/netbirdio/netbird/management/server/networks"
"github.com/netbirdio/netbird/management/server/networks/types"
"github.com/netbirdio/netbird/management/server/status"
)

Expand Down Expand Up @@ -81,7 +82,7 @@ func (h *handler) createNetwork(w http.ResponseWriter, r *http.Request) {
return
}

network := &networks.Network{}
network := &types.Network{}
network.FromAPIRequest(&req)

network.AccountID = accountID
Expand Down Expand Up @@ -140,7 +141,7 @@ func (h *handler) updateNetwork(w http.ResponseWriter, r *http.Request) {
return
}

network := &networks.Network{}
network := &types.Network{}
network.FromAPIRequest(&req)

network.ID = networkID
Expand Down
5 changes: 3 additions & 2 deletions management/server/http/handlers/networks/resources_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/netbirdio/netbird/management/server/http/util"
"github.com/netbirdio/netbird/management/server/jwtclaims"
"github.com/netbirdio/netbird/management/server/networks/resources"
"github.com/netbirdio/netbird/management/server/networks/resources/types"
)

type resourceHandler struct {
Expand Down Expand Up @@ -78,7 +79,7 @@ func (h *resourceHandler) createResource(w http.ResponseWriter, r *http.Request)
return
}

resource := &resources.NetworkResource{}
resource := &types.NetworkResource{}
resource.FromAPIRequest(&req)

resource.NetworkID = mux.Vars(r)["networkId"]
Expand Down Expand Up @@ -126,7 +127,7 @@ func (h *resourceHandler) updateResource(w http.ResponseWriter, r *http.Request)
return
}

resource := &resources.NetworkResource{}
resource := &types.NetworkResource{}
resource.FromAPIRequest(&req)

resource.ID = mux.Vars(r)["resourceId"]
Expand Down
5 changes: 3 additions & 2 deletions management/server/http/handlers/networks/routers_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/netbirdio/netbird/management/server/http/util"
"github.com/netbirdio/netbird/management/server/jwtclaims"
"github.com/netbirdio/netbird/management/server/networks/routers"
"github.com/netbirdio/netbird/management/server/networks/routers/types"
)

type routersHandler struct {
Expand Down Expand Up @@ -79,7 +80,7 @@ func (h *routersHandler) createRouter(w http.ResponseWriter, r *http.Request) {
return
}

router := &routers.NetworkRouter{}
router := &types.NetworkRouter{}
router.FromAPIRequest(&req)

router.NetworkID = networkID
Expand Down Expand Up @@ -128,7 +129,7 @@ func (h *routersHandler) updateRouter(w http.ResponseWriter, r *http.Request) {
return
}

router := &routers.NetworkRouter{}
router := &types.NetworkRouter{}
router.FromAPIRequest(&req)

router.NetworkID = mux.Vars(r)["networkId"]
Expand Down
17 changes: 9 additions & 8 deletions management/server/networks/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (

"github.com/netbirdio/netbird/management/server/networks/resources"
"github.com/netbirdio/netbird/management/server/networks/routers"
"github.com/netbirdio/netbird/management/server/networks/types"
"github.com/netbirdio/netbird/management/server/store"
)

type Manager interface {
GetAllNetworks(ctx context.Context, accountID, userID string) ([]*Network, error)
CreateNetwork(ctx context.Context, userID string, network *Network) (*Network, error)
GetNetwork(ctx context.Context, accountID, userID, networkID string) (*Network, error)
UpdateNetwork(ctx context.Context, userID string, network *Network) (*Network, error)
GetAllNetworks(ctx context.Context, accountID, userID string) ([]*types.Network, error)
CreateNetwork(ctx context.Context, userID string, network *types.Network) (*types.Network, error)
GetNetwork(ctx context.Context, accountID, userID, networkID string) (*types.Network, error)
UpdateNetwork(ctx context.Context, userID string, network *types.Network) (*types.Network, error)
DeleteNetwork(ctx context.Context, accountID, userID, networkID string) error
GetResourceManager() resources.Manager
GetRouterManager() routers.Manager
Expand All @@ -33,19 +34,19 @@ func NewManager(store store.Store) Manager {
}
}

func (m *managerImpl) GetAllNetworks(ctx context.Context, accountID, userID string) ([]*Network, error) {
func (m *managerImpl) GetAllNetworks(ctx context.Context, accountID, userID string) ([]*types.Network, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) CreateNetwork(ctx context.Context, userID string, network *Network) (*Network, error) {
func (m *managerImpl) CreateNetwork(ctx context.Context, userID string, network *types.Network) (*types.Network, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) GetNetwork(ctx context.Context, accountID, userID, networkID string) (*Network, error) {
func (m *managerImpl) GetNetwork(ctx context.Context, accountID, userID, networkID string) (*types.Network, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) UpdateNetwork(ctx context.Context, userID string, network *Network) (*Network, error) {
func (m *managerImpl) UpdateNetwork(ctx context.Context, userID string, network *types.Network) (*types.Network, error) {
return nil, errors.New("not implemented")
}

Expand Down
17 changes: 9 additions & 8 deletions management/server/networks/resources/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"errors"

"github.com/netbirdio/netbird/management/server/networks/resources/types"
"github.com/netbirdio/netbird/management/server/store"
)

type Manager interface {
GetAllResources(ctx context.Context, accountID, userID, networkID string) ([]*NetworkResource, error)
CreateResource(ctx context.Context, accountID string, resource *NetworkResource) (*NetworkResource, error)
GetResource(ctx context.Context, accountID, userID, networkID, resourceID string) (*NetworkResource, error)
UpdateResource(ctx context.Context, userID string, resource *NetworkResource) (*NetworkResource, error)
GetAllResources(ctx context.Context, accountID, userID, networkID string) ([]*types.NetworkResource, error)
CreateResource(ctx context.Context, accountID string, resource *types.NetworkResource) (*types.NetworkResource, error)
GetResource(ctx context.Context, accountID, userID, networkID, resourceID string) (*types.NetworkResource, error)
UpdateResource(ctx context.Context, userID string, resource *types.NetworkResource) (*types.NetworkResource, error)
DeleteResource(ctx context.Context, accountID, userID, networkID, resourceID string) error
}

Expand All @@ -25,19 +26,19 @@ func NewManager(store store.Store) Manager {
}
}

func (m *managerImpl) GetAllResources(ctx context.Context, accountID, userID, networkID string) ([]*NetworkResource, error) {
func (m *managerImpl) GetAllResources(ctx context.Context, accountID, userID, networkID string) ([]*types.NetworkResource, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) CreateResource(ctx context.Context, accountID string, resource *NetworkResource) (*NetworkResource, error) {
func (m *managerImpl) CreateResource(ctx context.Context, accountID string, resource *types.NetworkResource) (*types.NetworkResource, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) GetResource(ctx context.Context, accountID, userID, networkID, resourceID string) (*NetworkResource, error) {
func (m *managerImpl) GetResource(ctx context.Context, accountID, userID, networkID, resourceID string) (*types.NetworkResource, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) UpdateResource(ctx context.Context, userID string, resource *NetworkResource) (*NetworkResource, error) {
func (m *managerImpl) UpdateResource(ctx context.Context, userID string, resource *types.NetworkResource) (*types.NetworkResource, error) {
return nil, errors.New("not implemented")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package resources
package types

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package resources
package types

import (
"testing"
Expand Down
17 changes: 9 additions & 8 deletions management/server/networks/routers/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"errors"

"github.com/netbirdio/netbird/management/server/networks/routers/types"
"github.com/netbirdio/netbird/management/server/store"
)

type Manager interface {
GetAllRouters(ctx context.Context, accountID, userID, networkID string) ([]*NetworkRouter, error)
CreateRouter(ctx context.Context, userID string, router *NetworkRouter) (*NetworkRouter, error)
GetRouter(ctx context.Context, accountID, userID, networkID, routerID string) (*NetworkRouter, error)
UpdateRouter(ctx context.Context, userID string, router *NetworkRouter) (*NetworkRouter, error)
GetAllRouters(ctx context.Context, accountID, userID, networkID string) ([]*types.NetworkRouter, error)
CreateRouter(ctx context.Context, userID string, router *types.NetworkRouter) (*types.NetworkRouter, error)
GetRouter(ctx context.Context, accountID, userID, networkID, routerID string) (*types.NetworkRouter, error)
UpdateRouter(ctx context.Context, userID string, router *types.NetworkRouter) (*types.NetworkRouter, error)
DeleteRouter(ctx context.Context, accountID, userID, networkID, routerID string) error
}

Expand All @@ -25,19 +26,19 @@ func NewManager(store store.Store) Manager {
}
}

func (m *managerImpl) GetAllRouters(ctx context.Context, accountID, userID, networkID string) ([]*NetworkRouter, error) {
func (m *managerImpl) GetAllRouters(ctx context.Context, accountID, userID, networkID string) ([]*types.NetworkRouter, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) CreateRouter(ctx context.Context, userID string, router *NetworkRouter) (*NetworkRouter, error) {
func (m *managerImpl) CreateRouter(ctx context.Context, userID string, router *types.NetworkRouter) (*types.NetworkRouter, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) GetRouter(ctx context.Context, accountID, userID, networkID, routerID string) (*NetworkRouter, error) {
func (m *managerImpl) GetRouter(ctx context.Context, accountID, userID, networkID, routerID string) (*types.NetworkRouter, error) {
return nil, errors.New("not implemented")
}

func (m *managerImpl) UpdateRouter(ctx context.Context, userID string, router *NetworkRouter) (*NetworkRouter, error) {
func (m *managerImpl) UpdateRouter(ctx context.Context, userID string, router *types.NetworkRouter) (*types.NetworkRouter, error) {
return nil, errors.New("not implemented")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package routers
package types

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package routers
package types

import "testing"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package networks
package types

import (
"github.com/rs/xid"
Expand Down
Loading

0 comments on commit cbb3ffa

Please sign in to comment.