-
Notifications
You must be signed in to change notification settings - Fork 257
/
zz_generated.options.go
145 lines (127 loc) · 4.85 KB
/
zz_generated.options.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Code generated by github.com/ecordell/optgen. DO NOT EDIT.
package testserver
import (
util "github.com/authzed/spicedb/pkg/cmd/util"
defaults "github.com/creasty/defaults"
helpers "github.com/ecordell/optgen/helpers"
)
type ConfigOption func(c *Config)
// NewConfigWithOptions creates a new Config with the passed in options set
func NewConfigWithOptions(opts ...ConfigOption) *Config {
c := &Config{}
for _, o := range opts {
o(c)
}
return c
}
// NewConfigWithOptionsAndDefaults creates a new Config with the passed in options set starting from the defaults
func NewConfigWithOptionsAndDefaults(opts ...ConfigOption) *Config {
c := &Config{}
defaults.MustSet(c)
for _, o := range opts {
o(c)
}
return c
}
// ToOption returns a new ConfigOption that sets the values from the passed in Config
func (c *Config) ToOption() ConfigOption {
return func(to *Config) {
to.GRPCServer = c.GRPCServer
to.ReadOnlyGRPCServer = c.ReadOnlyGRPCServer
to.HTTPGateway = c.HTTPGateway
to.ReadOnlyHTTPGateway = c.ReadOnlyHTTPGateway
to.LoadConfigs = c.LoadConfigs
to.MaximumUpdatesPerWrite = c.MaximumUpdatesPerWrite
to.MaximumPreconditionCount = c.MaximumPreconditionCount
to.MaxCaveatContextSize = c.MaxCaveatContextSize
to.MaxRelationshipContextSize = c.MaxRelationshipContextSize
}
}
// DebugMap returns a map form of Config for debugging
func (c Config) DebugMap() map[string]any {
debugMap := map[string]any{}
debugMap["GRPCServer"] = helpers.DebugValue(c.GRPCServer, false)
debugMap["ReadOnlyGRPCServer"] = helpers.DebugValue(c.ReadOnlyGRPCServer, false)
debugMap["HTTPGateway"] = helpers.DebugValue(c.HTTPGateway, false)
debugMap["ReadOnlyHTTPGateway"] = helpers.DebugValue(c.ReadOnlyHTTPGateway, false)
debugMap["LoadConfigs"] = helpers.DebugValue(c.LoadConfigs, false)
debugMap["MaximumUpdatesPerWrite"] = helpers.DebugValue(c.MaximumUpdatesPerWrite, false)
debugMap["MaximumPreconditionCount"] = helpers.DebugValue(c.MaximumPreconditionCount, false)
debugMap["MaxCaveatContextSize"] = helpers.DebugValue(c.MaxCaveatContextSize, false)
debugMap["MaxRelationshipContextSize"] = helpers.DebugValue(c.MaxRelationshipContextSize, false)
return debugMap
}
// ConfigWithOptions configures an existing Config with the passed in options set
func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config {
for _, o := range opts {
o(c)
}
return c
}
// WithOptions configures the receiver Config with the passed in options set
func (c *Config) WithOptions(opts ...ConfigOption) *Config {
for _, o := range opts {
o(c)
}
return c
}
// WithGRPCServer returns an option that can set GRPCServer on a Config
func WithGRPCServer(gRPCServer util.GRPCServerConfig) ConfigOption {
return func(c *Config) {
c.GRPCServer = gRPCServer
}
}
// WithReadOnlyGRPCServer returns an option that can set ReadOnlyGRPCServer on a Config
func WithReadOnlyGRPCServer(readOnlyGRPCServer util.GRPCServerConfig) ConfigOption {
return func(c *Config) {
c.ReadOnlyGRPCServer = readOnlyGRPCServer
}
}
// WithHTTPGateway returns an option that can set HTTPGateway on a Config
func WithHTTPGateway(hTTPGateway util.HTTPServerConfig) ConfigOption {
return func(c *Config) {
c.HTTPGateway = hTTPGateway
}
}
// WithReadOnlyHTTPGateway returns an option that can set ReadOnlyHTTPGateway on a Config
func WithReadOnlyHTTPGateway(readOnlyHTTPGateway util.HTTPServerConfig) ConfigOption {
return func(c *Config) {
c.ReadOnlyHTTPGateway = readOnlyHTTPGateway
}
}
// WithLoadConfigs returns an option that can append LoadConfigss to Config.LoadConfigs
func WithLoadConfigs(loadConfigs string) ConfigOption {
return func(c *Config) {
c.LoadConfigs = append(c.LoadConfigs, loadConfigs)
}
}
// SetLoadConfigs returns an option that can set LoadConfigs on a Config
func SetLoadConfigs(loadConfigs []string) ConfigOption {
return func(c *Config) {
c.LoadConfigs = loadConfigs
}
}
// WithMaximumUpdatesPerWrite returns an option that can set MaximumUpdatesPerWrite on a Config
func WithMaximumUpdatesPerWrite(maximumUpdatesPerWrite uint16) ConfigOption {
return func(c *Config) {
c.MaximumUpdatesPerWrite = maximumUpdatesPerWrite
}
}
// WithMaximumPreconditionCount returns an option that can set MaximumPreconditionCount on a Config
func WithMaximumPreconditionCount(maximumPreconditionCount uint16) ConfigOption {
return func(c *Config) {
c.MaximumPreconditionCount = maximumPreconditionCount
}
}
// WithMaxCaveatContextSize returns an option that can set MaxCaveatContextSize on a Config
func WithMaxCaveatContextSize(maxCaveatContextSize int) ConfigOption {
return func(c *Config) {
c.MaxCaveatContextSize = maxCaveatContextSize
}
}
// WithMaxRelationshipContextSize returns an option that can set MaxRelationshipContextSize on a Config
func WithMaxRelationshipContextSize(maxRelationshipContextSize int) ConfigOption {
return func(c *Config) {
c.MaxRelationshipContextSize = maxRelationshipContextSize
}
}