-
Notifications
You must be signed in to change notification settings - Fork 7
/
ccaplatformconfigid.go
98 lines (77 loc) · 1.92 KB
/
ccaplatformconfigid.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2021-2024 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package comid
import (
"encoding/json"
"errors"
"fmt"
"unicode/utf8"
)
var CCAPlatformConfigIDType = "cca.platform-config-id"
type CCAPlatformConfigID string
func (o CCAPlatformConfigID) Empty() bool {
return o == ""
}
func (o *CCAPlatformConfigID) Set(v string) error {
if v == "" {
return fmt.Errorf("empty input string")
}
*o = CCAPlatformConfigID(v)
return nil
}
func (o CCAPlatformConfigID) Get() (CCAPlatformConfigID, error) {
if o == "" {
return "", fmt.Errorf("empty CCA platform config ID")
}
return o, nil
}
type TaggedCCAPlatformConfigID CCAPlatformConfigID
func NewTaggedCCAPlatformConfigID(val any) (*TaggedCCAPlatformConfigID, error) {
var ret TaggedCCAPlatformConfigID
if val == nil {
return &ret, nil
}
switch t := val.(type) {
case TaggedCCAPlatformConfigID:
ret = t
case *TaggedCCAPlatformConfigID:
ret = *t
case CCAPlatformConfigID:
ret = TaggedCCAPlatformConfigID(t)
case *CCAPlatformConfigID:
ret = TaggedCCAPlatformConfigID(*t)
case string:
ret = TaggedCCAPlatformConfigID(t)
case []byte:
if !utf8.Valid(t) {
return nil, errors.New("bytes do not form a valid UTF-8 string")
}
ret = TaggedCCAPlatformConfigID(t)
default:
return nil, fmt.Errorf("unexpected type for CCA platform-config-id: %T", t)
}
return &ret, nil
}
func (o TaggedCCAPlatformConfigID) Valid() error {
if o == "" {
return errors.New("empty value")
}
return nil
}
func (o TaggedCCAPlatformConfigID) String() string {
return string(o)
}
func (o TaggedCCAPlatformConfigID) Type() string {
return CCAPlatformConfigIDType
}
func (o TaggedCCAPlatformConfigID) IsZero() bool {
return len(o) == 0
}
func (o *TaggedCCAPlatformConfigID) UnmarshalJSON(data []byte) error {
var temp string
if err := json.Unmarshal(data, &temp); err != nil {
return err
}
*o = TaggedCCAPlatformConfigID(temp)
return nil
}