Skip to content

Commit c7beee0

Browse files
committed
fix: populate empty SNIs with an empty array
Kong returns back an empty JSON array instead of a `null` when the SNI array is empty: ``` { "data": [ { "cert": "-truncated-", "created_at": 1584219121, "id": "3e83146b-7139-4306-aa0c-f95ba3a9e315", "key": "-truncated-", "snis": [], "tags": null } ], "next": null } ``` Kong deviates from it's regular behavior of returning a `null`. This causes decK to detect a diff an existing and desired certificate because the two certificates have different empty SNIs, one has an empty array ([]*string{}) while the other is `nil`. This commit populates a nil SNIs field with an empty array. This bug only shows up when there are no SNIs associates with a certificate in Kong. Fix #131
1 parent 86f2849 commit c7beee0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

file/builder.go

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ func (b *stateBuilder) certificates() {
8383
}
8484
}
8585
utils.MustMergeTags(&c.Certificate, b.selectTags)
86+
if c.Certificate.SNIs == nil {
87+
c.Certificate.SNIs = []*string{}
88+
}
8689

8790
b.rawState.Certificates = append(b.rawState.Certificates,
8891
&c.Certificate)

0 commit comments

Comments
 (0)