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