mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-12 17:59:06 +02:00
Use list of owners
This commit is contained in:
@@ -211,7 +211,7 @@ type Config struct {
|
||||
// (HasKey, ManagedKeys, IsEmpty).
|
||||
policy *mdm.Policy `json:"-"`
|
||||
|
||||
Owner string
|
||||
Owners []string
|
||||
}
|
||||
|
||||
// Policy returns the MDM policy applied to this Config. Returns a non-nil
|
||||
@@ -718,7 +718,7 @@ func (config *Config) apply(input ConfigInput) (updated bool, err error) {
|
||||
|
||||
if input.Owner != nil {
|
||||
ownerString := ipcauth.OwnerPrincipalForIdentity(*input.Owner)
|
||||
config.Owner = ownerString
|
||||
config.Owners = append([]string{}, ownerString)
|
||||
log.Infof("setting '%s' as owner for profile %s", ownerString, config.Name)
|
||||
updated = true
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ type profileMeta struct {
|
||||
|
||||
// nolint:unused
|
||||
type ownerMeta struct {
|
||||
Owner string
|
||||
Owners []string
|
||||
}
|
||||
|
||||
func (e *ErrAmbiguousHandle) Error() string {
|
||||
@@ -578,16 +578,16 @@ func readProfileName(path string) string {
|
||||
}
|
||||
|
||||
// nolint: unused,unusedfunc
|
||||
func readProfileOwner(path string) string {
|
||||
func readProfileOwner(path string) []string {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return ""
|
||||
return []string{}
|
||||
}
|
||||
var meta ownerMeta
|
||||
if err := json.Unmarshal(data, &meta); err != nil {
|
||||
return ""
|
||||
return []string{}
|
||||
}
|
||||
return meta.Owner
|
||||
return meta.Owners
|
||||
}
|
||||
|
||||
// nolint: unused,unusedfunc
|
||||
@@ -600,7 +600,7 @@ func stampOwner(path string, owner ipcauth.Identity) error {
|
||||
if err := json.Unmarshal(data, &cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.Owner = ipcauth.OwnerPrincipalForIdentity(owner)
|
||||
cfg.Owners = append([]string{}, ipcauth.OwnerPrincipalForIdentity(owner))
|
||||
|
||||
if err := util.WriteJson(context.Background(), path, cfg); err != nil {
|
||||
return fmt.Errorf("failed to write profile owner: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user