-
Notifications
You must be signed in to change notification settings - Fork 261
/
resource_with_metadata_impl.go
44 lines (35 loc) · 1.25 KB
/
resource_with_metadata_impl.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
package modconfig
import "github.com/hashicorp/hcl/v2"
type ResourceWithMetadataImpl struct {
// required to allow partial decoding
ResourceWithMetadataBaseRemain hcl.Body `hcl:",remain" json:"-"`
References []*ResourceReference `json:"-"`
metadata *ResourceMetadata
anonymous bool
}
// GetMetadata implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) GetMetadata() *ResourceMetadata {
return b.metadata
}
// SetMetadata implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) SetMetadata(metadata *ResourceMetadata) {
b.metadata = metadata
// set anonymous property on metadata
b.metadata.Anonymous = b.anonymous
}
// SetAnonymous implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) SetAnonymous(block *hcl.Block) {
b.anonymous = len(block.Labels) == 0
}
// IsAnonymous implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) IsAnonymous() bool {
return b.anonymous
}
// AddReference implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) AddReference(ref *ResourceReference) {
b.References = append(b.References, ref)
}
// GetReferences implements ResourceWithMetadata
func (b *ResourceWithMetadataImpl) GetReferences() []*ResourceReference {
return b.References
}