- java.lang.Object
-
- io.helidon.config.AbstractSourceBuilder<B,U>
-
- io.helidon.config.AbstractConfigSourceBuilder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>
-
- io.helidon.config.git.GitConfigSourceBuilder
-
- All Implemented Interfaces:
Builder<GitConfigSource>
,ParsableSource.Builder<GitConfigSourceBuilder>
,PollableSource.Builder<GitConfigSourceBuilder>
,Source.Builder<GitConfigSourceBuilder>
,Supplier<GitConfigSource>
public final class GitConfigSourceBuilder extends AbstractConfigSourceBuilder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint> implements Builder<GitConfigSource>, PollableSource.Builder<GitConfigSourceBuilder>, ParsableSource.Builder<GitConfigSourceBuilder>
Git ConfigSource builder.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 atry-release
block -- or otherwise make sure that it invokes theGitConfigSource#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 theGitConfigSource.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
andparser
properties must be set to be clear how to parse the content. If both of them are set, thenparser
has precedence.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitConfigSourceBuilder.GitEndpoint
Git source endpoint descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GitConfigSourceBuilder
branch(String branch)
Sets a git branch to checkout.GitConfigSource
build()
Build the instance from this builder.GitConfigSourceBuilder
config(Config metaConfig)
Configure builder from meta configuration.GitConfigSourceBuilder
credentials(String user, String password)
Sets user and password to the repository.GitConfigSourceBuilder
credentialsProvider(org.eclipse.jgit.transport.CredentialsProvider credentialsProvider)
Sets newCredentialsProvider
which should be used by application.GitConfigSourceBuilder
directory(Path directory)
Sets a directory where the repository is cloned or should be cloned.GitConfigSourceBuilder
mediaType(String mediaType)
Media type if this is aParsableSource
and explicit media type is configured.GitConfigSourceBuilder
parser(ConfigParser parser)
A parser if this is aParsableSource
and explicit parser is configured.GitConfigSourceBuilder
path(String path)
Configure path to use.GitConfigSourceBuilder
pollingStrategy(PollingStrategy pollingStrategy)
Configure a polling strategy.GitConfigSourceBuilder
uri(URI uri)
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 Detail
-
path
public GitConfigSourceBuilder path(String path)
Configure path to use.- Parameters:
path
- path to the configuration file- Returns:
- updated builder instance
-
build
public GitConfigSource build()
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<GitConfigSource>
- Returns:
- instance of the built type
-
config
public GitConfigSourceBuilder config(Config metaConfig)
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
public GitConfigSourceBuilder parser(ConfigParser 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
public GitConfigSourceBuilder mediaType(String 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
public GitConfigSourceBuilder pollingStrategy(PollingStrategy 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
public GitConfigSourceBuilder branch(String branch)
Sets a git branch to checkout.- Parameters:
branch
- a git branch- Returns:
- this builder
-
directory
public GitConfigSourceBuilder directory(Path directory)
Sets a directory where the repository is cloned or should be cloned.- Parameters:
directory
- a local git repository- Returns:
- this builder
-
uri
public GitConfigSourceBuilder uri(URI uri)
Sets an uri to the repository.- Parameters:
uri
- an uri to the repository- Returns:
- this builder
-
credentials
public GitConfigSourceBuilder credentials(String user, String password)
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
-
-