spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.96k stars 1.29k forks source link

Support a fallback label if label not found #1519

Open marnee01 opened 4 years ago

marnee01 commented 4 years ago

We want to configure a fallback label for a given repo to be used when the label does not exist.

Is your feature request related to a problem? Please describe.

We are implementing a composite repo so that a call to ConfigServer results in a fetch from two repos. There will be one main repo and one supplemental repo with shared configs. When we are doing feature testing, developers will typically create a feature branch in the main repo. It will cause constant confusion that developers will also have to create the same feature branch in the supplemental repo, which will change very infrequently. (In fact, it's not just developers, but QA people and occasionally operations people that will have to know to create this additional feature branch.)

Describe the solution you'd like We'd like something like fallback-label property, similar to default-label config. The default-label is used when no label is provided on the URL. By contrast, the new fallback-label would be used if the label provided on the URL does not exist.

For example, we'd specify fallback-label on our Messaging repo config (near the end of the sample config below):

spring:
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
        -              
          type: git
          uri: ssh://git@bitbucket.pearson.com/~user/{application}.git

          repos:
            Service1:
              pattern: 'Service1/*dev'
              searchPaths: /{application}
              uri: ssh://git@bitbucket.pearson.com/~user/sharedServices.git

            AsyncServices:
              pattern: AsyncService*
              searchPaths:
              - AsyncService/{application}
              - AsyncService/{application}/*
              - AsyncService/{application}/SensorArray/*
              uri: ssh://git@bitbucket.pearson.com/~user/sharedServices.git

        # Shared Messaging Files
        -              
          type: git
          uri: ssh://git@bitbucket.pearson.com/~user/ApplicationPasswords.git

          # Have to put it here, not at the top leve just above. If you specify it just above,
          # the "pattern" is ignored and even those without the messaging profiles will end up causing
          # fetch on the repo.
          repos:
            Messaging:
              pattern: '*/MSG*'
              fallback-label: dev
              uri: ssh://git@bitbucket.pearson.com/~user/rabbitmqconfigs.git
              searchPaths: /*, SharedDomains/*

Describe alternatives you've considered I know if no alternative. I am hoping this is already solvable some way or another. (We do need to apply it only to specific repos, not to every repo. For us, most times, we do want ConfigServer to throw an error if the label does not exist.)

spencergibb commented 4 years ago

Duplicates #617

spencergibb commented 4 years ago

Actually, that's a whole repo not label