Skip to content

Commit

Permalink
fix version check of plugin config converting
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Nov 30, 2023
1 parent 9e470d6 commit 5f8a1db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/dataplane/kongstate/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (p plugin) toKongPlugin(kongVersion semver.Version) kong.Plugin {
if len(p.Protocols) > 0 {
result.Protocols = kong.StringSlice(p.Protocols...)
}
if p.InstanceName != "" && kongVersion.GT(versions.PluginInstanceNameCutoff) {
if p.InstanceName != "" && kongVersion.GTE(versions.PluginInstanceNameCutoff) {
result.InstanceName = kong.String(p.InstanceName)
}
return result
Expand Down
20 changes: 12 additions & 8 deletions internal/dataplane/kongstate/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestKongPluginFromK8SClusterPlugin(t *testing.T) {
Raw: []byte(`{"header_name": "foo"}`),
},
},
kongVersion: semver.MustParse("3.4.0"),
kongVersion: semver.MustParse("3.2.0"),
},
want: kong.Plugin{
Name: kong.String("correlation-id"),
Expand Down Expand Up @@ -96,8 +96,9 @@ func TestKongPluginFromK8SClusterPlugin(t *testing.T) {
name: "secret configuration",
args: args{
plugin: kongv1.KongClusterPlugin{
Protocols: []kongv1.KongProtocol{"http"},
PluginName: "correlation-id",
Protocols: []kongv1.KongProtocol{"http"},
PluginName: "correlation-id",
InstanceName: "example",
ConfigFrom: &kongv1.NamespacedConfigSource{
SecretValue: kongv1.NamespacedSecretValueFromSource{
Key: "correlation-id-config",
Expand All @@ -109,7 +110,8 @@ func TestKongPluginFromK8SClusterPlugin(t *testing.T) {
kongVersion: semver.MustParse("3.4.0"),
},
want: kong.Plugin{
Name: kong.String("correlation-id"),
Name: kong.String("correlation-id"),
InstanceName: kong.String("example"),
Config: kong.Configuration{
"header_name": "foo",
},
Expand Down Expand Up @@ -223,7 +225,7 @@ func TestKongPluginFromK8SPlugin(t *testing.T) {
Raw: []byte(`{"header_name": "foo"}`),
},
},
kongVersion: semver.MustParse("3.4.0"),
kongVersion: semver.MustParse("3.2.0"),
},
want: kong.Plugin{
Name: kong.String("correlation-id"),
Expand Down Expand Up @@ -266,8 +268,9 @@ func TestKongPluginFromK8SPlugin(t *testing.T) {
Name: "foo",
Namespace: "default",
},
Protocols: []kongv1.KongProtocol{"http"},
PluginName: "correlation-id",
Protocols: []kongv1.KongProtocol{"http"},
PluginName: "correlation-id",
InstanceName: "example",
ConfigFrom: &kongv1.ConfigSource{
SecretValue: kongv1.SecretValueFromSource{
Key: "correlation-id-config",
Expand All @@ -278,7 +281,8 @@ func TestKongPluginFromK8SPlugin(t *testing.T) {
kongVersion: semver.MustParse("3.4.0"),
},
want: kong.Plugin{
Name: kong.String("correlation-id"),
Name: kong.String("correlation-id"),
InstanceName: kong.String("example"),
Config: kong.Configuration{
"header_name": "foo",
},
Expand Down

0 comments on commit 5f8a1db

Please sign in to comment.