-
Notifications
You must be signed in to change notification settings - Fork 3
/
payload.go
50 lines (38 loc) · 1004 Bytes
/
payload.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
47
48
49
50
// Copyright 2020 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package swid
// Payload models a payload-entry
type Payload struct {
PayloadExtension
GlobalAttributes
ResourceCollection
}
// NewPayload instantiates a new empty Payload object
func NewPayload() *Payload {
return &Payload{}
}
// AddDirectory adds the supplied Directory to the ResourceCollection of the
// Payload receiver
func (p *Payload) AddDirectory(d Directory) error {
if p.Directories == nil {
p.Directories = new(Directories)
}
*p.Directories = append(*p.Directories, d)
return nil
}
func (p *Payload) AddFile(f File) error {
if p.Files == nil {
p.Files = new(Files)
}
*p.Files = append(*p.Files, f)
return nil
}
// AddResource adds the supplied Directory to the ResourceCollection of the
// Payload receiver
func (p *Payload) AddResource(r Resource) error {
if p.Resources == nil {
p.Resources = new(Resources)
}
*p.Resources = append(*p.Resources, r)
return nil
}