-
Notifications
You must be signed in to change notification settings - Fork 6
/
archetype.go
46 lines (40 loc) · 1.46 KB
/
archetype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package alzlib
import (
mapset "github.com/deckarep/golang-set/v2"
)
// Archetype represents an archetype definition that hasn't been assigned to a management group
// The contents of the sets represent the map keys of the corresponding AlzLib maps.
// Do not creaste this struct directly, use NewArchetype instead.
type Archetype struct {
PolicyDefinitions mapset.Set[string]
PolicyAssignments mapset.Set[string]
PolicySetDefinitions mapset.Set[string]
RoleDefinitions mapset.Set[string]
name string
}
// NewArchetype creates a new Archetype with the given name.
func NewArchetype(name string) *Archetype {
return &Archetype{
PolicyDefinitions: mapset.NewThreadUnsafeSet[string](),
PolicyAssignments: mapset.NewThreadUnsafeSet[string](),
PolicySetDefinitions: mapset.NewThreadUnsafeSet[string](),
RoleDefinitions: mapset.NewThreadUnsafeSet[string](),
name: name,
}
}
// Name returns the name of the archetype.
func (a *Archetype) Name() string {
return a.name
}
// copy creates a deep copy of the archetype.
func (a *Archetype) copy() *Archetype {
return &Archetype{
PolicyDefinitions: a.PolicyDefinitions.Clone(),
PolicyAssignments: a.PolicyAssignments.Clone(),
PolicySetDefinitions: a.PolicySetDefinitions.Clone(),
RoleDefinitions: a.RoleDefinitions.Clone(),
name: a.name,
}
}