Skip to content

Commit

Permalink
fix: deck content to dbless converter for empty names
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer04 committed Aug 7, 2023
1 parent 9dfe212 commit 84e7c30
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/dataplane/sendconfig/inmemory_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func convertConsumerGroups(dblessConfig *DBLessConfig) {
// ... therefore we need to convert them to relationships...
for _, cg := range dblessConfig.Content.Consumers[i].Groups {
dblessConfig.ConsumerGroupConsumerRelationships = append(dblessConfig.ConsumerGroupConsumerRelationships, ConsumerGroupConsumerRelationship{
ConsumerGroup: *cg.Name,
Consumer: *c.Username,
ConsumerGroup: cg.FriendlyName(),
Consumer: c.FriendlyName(),
})
}
// ... and remove them from the Consumer struct.
Expand All @@ -112,8 +112,8 @@ func convertConsumerGroups(dblessConfig *DBLessConfig) {
// ... therefore we need to convert it to relationships...
if p.ConsumerGroup != nil {
dblessConfig.ConsumerGroupPluginRelationships = append(dblessConfig.ConsumerGroupPluginRelationships, ConsumerGroupPluginRelationship{
ConsumerGroup: *p.ConsumerGroup.Name,
Plugin: *p.Name,
ConsumerGroup: p.ConsumerGroup.FriendlyName(),
Plugin: p.FriendlyName(),
})
}
// ... and remove it from the Plugin struct.
Expand Down
67 changes: 67 additions & 0 deletions internal/dataplane/sendconfig/inmemory_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,73 @@ func TestDefaultContentToDBLessConfigConverter(t *testing.T) {
},
},
},
{
name: "content with consumer group consumers and plugins (only IDs filled)",
content: &file.Content{
ConsumerGroups: []file.FConsumerGroupObject{
{
ConsumerGroup: kong.ConsumerGroup{
Name: kong.String("cg1"),
},
Consumers: []*kong.Consumer{{ID: kong.String("c1")}},
Plugins: []*kong.ConsumerGroupPlugin{{ID: kong.String("p1")}},
},
},
Consumers: []file.FConsumer{
{
Consumer: kong.Consumer{
ID: kong.String("c1"),
},
Groups: []*kong.ConsumerGroup{{ID: kong.String("cg1")}},
},
},
Plugins: []file.FPlugin{
{
Plugin: kong.Plugin{
Name: kong.String("p1"),
ConsumerGroup: &kong.ConsumerGroup{ID: kong.String("cg1")},
},
},
},
},
expectedDBLessConfig: sendconfig.DBLessConfig{
Content: file.Content{
ConsumerGroups: []file.FConsumerGroupObject{
{
ConsumerGroup: kong.ConsumerGroup{
Name: kong.String("cg1"),
},
},
},
Consumers: []file.FConsumer{
{
Consumer: kong.Consumer{
ID: kong.String("c1"),
},
},
},
Plugins: []file.FPlugin{
{
Plugin: kong.Plugin{
ID: kong.String("p1"),
},
},
},
},
ConsumerGroupConsumerRelationships: []sendconfig.ConsumerGroupConsumerRelationship{
{
ConsumerGroup: "cg1",
Consumer: "c1",
},
},
ConsumerGroupPluginRelationships: []sendconfig.ConsumerGroupPluginRelationship{
{
ConsumerGroup: "cg1",
Plugin: "p1",
},
},
},
},
{
name: "content with plugin config nulls",
content: &file.Content{
Expand Down

0 comments on commit 84e7c30

Please sign in to comment.