-
Notifications
You must be signed in to change notification settings - Fork 1
/
system.go
40 lines (33 loc) · 870 Bytes
/
system.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
package xrhidgen
import (
"github.com/pioz/faker"
"github.com/redhatinsights/platform-go-middlewares/v2/identity"
)
// System holds values to be used as input when generating a system identity
// record.
type System struct {
CertType *string
ClusterID *string
CN *string
}
// NewSystem will build and return a fully populated System data structure,
// using any values that are present in template.
func NewSystem(template System) (*identity.System, error) {
var id identity.System
if template.CertType != nil {
id.CertType = *template.CertType
} else {
id.CertType = faker.Pick("", "consumer", "system")
}
if template.ClusterID != nil {
id.ClusterId = *template.ClusterID
} else {
id.ClusterId = faker.String()
}
if template.CN != nil {
id.CommonName = *template.CN
} else {
id.CommonName = faker.String()
}
return &id, nil
}