Skip to content

Commit 1a3646f

Browse files
committed
BUG/MAJOR: spec: mark all names as required to fit in map structured
1 parent c36b85a commit 1a3646f

33 files changed

+203
-72
lines changed

configuration/bind.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,16 @@ func ParseBind(ondiskBind types.Bind) *models.Bind {
214214
}
215215
}
216216
b.Metadata = parseMetadata(ondiskBind.Comment)
217-
b.BindParams = parseBindParams(ondiskBind.Params)
217+
b.BindParams, b.Name = parseBindParams(ondiskBind.Params)
218218
if b.Name == "" {
219219
b.Name = ondiskBind.Path
220220
}
221221
return b
222222
}
223223

224-
func parseBindParams(bindOptions []params.BindOption) models.BindParams { //nolint:gocyclo,cyclop,maintidx,gocognit
224+
func parseBindParams(bindOptions []params.BindOption) (models.BindParams, string) { //nolint:gocyclo,cyclop,maintidx,gocognit
225225
var b models.BindParams
226+
name := ""
226227
for _, p := range bindOptions {
227228
switch v := p.(type) {
228229
case *params.BindOptionDoubleWord:
@@ -302,7 +303,7 @@ func parseBindParams(bindOptions []params.BindOption) models.BindParams { //noli
302303
case *params.BindOptionValue:
303304
switch v.Name {
304305
case "name":
305-
b.Name = v.Value
306+
name = v.Value
306307
case "tcp-ut":
307308
b.TCPUserTimeout = misc.ParseTimeout(v.Value)
308309
case "tcp-md5sig":
@@ -436,7 +437,7 @@ func parseBindParams(bindOptions []params.BindOption) models.BindParams { //noli
436437
}
437438
}
438439
}
439-
return b
440+
return b, name
440441
}
441442

442443
func SerializeBind(b models.Bind, opt *options.ConfigurationOptions) types.Bind {
@@ -457,14 +458,15 @@ func SerializeBind(b models.Bind, opt *options.ConfigurationOptions) types.Bind
457458
bind.Comment = comment
458459
}
459460
bind.Params = serializeBindParams(b.BindParams, bind.Path, opt)
461+
if b.Name != "" {
462+
bind.Params = append(bind.Params, &params.BindOptionValue{Name: "name", Value: b.Name})
463+
}
460464
return bind
461465
}
462466

463467
func serializeBindParams(b models.BindParams, path string, opt *options.ConfigurationOptions) []params.BindOption { //nolint:gocognit,gocyclo,cyclop,maintidx
464468
var options []params.BindOption
465-
if b.Name != "" {
466-
options = append(options, &params.BindOptionValue{Name: "name", Value: b.Name})
467-
} else if path != "" {
469+
if path != "" {
468470
options = append(options, &params.BindOptionValue{Name: "name", Value: path})
469471
}
470472
if b.SslCertificate != "" {

configuration/configuration.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,10 @@ func (s *SectionParser) defaultBind() interface{} {
13761376
}
13771377

13781378
d := data.(*types.DefaultBind)
1379+
bindParams, name := parseBindParams(d.Params)
13791380
return &models.DefaultBind{
1380-
BindParams: parseBindParams(d.Params),
1381+
BindParams: bindParams,
1382+
Name: name,
13811383
}
13821384
}
13831385

configuration/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (c *client) GetDefaultsConfiguration(transactionID string) (int64, *models.
4949

5050
d := &models.Defaults{}
5151
_ = ParseSection(&d.DefaultsBase, parser.Defaults, parser.DefaultSectionName, p)
52-
52+
d.Name = parser.DefaultSectionName
5353
return v, d, nil
5454
}
5555

configuration/global.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func parseRuntimeAPIs(p parser.Parser) ([]*models.RuntimeAPI, error) {
170170
for _, s := range sockets {
171171
p := s.Path
172172
rAPI := &models.RuntimeAPI{Address: &p}
173-
rAPI.BindParams = parseBindParams(s.Params)
173+
rAPI.BindParams, rAPI.Name = parseBindParams(s.Params)
174174
rAPIs = append(rAPIs, rAPI)
175175
}
176176
}

models/bind.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/bind_diff_generated.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/bind_equal_generated.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/bind_params.go

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/bindparams_diff_generated.go

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/bindparams_equal_generated.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)