github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/cmd/util/zz_generated.options.go (about) 1 // Code generated by github.com/ecordell/optgen. DO NOT EDIT. 2 package util 3 4 import ( 5 defaults "github.com/creasty/defaults" 6 helpers "github.com/ecordell/optgen/helpers" 7 "time" 8 ) 9 10 type GRPCServerConfigOption func(g *GRPCServerConfig) 11 12 // NewGRPCServerConfigWithOptions creates a new GRPCServerConfig with the passed in options set 13 func NewGRPCServerConfigWithOptions(opts ...GRPCServerConfigOption) *GRPCServerConfig { 14 g := &GRPCServerConfig{} 15 for _, o := range opts { 16 o(g) 17 } 18 return g 19 } 20 21 // NewGRPCServerConfigWithOptionsAndDefaults creates a new GRPCServerConfig with the passed in options set starting from the defaults 22 func NewGRPCServerConfigWithOptionsAndDefaults(opts ...GRPCServerConfigOption) *GRPCServerConfig { 23 g := &GRPCServerConfig{} 24 defaults.MustSet(g) 25 for _, o := range opts { 26 o(g) 27 } 28 return g 29 } 30 31 // ToOption returns a new GRPCServerConfigOption that sets the values from the passed in GRPCServerConfig 32 func (g *GRPCServerConfig) ToOption() GRPCServerConfigOption { 33 return func(to *GRPCServerConfig) { 34 to.Address = g.Address 35 to.Network = g.Network 36 to.TLSCertPath = g.TLSCertPath 37 to.TLSKeyPath = g.TLSKeyPath 38 to.MaxConnAge = g.MaxConnAge 39 to.Enabled = g.Enabled 40 to.BufferSize = g.BufferSize 41 to.ClientCAPath = g.ClientCAPath 42 to.MaxWorkers = g.MaxWorkers 43 to.flagPrefix = g.flagPrefix 44 } 45 } 46 47 // DebugMap returns a map form of GRPCServerConfig for debugging 48 func (g GRPCServerConfig) DebugMap() map[string]any { 49 debugMap := map[string]any{} 50 debugMap["Address"] = helpers.DebugValue(g.Address, false) 51 debugMap["Network"] = helpers.DebugValue(g.Network, false) 52 debugMap["TLSCertPath"] = helpers.DebugValue(g.TLSCertPath, false) 53 debugMap["TLSKeyPath"] = helpers.DebugValue(g.TLSKeyPath, false) 54 debugMap["MaxConnAge"] = helpers.DebugValue(g.MaxConnAge, false) 55 debugMap["Enabled"] = helpers.DebugValue(g.Enabled, false) 56 debugMap["BufferSize"] = helpers.DebugValue(g.BufferSize, false) 57 debugMap["ClientCAPath"] = helpers.DebugValue(g.ClientCAPath, false) 58 debugMap["MaxWorkers"] = helpers.DebugValue(g.MaxWorkers, false) 59 return debugMap 60 } 61 62 // GRPCServerConfigWithOptions configures an existing GRPCServerConfig with the passed in options set 63 func GRPCServerConfigWithOptions(g *GRPCServerConfig, opts ...GRPCServerConfigOption) *GRPCServerConfig { 64 for _, o := range opts { 65 o(g) 66 } 67 return g 68 } 69 70 // WithOptions configures the receiver GRPCServerConfig with the passed in options set 71 func (g *GRPCServerConfig) WithOptions(opts ...GRPCServerConfigOption) *GRPCServerConfig { 72 for _, o := range opts { 73 o(g) 74 } 75 return g 76 } 77 78 // WithAddress returns an option that can set Address on a GRPCServerConfig 79 func WithAddress(address string) GRPCServerConfigOption { 80 return func(g *GRPCServerConfig) { 81 g.Address = address 82 } 83 } 84 85 // WithNetwork returns an option that can set Network on a GRPCServerConfig 86 func WithNetwork(network string) GRPCServerConfigOption { 87 return func(g *GRPCServerConfig) { 88 g.Network = network 89 } 90 } 91 92 // WithTLSCertPath returns an option that can set TLSCertPath on a GRPCServerConfig 93 func WithTLSCertPath(tLSCertPath string) GRPCServerConfigOption { 94 return func(g *GRPCServerConfig) { 95 g.TLSCertPath = tLSCertPath 96 } 97 } 98 99 // WithTLSKeyPath returns an option that can set TLSKeyPath on a GRPCServerConfig 100 func WithTLSKeyPath(tLSKeyPath string) GRPCServerConfigOption { 101 return func(g *GRPCServerConfig) { 102 g.TLSKeyPath = tLSKeyPath 103 } 104 } 105 106 // WithMaxConnAge returns an option that can set MaxConnAge on a GRPCServerConfig 107 func WithMaxConnAge(maxConnAge time.Duration) GRPCServerConfigOption { 108 return func(g *GRPCServerConfig) { 109 g.MaxConnAge = maxConnAge 110 } 111 } 112 113 // WithEnabled returns an option that can set Enabled on a GRPCServerConfig 114 func WithEnabled(enabled bool) GRPCServerConfigOption { 115 return func(g *GRPCServerConfig) { 116 g.Enabled = enabled 117 } 118 } 119 120 // WithBufferSize returns an option that can set BufferSize on a GRPCServerConfig 121 func WithBufferSize(bufferSize int) GRPCServerConfigOption { 122 return func(g *GRPCServerConfig) { 123 g.BufferSize = bufferSize 124 } 125 } 126 127 // WithClientCAPath returns an option that can set ClientCAPath on a GRPCServerConfig 128 func WithClientCAPath(clientCAPath string) GRPCServerConfigOption { 129 return func(g *GRPCServerConfig) { 130 g.ClientCAPath = clientCAPath 131 } 132 } 133 134 // WithMaxWorkers returns an option that can set MaxWorkers on a GRPCServerConfig 135 func WithMaxWorkers(maxWorkers uint32) GRPCServerConfigOption { 136 return func(g *GRPCServerConfig) { 137 g.MaxWorkers = maxWorkers 138 } 139 } 140 141 type HTTPServerConfigOption func(h *HTTPServerConfig) 142 143 // NewHTTPServerConfigWithOptions creates a new HTTPServerConfig with the passed in options set 144 func NewHTTPServerConfigWithOptions(opts ...HTTPServerConfigOption) *HTTPServerConfig { 145 h := &HTTPServerConfig{} 146 for _, o := range opts { 147 o(h) 148 } 149 return h 150 } 151 152 // NewHTTPServerConfigWithOptionsAndDefaults creates a new HTTPServerConfig with the passed in options set starting from the defaults 153 func NewHTTPServerConfigWithOptionsAndDefaults(opts ...HTTPServerConfigOption) *HTTPServerConfig { 154 h := &HTTPServerConfig{} 155 defaults.MustSet(h) 156 for _, o := range opts { 157 o(h) 158 } 159 return h 160 } 161 162 // ToOption returns a new HTTPServerConfigOption that sets the values from the passed in HTTPServerConfig 163 func (h *HTTPServerConfig) ToOption() HTTPServerConfigOption { 164 return func(to *HTTPServerConfig) { 165 to.HTTPAddress = h.HTTPAddress 166 to.HTTPTLSCertPath = h.HTTPTLSCertPath 167 to.HTTPTLSKeyPath = h.HTTPTLSKeyPath 168 to.HTTPEnabled = h.HTTPEnabled 169 to.flagPrefix = h.flagPrefix 170 } 171 } 172 173 // DebugMap returns a map form of HTTPServerConfig for debugging 174 func (h HTTPServerConfig) DebugMap() map[string]any { 175 debugMap := map[string]any{} 176 debugMap["HTTPAddress"] = helpers.DebugValue(h.HTTPAddress, false) 177 debugMap["HTTPTLSCertPath"] = helpers.DebugValue(h.HTTPTLSCertPath, false) 178 debugMap["HTTPTLSKeyPath"] = helpers.DebugValue(h.HTTPTLSKeyPath, false) 179 debugMap["HTTPEnabled"] = helpers.DebugValue(h.HTTPEnabled, false) 180 return debugMap 181 } 182 183 // HTTPServerConfigWithOptions configures an existing HTTPServerConfig with the passed in options set 184 func HTTPServerConfigWithOptions(h *HTTPServerConfig, opts ...HTTPServerConfigOption) *HTTPServerConfig { 185 for _, o := range opts { 186 o(h) 187 } 188 return h 189 } 190 191 // WithOptions configures the receiver HTTPServerConfig with the passed in options set 192 func (h *HTTPServerConfig) WithOptions(opts ...HTTPServerConfigOption) *HTTPServerConfig { 193 for _, o := range opts { 194 o(h) 195 } 196 return h 197 } 198 199 // WithHTTPAddress returns an option that can set HTTPAddress on a HTTPServerConfig 200 func WithHTTPAddress(hTTPAddress string) HTTPServerConfigOption { 201 return func(h *HTTPServerConfig) { 202 h.HTTPAddress = hTTPAddress 203 } 204 } 205 206 // WithHTTPTLSCertPath returns an option that can set HTTPTLSCertPath on a HTTPServerConfig 207 func WithHTTPTLSCertPath(hTTPTLSCertPath string) HTTPServerConfigOption { 208 return func(h *HTTPServerConfig) { 209 h.HTTPTLSCertPath = hTTPTLSCertPath 210 } 211 } 212 213 // WithHTTPTLSKeyPath returns an option that can set HTTPTLSKeyPath on a HTTPServerConfig 214 func WithHTTPTLSKeyPath(hTTPTLSKeyPath string) HTTPServerConfigOption { 215 return func(h *HTTPServerConfig) { 216 h.HTTPTLSKeyPath = hTTPTLSKeyPath 217 } 218 } 219 220 // WithHTTPEnabled returns an option that can set HTTPEnabled on a HTTPServerConfig 221 func WithHTTPEnabled(hTTPEnabled bool) HTTPServerConfigOption { 222 return func(h *HTTPServerConfig) { 223 h.HTTPEnabled = hTTPEnabled 224 } 225 }