Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
93c861c
feat(go): add schema definition for organization and tenant tables;
VishalDalwadi Jun 18, 2026
be49886
feat(go): add org/tenant scoping to db; add middleware for api handle…
VishalDalwadi Jun 18, 2026
0242485
feat(go): add tenant scope declaration for some controllers;
VishalDalwadi Jun 18, 2026
231f879
feat(go): add tenant id columns to all tables in schema pkg;
VishalDalwadi Jun 18, 2026
7cdb593
feat(go): add multi-tenancy migration;
VishalDalwadi Jun 18, 2026
8b8d5ce
feat(go): migration ensures default org and tenant is created only on…
VishalDalwadi Jun 18, 2026
21f4316
feat(go): remove shutdown api;
VishalDalwadi Jun 18, 2026
9a2b6a7
feat(go): assign tenant scope to server config and settings api;
VishalDalwadi Jun 18, 2026
9185365
feat(go): assign tenant scope to apis host calls;
VishalDalwadi Jun 18, 2026
10c9b1a
feat(go): prevent error on missing tenant/organization id for existin…
VishalDalwadi Jun 18, 2026
0f34afa
feat(go): add schema definition for organization settings;
VishalDalwadi Jun 19, 2026
d2427d3
feat(go): move user settings to user table;
VishalDalwadi Jun 19, 2026
194fe9b
feat(go): add migration of user settings from server settings table;
VishalDalwadi Jun 19, 2026
1f0354e
feat(go): remove usage of host actions table;
VishalDalwadi Jun 19, 2026
8816f8d
feat(go): add schema definition for tenant settings;
VishalDalwadi Jun 19, 2026
a494009
feat(go): move scope to it's own package;
VishalDalwadi Jun 22, 2026
41fd5de
feat(go): add schema definition for dns records;
VishalDalwadi Jun 22, 2026
0ccf21a
wip(go): add method to modify db in ctx;
VishalDalwadi Jun 22, 2026
a0c89ea
wip(go): move dns records db management to schema pkg;
VishalDalwadi Jun 22, 2026
b2a98ef
wip(go): move acl, metrics, extclient and tag records db management t…
VishalDalwadi Jun 22, 2026
1750b0f
wip(go): move cache db management to schema pkg;
VishalDalwadi Jun 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions auth/host_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/gravitl/netmaker/db"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/logic/hostactions"
"github.com/gravitl/netmaker/logic/pro/netcache"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/mq"
Expand Down Expand Up @@ -45,7 +44,7 @@ func SessionHandler(conn *websocket.Conn) {
return
}

req := new(netcache.CValue)
req := new(schema.CacheValue)
req.Value = string(registerMessage.RegisterHost.ID.String())
req.Network = registerMessage.Network
req.Host = registerMessage.RegisterHost
Expand All @@ -65,7 +64,7 @@ func SessionHandler(conn *websocket.Conn) {
defer netcache.Del(stateStr)
// Wait for the user to finish his auth flow...
timeout := make(chan bool, 2)
answer := make(chan netcache.CValue, 1)
answer := make(chan schema.CacheValue, 1)
defer close(answer)
defer close(timeout)
if len(registerMessage.User) > 0 { // handle basic auth
Expand Down Expand Up @@ -232,9 +231,9 @@ func SessionHandler(conn *websocket.Conn) {
func CheckNetRegAndHostUpdate(key schema.EnrollmentKey, host *schema.Host, username string) {
// publish host update through MQ
featureFlags := logic.GetFeatureFlags()
keyTags := make(map[models.TagID]struct{})
keyTags := make(map[schema.TagID]struct{})
for _, tagI := range key.Tags {
keyTags[models.TagID(tagI)] = struct{}{}
keyTags[schema.TagID(tagI)] = struct{}{}
}
for _, netID := range key.Networks {
network := &schema.Network{Name: netID}
Expand Down Expand Up @@ -287,7 +286,7 @@ func CheckNetRegAndHostUpdate(key schema.EnrollmentKey, host *schema.Host, usern
continue
}

node, err := orchestrator.GetRepository().NodeOrchestrator().CreateNode(
_, err := orchestrator.GetRepository().NodeOrchestrator().CreateNode(
db.WithContext(context.TODO()),
host,
network,
Expand All @@ -298,13 +297,6 @@ func CheckNetRegAndHostUpdate(key schema.EnrollmentKey, host *schema.Host, usern
if err != nil {
logger.Log(0, fmt.Sprintf("failed to add host (%s, %s) to network (%s): %v", host.ID.String(), host.Name, netID, err.Error()))
} else {
newNode := logic.ConvertSchemaNodeToModelsNode(node)
hostactions.AddAction(models.HostUpdate{
Action: models.JoinHostToNetwork,
Host: *host,
Node: *newNode,
})

if len(username) > 0 {
logic.LogEvent(&models.Event{
Action: schema.JoinHostToNet,
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/dns/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"

"github.com/gravitl/netmaker/cli/functions"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +17,7 @@ var dnsCreateCmd = &cobra.Command{
if address == "" && address6 == "" {
log.Fatal("Either IPv4 or IPv6 address is required")
}
dnsEntry := &models.DNSEntry{Name: dnsName, Address: address, Address6: address6, Network: networkName}
dnsEntry := &schema.DNSEntry{Name: dnsName, Address: address, Address6: address6, Network: networkName}
functions.PrettyPrint(functions.CreateDNS(networkName, dnsEntry))
},
}
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/dns/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/gravitl/netmaker/cli/cmd/commons"
"github.com/gravitl/netmaker/cli/functions"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
"github.com/guumaster/tablewriter"
"github.com/spf13/cobra"
)
Expand All @@ -17,7 +17,7 @@ var dnsListCmd = &cobra.Command{
Short: "List DNS entries",
Long: `List DNS entries`,
Run: func(cmd *cobra.Command, args []string) {
var data []models.DNSEntry
var data []schema.DNSEntry
if networkName != "" {
switch dnsType {
case "node":
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/ext_client/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/gravitl/netmaker/cli/cmd/commons"
"github.com/gravitl/netmaker/cli/functions"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
"github.com/guumaster/tablewriter"
"github.com/spf13/cobra"
)
Expand All @@ -20,7 +20,7 @@ var extClientListCmd = &cobra.Command{
Short: "List External Clients",
Long: `List External Clients`,
Run: func(cmd *cobra.Command, args []string) {
var data []models.ExtClient
var data []schema.ExtClient
if networkName != "" {
data = *functions.GetNetworkExtClients(networkName)
} else {
Expand Down
22 changes: 11 additions & 11 deletions cli/functions/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ import (
"fmt"
"net/http"

"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
)

// GetDNS - fetch all DNS entries
func GetDNS() *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, "/api/dns", nil)
func GetDNS() *[]schema.DNSEntry {
return request[[]schema.DNSEntry](http.MethodGet, "/api/dns", nil)
}

// GetNodeDNS - fetch all Node DNS entires
func GetNodeDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
func GetNodeDNS(networkName string) *[]schema.DNSEntry {
return request[[]schema.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
}

// GetCustomDNS - fetch user defined DNS entriees
func GetCustomDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
func GetCustomDNS(networkName string) *[]schema.DNSEntry {
return request[[]schema.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
}

// GetNetworkDNS - fetch DNS entries associated with a network
func GetNetworkDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
func GetNetworkDNS(networkName string) *[]schema.DNSEntry {
return request[[]schema.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
}

// CreateDNS - create a DNS entry
func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
func CreateDNS(networkName string, payload *schema.DNSEntry) *schema.DNSEntry {
return request[schema.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
}

// PushDNS - push a DNS entry to CoreDNS
Expand Down
17 changes: 9 additions & 8 deletions cli/functions/ext_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import (
"net/http"

"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
)

// GetAllExtClients - fetch all external clients
func GetAllExtClients() *[]models.ExtClient {
return request[[]models.ExtClient](http.MethodGet, "/api/extclients", nil)
func GetAllExtClients() *[]schema.ExtClient {
return request[[]schema.ExtClient](http.MethodGet, "/api/extclients", nil)
}

// GetNetworkExtClients - fetch external clients associated with a network
func GetNetworkExtClients(networkName string) *[]models.ExtClient {
return request[[]models.ExtClient](http.MethodGet, "/api/extclients/"+networkName, nil)
func GetNetworkExtClients(networkName string) *[]schema.ExtClient {
return request[[]schema.ExtClient](http.MethodGet, "/api/extclients/"+networkName, nil)
}

// GetExtClient - fetch a single external client
func GetExtClient(networkName, clientID string) *models.ExtClient {
return request[models.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
func GetExtClient(networkName, clientID string) *schema.ExtClient {
return request[schema.ExtClient](http.MethodGet, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), nil)
}

// GetExtClientConfig - fetch a wireguard config of an external client
Expand All @@ -43,6 +44,6 @@ func DeleteExtClient(networkName, clientID string) *models.SuccessResponse {
}

// UpdateExtClient - update an external client
func UpdateExtClient(networkName, clientID string, payload *models.CustomExtClient) *models.ExtClient {
return request[models.ExtClient](http.MethodPut, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), payload)
func UpdateExtClient(networkName, clientID string, payload *models.CustomExtClient) *schema.ExtClient {
return request[schema.ExtClient](http.MethodPut, fmt.Sprintf("/api/extclients/%s/%s", networkName, clientID), payload)
}
9 changes: 5 additions & 4 deletions cli/functions/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"net/http"

"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/schema"
)

// GetNodeMetrics - fetch a single node's metrics
func GetNodeMetrics(networkName, nodeID string) *models.Metrics {
return request[models.Metrics](http.MethodGet, fmt.Sprintf("/api/metrics/%s/%s", networkName, nodeID), nil)
func GetNodeMetrics(networkName, nodeID string) *schema.Metrics {
return request[schema.Metrics](http.MethodGet, fmt.Sprintf("/api/metrics/%s/%s", networkName, nodeID), nil)
}

// GetNetworkNodeMetrics - fetch an entire network's metrics
Expand All @@ -23,6 +24,6 @@ func GetAllMetrics() *models.NetworkMetrics {
}

// GetNetworkExtMetrics - fetch external client metrics belonging to a network
func GetNetworkExtMetrics(networkName string) *map[string]models.Metric {
return request[map[string]models.Metric](http.MethodGet, "/api/metrics-ext/"+networkName, nil)
func GetNetworkExtMetrics(networkName string) *map[string]schema.Metric {
return request[map[string]schema.Metric](http.MethodGet, "/api/metrics-ext/"+networkName, nil)
}
Loading
Loading