Skip to content

spring.config.activate.on-cloud-platform should consider NONE to be semantically equivalent to null #38506

Closed as not planned
@osirisOfGit

Description

@osirisOfGit

Apologies if this has been reported before, couldn't find any StackOverflow posts or GitHub issues.

When attempting to use spring.config.activate.on-cloud-platform, there is no mechanism available to simply state "If not running on a cloud platform" without forcibly setting the NONE value via spring.main.cloud-platform through some other mechanism.

return this.onCloudPlatform == null || this.onCloudPlatform == cloudPlatform;

This is undesirable for libraries providing configuration files with default values (e.g. through multi-documents) for scenarios when the consumers is running on a cloud platform and for when they aren't, as it forces one of the following scenarios:

  • Force consumers to specify spring.main.cloud-platform: NONE when running locally (ex: through their application-{local-env-name}.yml)
  • Abandon spring.config.activate.on-cloud-platform and multi-document config files, and conditionally load the properties through custom beans and manual CloudPlatform checks
  • Abandon spring.config.activate.on-cloud-platform and use a different, likely more unreliable, property condition, such as spring.config.activate.on-profile: 'DEV | LOCAL | NO-PLATFORM'

Proposed change:

		private boolean isActive(CloudPlatform cloudPlatform) {
			return this.onCloudPlatform == null 
                                       || (this.onCloudPlatform == NONE && cloudPlatform == null) 
                                       || this.onCloudPlatform == cloudPlatform);
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions