Skip to content

Commit d8dd9b0

Browse files
authored
Makes Assignments nullable in createpartitions RequestTopic (#758)
1 parent 2d04c4b commit d8dd9b0

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

createpartitions_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,36 @@ func TestClientCreatePartitions(t *testing.T) {
3333
},
3434
ValidateOnly: false,
3535
})
36+
if err != nil {
37+
t.Fatal(err)
38+
}
39+
40+
if err := res.Errors[topic]; err != nil {
41+
t.Error(err)
42+
}
43+
}
44+
45+
func TestClientCreatePartitionsNoAssignments(t *testing.T) {
46+
if !ktesting.KafkaIsAtLeast("1.0.1") {
47+
return
48+
}
49+
50+
client, shutdown := newLocalClient()
51+
defer shutdown()
3652

53+
topic := makeTopic()
54+
createTopic(t, topic, 1)
55+
defer deleteTopic(t, topic)
56+
57+
res, err := client.CreatePartitions(context.Background(), &CreatePartitionsRequest{
58+
Topics: []TopicPartitionsConfig{
59+
{
60+
Name: topic,
61+
Count: 2,
62+
},
63+
},
64+
ValidateOnly: false,
65+
})
3766
if err != nil {
3867
t.Fatal(err)
3968
}

protocol/createpartitions/createpartitions.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (r *Request) Broker(cluster protocol.Cluster) (protocol.Broker, error) {
2323
type RequestTopic struct {
2424
Name string `kafka:"min=v0,max=v1"`
2525
Count int32 `kafka:"min=v0,max=v1"`
26-
Assignments []RequestAssignment `kafka:"min=v0,max=v1"`
26+
Assignments []RequestAssignment `kafka:"min=v0,max=v1,nullable"`
2727
}
2828

2929
type RequestAssignment struct {
@@ -43,6 +43,4 @@ type ResponseResult struct {
4343
ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
4444
}
4545

46-
var (
47-
_ protocol.BrokerMessage = (*Request)(nil)
48-
)
46+
var _ protocol.BrokerMessage = (*Request)(nil)

0 commit comments

Comments
 (0)