- All Implemented Interfaces:
Builder<GitConfigSourceBuilder,
,GitConfigSource> ParsableSource.Builder<GitConfigSourceBuilder>
,PollableSource.Builder<GitConfigSourceBuilder>
,Source.Builder<GitConfigSourceBuilder>
,Supplier<GitConfigSource>
Creates a GitConfigSource
while allowing the application to the following properties:
path
- a relative path to the configuration file in repositoryuri
- an uri to the repositorydirectory
- a directory with a cloned repository - by default it is a temporary dir created by callingFiles.createTempFile(String, String, FileAttribute[])
with the prefixhelidon-config-git-source-
branch
- a git branch - a default value ismaster
optional
- is existence of configuration resource mandatory (by default) or isoptional
?media-type
- configuration content media type to be used to look for appropriateConfigParser
;parser
- or directly setConfigParser
instance to be used to parse the source;
The application should invoke the builder's build
method in a
try-release
block -- or otherwise make sure that it invokes the
GitConfigSource#close
method -- to clean up the config source when the
application no longer needs it.
If the directory is not set, a temporary directory is created (see Files.createTempDirectory(String, FileAttribute[])
.
The temporary file is cleaned up by the GitConfigSource.close()
method).
A specified directory, that is not empty, must be a valid git repository, otherwise an exception is thrown.
If the directory nor the uri is not set, an exception is thrown.
One of media-type
and parser
properties must be set to be clear how to parse the content. If both of them
are set, then parser
has precedence.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Git source endpoint descriptor. -
Method Summary
Modifier and TypeMethodDescriptionSets a git branch to checkout.build()
Build the instance from this builder.Configure builder from meta configuration.credentials
(String user, String password) Sets user and password to the repository.credentialsProvider
(org.eclipse.jgit.transport.CredentialsProvider credentialsProvider) Sets newCredentialsProvider
which should be used by application.Sets a directory where the repository is cloned or should be cloned.Media type if this is aParsableSource
and explicit media type is configured.parser
(ConfigParser parser) A parser if this is aParsableSource
and explicit parser is configured.Configure path to use.pollingStrategy
(PollingStrategy pollingStrategy) Configure a polling strategy.Sets an uri to the repository.Methods inherited from class io.helidon.config.AbstractConfigSourceBuilder
mediaTypeMapping, parserMapping
Methods inherited from class io.helidon.config.AbstractSourceBuilder
changeWatcher, optional, retryPolicy
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.config.spi.PollableSource.Builder
pollingStrategy
Methods inherited from interface io.helidon.config.spi.Source.Builder
optional, optional, retryPolicy
-
Method Details
-
path
Configure path to use.- Parameters:
path
- path to the configuration file- Returns:
- updated builder instance
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<GitConfigSourceBuilder,
GitConfigSource> - Returns:
- instance of the built type
-
config
Configure builder from meta configuration.The following configuration options are supported:
Optional configuration parameters key default value description optional false
Configure to true
if this source should not fail configuration setup when underlying data is missing.polling-strategy No polling strategy is added by default Meta configuration of a polling strategy to be used with this source, add configuration to properties
sub node.change-watcher No change watcher is added by default Meta configuration of a change watcher to be used with this source, add configuration to properties
sub node.retry-policy No retry policy is added by default Meta configuration of a retry policy to be used to load this source, add configuration to properties
sub node.Media type and type mapping media-type Media type from loaded data is used by default for parsable config sources Explicit media type to use, such as when a file has invalid suffix, or when we need to explicitly mark the media type. media-type-mapping No media type mapping is done by default A mapping of key to a media type, allowing us to have a key that contains a sub-tree (e.g. a key that contains json data) - when we configure a mapping of the key to application/json
, the data would be expanded into config as a proper tree structurepath
- typeString
, seepath(String)
uri
- typeURI
, seeuri(URI)
branch
- typeString
, seebranch(String)
directory
- typePath
, seedirectory(Path)
- Overrides:
config
in classAbstractConfigSourceBuilder<GitConfigSourceBuilder,
GitConfigSourceBuilder.GitEndpoint> - Parameters:
metaConfig
- configuration properties used to initialize a builder instance.- Returns:
- modified builder instance
-
parser
Description copied from class:AbstractConfigSourceBuilder
A parser if this is aParsableSource
and explicit parser is configured.- Specified by:
parser
in interfaceParsableSource.Builder<GitConfigSourceBuilder>
- Overrides:
parser
in classAbstractConfigSourceBuilder<GitConfigSourceBuilder,
GitConfigSourceBuilder.GitEndpoint> - Parameters:
parser
- parser configured for this source- Returns:
- updated builder instance
-
mediaType
Description copied from class:AbstractConfigSourceBuilder
Media type if this is aParsableSource
and explicit media type is configured.- Specified by:
mediaType
in interfaceParsableSource.Builder<GitConfigSourceBuilder>
- Overrides:
mediaType
in classAbstractConfigSourceBuilder<GitConfigSourceBuilder,
GitConfigSourceBuilder.GitEndpoint> - Parameters:
mediaType
- media type configured for this source- Returns:
- updated builder instance
-
pollingStrategy
Description copied from class:AbstractSourceBuilder
Configure a polling strategy. This method must be exposed by builders of sources that support polling. If you see this method as being protected in your builder, the source has removed support for polling, such asClasspathConfigSource
.- Specified by:
pollingStrategy
in interfacePollableSource.Builder<GitConfigSourceBuilder>
- Overrides:
pollingStrategy
in classAbstractSourceBuilder<GitConfigSourceBuilder,
GitConfigSourceBuilder.GitEndpoint> - Parameters:
pollingStrategy
- polling strategy to use- Returns:
- updated builder instance
-
branch
Sets a git branch to checkout.- Parameters:
branch
- a git branch- Returns:
- this builder
-
directory
Sets a directory where the repository is cloned or should be cloned.- Parameters:
directory
- a local git repository- Returns:
- this builder
-
uri
Sets an uri to the repository.- Parameters:
uri
- an uri to the repository- Returns:
- this builder
-
credentials
Sets user and password to the repository.- Parameters:
user
- user to the repositorypassword
- password to the repository- Returns:
- this builder
-
credentialsProvider
public GitConfigSourceBuilder credentialsProvider(org.eclipse.jgit.transport.CredentialsProvider credentialsProvider) Sets newCredentialsProvider
which should be used by application.- Parameters:
credentialsProvider
- credentials provider- Returns:
- this builder
-