-
Notifications
You must be signed in to change notification settings - Fork 19
/
global.go
50 lines (41 loc) · 1.1 KB
/
global.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
package assets
import "fmt"
// Global is a named constant.
//
// {
// "key": "organization_name",
// "name": "Organization Name",
// "value": "U-Report"
// }
//
// @asset global
type Global interface {
Key() string
Name() string
Value() string
}
// GlobalReference is a reference to a global
type GlobalReference struct {
Key string `json:"key" validate:"required"`
Name string `json:"name"`
}
// NewGlobalReference creates a new global reference with the given key and name
func NewGlobalReference(key string, name string) *GlobalReference {
return &GlobalReference{Key: key, Name: name}
}
// Type returns the name of the asset type
func (r *GlobalReference) Type() string {
return "global"
}
// Identity returns the unique identity of the asset
func (r *GlobalReference) Identity() string {
return string(r.Key)
}
// Variable returns whether this a variable (vs concrete) reference
func (r *GlobalReference) Variable() bool {
return false
}
func (r *GlobalReference) String() string {
return fmt.Sprintf("%s[key=%s,name=%s]", r.Type(), r.Identity(), r.Name)
}
var _ Reference = (*GlobalReference)(nil)