mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-04 02:44:29 +08:00
create enrollementkey for existing networks
This commit is contained in:
parent
636b2ff1a7
commit
60ea2a76a6
1 changed files with 28 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"golang.org/x/exp/slog"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/gravitl/netmaker/database"
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/logic"
|
||||
|
@ -122,6 +123,33 @@ func updateEnrollmentKeys() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
existingKeys, err := logic.GetAllEnrollmentKeys()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// check if any tags are duplicate
|
||||
existingTags := make(map[string]struct{})
|
||||
for _, existingKey := range existingKeys {
|
||||
for _, t := range existingKey.Tags {
|
||||
existingTags[t] = struct{}{}
|
||||
}
|
||||
}
|
||||
networks, _ := logic.GetNetworks()
|
||||
for _, network := range networks {
|
||||
if _, ok := existingTags[network.NetID]; ok {
|
||||
continue
|
||||
}
|
||||
_, _ = logic.CreateEnrollmentKey(
|
||||
0,
|
||||
time.Time{},
|
||||
[]string{network.NetID},
|
||||
[]string{network.NetID},
|
||||
true,
|
||||
uuid.Nil,
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func removeOldUserGrps() {
|
||||
|
|
Loading…
Add table
Reference in a new issue