-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudFoundry Configuration - Service credentials empty #1332
Comments
Hi @szaboegon, The code you've shared generally looks correct, can you share how you're inspecting the options instance? (eg: remotely debugging app in CF vs app running locally that sets VCAP manually or something else). It may be useful to have a minimal but running application that demonstrates the problem if you have time. In case this is useful, unit tests for CloudFoundryServiceOptions are here |
Hi @TimHess, I am using remote debugging to inspect the options, so the app is deployed to CloudFoundry when inspecting. As for the application: I cannot share the original, but I created a new sample ASP.NET project and the issue still stands. I attached the code below. |
OK, that makes sense - thanks for sharing the sample, I believe I see what you're seeing. I think that both the null fields and the seemingly empty credentials are side affects of the generic and recursive data structure used in Can we back up a step and discuss what you're trying to accomplish? |
I checked the sample and I don't really see any differences between that and my usage. Originally I wanted to use my own options classes with the I could get the values via manually parsing the Configuration, but I want to avoid that at all costs, because it is not typed and hard to maintain in my opinion. So I definitely want to use the Options framework somehow. |
The difference is subtle, but important. I understand that you are trying to get credentials out of configuration, but can you please be more specific? We built (and in v4 completely re-built) Connectors to handle the complexity of the generic structures and make it more easily consumable for specific services. Steeltoe tries to create situations where your apps benefit from platform features like Additionally, |
Specifically, my use case is that I want to connect to a MySQL server that is hosted outside of CloudFoundry. For this I am using user-provided services as stated here in the CloudFoundry docs. Now that I have looked at connectors they really seem a lot easier to use, but It doesn't quite fit my use case. I tried, but it seems like it cannot find the service by name. I'm guessing this is because of the user-provided aspect. It is interesting, that you are considering the removal of the Is there any way I can make the package work with user-provided services or should I look into other solutions? |
User-provided services in general are difficult to support since they could contain just about anything, therefore the structure is nearly as general as what In this case all you should need to do is add the tag "mysql" and use the same keys Steeltoe is looking for. Here's the credential mapping in v4. For v3, the mapping is here - please note the check for a Uri setting (I don't know offhand why it's there, but it's been that way for years at this point) |
I added the tag like you said, but the connector still does not seem to find the service instance. This is what the VCAP_SERVICES env variable looks like:
My code in ASP.NET:
The connector throws an exception saying On another note: is v4 released already? As I cannot find it in the Nuget Package Manager or the documentation either. |
AH! Sorry for the confusion here, it's been a while since I looked at this code, and it really is too complex... The reason the code checks for the existence of Why would we do that? Because (afaik) all of the MySQL brokers ever created for Cloud Foundry set the Uri consistently, but not the other properties... Steeltoe v4 has not quite shipped yet, but we are extremely close to public previews on nuget.org (the last API review PR is in progress right now, so we might be done with planned breaking changes as soon as this week). Work on the samples is happening in the |
Question
I have a problem when using the Steeltoe.Extensions.Configuration.CloudFoundryCore package in ASP.NET.
There is a service bound to my application. The applications environment section describing the services looks like this:
I initialize the configuration provider and configure the options classes in my Program.cs as shown in the documentation:
After that I resolve the CloudFoundryServicesOptions in my service class from the service provider - so far everything works as expected.
However upon inspection I found that the options instance contains the following:
As you can see all the credential fields are empty when they shouldn't be according to the environment variables. Also the structure of the second JSON looks weird to me, especially all the null fields at the root level.
I tried everything but I don't know what causes this when I'm doing everything right according to the documentation.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: