spring-cloud / spring-cloud/spring-cloud-config

Support a fallback label if label not found

Open
#1,519 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
2k
Forks
1.3k
Avg merge
2d 59m
Merged PRs (30d)
16

Description

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.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing default-label handling in the composite Git repository configuration and how missing labels are reported. Verify the fallback applies only to the configured repository and is used when the requested label is absent, while other repositories retain the current error behavior; add or update tests for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java, spring
Domain
api, backend, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.