Skip to content

Commit

Permalink
adding discovered value to properties whose value mathes the service …
Browse files Browse the repository at this point in the history
…discovery pattern
  • Loading branch information
dmartinol committed Feb 2, 2024
1 parent 4d0afe8 commit 612766f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions controllers/profiles/common/properties/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ func Test_appPropertyHandler_WithUserPropertiesWithServiceDiscovery(t *testing.T
assert.Equal(t, 21, len(generatedProps.Keys()))
assert.NotContains(t, "property1", generatedProps.Keys())
assert.NotContains(t, "property2", generatedProps.Keys())
defaultService := "http://localhost:8080"
assertHasProperty(t, generatedProps, "service1", defaultService)
assertHasProperty(t, generatedProps, "service2", defaultService)
assertHasProperty(t, generatedProps, "service3", defaultService)
assertHasProperty(t, generatedProps, "service4", defaultService)
assertHasProperty(t, generatedProps, "service5", defaultService)
assertHasProperty(t, generatedProps, "broker1", defaultService)
assertHasProperty(t, generatedProps, "broker2", defaultService)
assertHasProperty(t, generatedProps, "service1", myService1Address)
assertHasProperty(t, generatedProps, "service2", myService2Address)
assertHasProperty(t, generatedProps, "service3", myKnService1Address)
assertHasProperty(t, generatedProps, "service4", myKnService2Address)
assertHasProperty(t, generatedProps, "service5", myKnService3Address)
assertHasProperty(t, generatedProps, "broker1", myKnBroker1Address)
assertHasProperty(t, generatedProps, "broker2", myKnBroker2Address)

//org.kie.kogito.addons.discovery.kubernetes\:services.v1\/usecase1º/my-service1 below we use the unescaped vale because the properties.LoadString removes them.
assertHasProperty(t, generatedProps, "org.kie.kogito.addons.discovery.kubernetes:services.v1/namespace1/my-service1", myService1Address)
Expand Down
3 changes: 2 additions & 1 deletion controllers/profiles/common/properties/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func generateDiscoveryProperties(ctx context.Context, catalog discovery.ServiceC
mpProperty := generateMicroprofileServiceCatalogProperty(plainUri)
klog.V(log.I).Infof("Generating microprofile service catalog property %s=%s.", mpProperty, address)
result.MustSet(mpProperty, address)
result.MustSet(k, "http://localhost:8080")
klog.V(log.I).Infof("Overriding the discoverable value as the managed property %s=%s.", k, address)
result.MustSet(k, address)
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions controllers/profiles/common/properties/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ func Test_generateDiscoveryProperties(t *testing.T) {
})

assert.Equal(t, 8, result.Len())
defaultService := "http://localhost:8080"
assertHasProperty(t, result, "service1", defaultService)
assertHasProperty(t, result, "service2", defaultService)
assertHasProperty(t, result, "service3", defaultService)
assertHasProperty(t, result, "service1", myService1Address)
assertHasProperty(t, result, "service2", myService2Address)
assertHasProperty(t, result, "service3", myService3Address)
assertHasProperty(t, result, "org.kie.kogito.addons.discovery.kubernetes\\:services.v1\\/namespace1\\/my-service1", myService1Address)
assertHasProperty(t, result, "org.kie.kogito.addons.discovery.kubernetes\\:services.v1\\/namespace1\\/my-service1", myService1Address)
assertHasProperty(t, result, "org.kie.kogito.addons.discovery.kubernetes\\:services.v1\\/namespace1\\/my-service1", myService1Address)
Expand Down

0 comments on commit 612766f

Please sign in to comment.