-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathendorse_opts.go
More file actions
80 lines (64 loc) · 1.9 KB
/
endorse_opts.go
File metadata and controls
80 lines (64 loc) · 1.9 KB
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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package ttx
// EndorsementsOpts is used to configure the CollectEndorsementsView
type EndorsementsOpts struct {
// SkipAuditing set it to true to skip the auditing phase
SkipAuditing bool
// SkipApproval set it to true to skip the approval phase
SkipApproval bool
// SkipDistributeEnv set it to true to skip the distribution phase
SkipDistributeEnv bool
// External Signers
ExternalWalletSigners map[string]ExternalWalletSigner
}
func (o *EndorsementsOpts) ExternalWalletSigner(id string) ExternalWalletSigner {
if o.ExternalWalletSigners == nil {
return nil
}
return o.ExternalWalletSigners[id]
}
// EndorsementsOpt is a function that configures a EndorsementsOpts
type EndorsementsOpt func(*EndorsementsOpts) error
// CompileCollectEndorsementsOpts compiles the given list of ServiceOption
func CompileCollectEndorsementsOpts(opts ...EndorsementsOpt) (*EndorsementsOpts, error) {
txOptions := &EndorsementsOpts{}
for _, opt := range opts {
if err := opt(txOptions); err != nil {
return nil, err
}
}
return txOptions, nil
}
// WithSkipAuditing to skip auditing
func WithSkipAuditing() EndorsementsOpt {
return func(o *EndorsementsOpts) error {
o.SkipAuditing = true
return nil
}
}
// WithSkipApproval to skip approval
func WithSkipApproval() EndorsementsOpt {
return func(o *EndorsementsOpts) error {
o.SkipApproval = true
return nil
}
}
// WithSkipDistributeEnv to skip approval
func WithSkipDistributeEnv() EndorsementsOpt {
return func(o *EndorsementsOpts) error {
o.SkipDistributeEnv = true
return nil
}
}
func WithExternalWalletSigner(walletID string, ews ExternalWalletSigner) EndorsementsOpt {
return func(o *EndorsementsOpts) error {
if o.ExternalWalletSigners == nil {
o.ExternalWalletSigners = map[string]ExternalWalletSigner{}
}
o.ExternalWalletSigners[walletID] = ews
return nil
}
}