Currenlty the CloudPlatform auto-detection (used by the onCloudPlatformCondition) relies on environment properties detection. In some cases, like Kubernetes, we're strictly looking for environment variables, which are hard to mock for tests purposes.

This issue should introduce a new spring.main.cloud-platform configuration property for overriding the auto-detection and forcing a particular cloud platform.

Comment From: bclozel

This change has been reverted in 05db46951d.

Comment From: wilkinsona

We've decided to proceed with this after all. See https://github.com/spring-projects/spring-boot/issues/20620 for some additional context.

Comment From: bclozel

We should not revert back to the initial commit, since we'd like to expand the initial intent.

We'd like to bind that property to the enum listing all supported Cloud Platforms, including a NONE. This NONE value could be useful in case the application is deployed in an environment that has a env property that triggers the detection of a particular Cloud Platform, even if this is a false positive.

With that property, could then allow developers: * to force a particular platform (for development purposes or production if auto-detection fails) * to disable detection in case of false positives

Comment From: wind57

I really like the argument towards spring.main.cloud-platform for testing purposes. The linked issue above will take a big advantage out of that. Thank you for bringing this up and providing that option.