Hi, here is a use case that needs to provision the repo credential via Github Apps, which results in that the generated token will expire in one hour. Therefore, I am wondering if there is an approach to inject the credential dynamically?

Taking the configuration as an example from below, the GITHUB_INSTALLATION_TOKEN is the field will expire.

spring:
  cloud:
    config:
      server:
        git:
          uri: https://dummy-link.git
          clone-on-start: true
          ignoreLocalSshSettings: true
          username: ${GITHUB_INSTALLATION_TOKEN}
          password: ${GITHUB_INSTALLATION_TOKEN}

Thanks in advance

Comment From: zailushangde

it is achieved by specifying the custom EnvironmentRepository bean

@Configuration
class CustomeRepoConfiguration(
    environment: ConfigurableEnvironment, 
    properties: JGitEnvironmentProperties, 
    credentialUpdater: CredentialUpdater) : JGitEnvironmentRepository(environment, properties) {

    override fun getUsername(): String = credentialUpdater.getFreshCredential()
    override fun getPassword(): String = credentialUpdater.getFreshCredential()
}

then, Spring will pick up the custom bean instead of

@Configuration
@ConditionalOnMissingBean(value = EnvironmentRepository.class, search = SearchStrategy.CURRENT)
class DefaultRepositoryConfiguration {
    ...
}