Class GitConfigSourceBuilder
- java.lang.Object
-
- io.helidon.config.spi.AbstractSource.Builder<B,T,ConfigSource>
-
- io.helidon.config.spi.AbstractConfigSource.Builder<B,T>
-
- io.helidon.config.spi.AbstractParsableConfigSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>
-
- io.helidon.config.git.GitConfigSourceBuilder
-
- All Implemented Interfaces:
Builder<ConfigSource>
,Supplier<ConfigSource>
public final class GitConfigSourceBuilder extends AbstractParsableConfigSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>
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.If Git ConfigSource is
mandatory
and auri
is not responsive orkey
does not exist thenSource.load()
throwsConfigException
.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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GitConfigSourceBuilder
branch(String branch)
Sets a git branch to checkout.GitConfigSource
build()
Builds new instance ofS
.static GitConfigSourceBuilder
create(Config metaConfig)
Initializes config source instance from meta configuration properties, seeConfigSources.load(Config)
.static GitConfigSourceBuilder
create(String path)
Creates a builder with mandatory path to the configuration source.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.protected GitConfigSourceBuilder
init(Config metaConfig)
Initialize builder from specified configuration properties.protected GitConfigSourceBuilder.GitEndpoint
target()
Returns key source attributes (target).GitConfigSourceBuilder
uri(URI uri)
Sets an uri to the repository.-
Methods inherited from class io.helidon.config.spi.AbstractParsableConfigSource.Builder
mediaType, mediaType, parser, parser
-
Methods inherited from class io.helidon.config.spi.AbstractConfigSource.Builder
get, mediaTypeMapping, mediaTypeMapping, parserMapping, parserMapping
-
Methods inherited from class io.helidon.config.spi.AbstractSource.Builder
changesExecutor, changesExecutor, changesMaxBuffer, changesMaxBuffer, isMandatory, optional, pollingStrategy, pollingStrategy, pollingStrategy, retryPolicy, retryPolicy, thisBuilder
-
-
-
-
Method Detail
-
create
public static GitConfigSourceBuilder create(String path)
Creates a builder with mandatory path to the configuration source.- Parameters:
path
- a path to the configuration file- Returns:
- a new builder
- See Also:
create(Config)
-
create
public static GitConfigSourceBuilder create(Config metaConfig) throws ConfigMappingException, MissingValueException
Initializes config source instance from meta configuration properties, seeConfigSources.load(Config)
.Mandatory
properties
, seecreate(String)
:path
- typeString
properties
: seeinit(Config)
.- Parameters:
metaConfig
- meta-configuration used to initialize returned config source builder instance from.- Returns:
- new instance of config source builder described by
metaConfig
- Throws:
MissingValueException
- in case the configuration tree does not contain all expected sub-nodes required by the mapper implementation to provide instance of Java type.ConfigMappingException
- in case the mapper fails to map the (existing) configuration tree represented by the supplied configuration node to an instance of a given Java type.- See Also:
create(String)
,init(Config)
-
init
protected GitConfigSourceBuilder init(Config metaConfig)
Initialize builder from specified configuration properties.Supported configuration
properties
:optional
- typeboolean
, seeAbstractSource.Builder.optional()
polling-strategy
- seePollingStrategy
for details about configuration format, seeAbstractSource.Builder.pollingStrategy(Supplier)
orAbstractSource.Builder.pollingStrategy(Function)
media-type-mapping
- typeMap
- key to media type, seeAbstractConfigSource.Builder.mediaTypeMapping(Function)
media-type
- typeString
, seeAbstractParsableConfigSource.Builder.mediaType(String)
uri
- typeURI
, seeuri(URI)
branch
- typeString
, seebranch(String)
directory
- typePath
, seedirectory(Path)
- Overrides:
init
in classAbstractParsableConfigSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>
- Parameters:
metaConfig
- configuration properties used to initialize a builder instance.- Returns:
- modified builder instance
-
target
protected GitConfigSourceBuilder.GitEndpoint target()
Description copied from class:AbstractSource.Builder
Returns key source attributes (target).- Overrides:
target
in classAbstractSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint,ConfigSource>
- Returns:
- key source attributes (target).
-
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
-
build
public GitConfigSource build()
Description copied from class:AbstractSource.Builder
Builds new instance ofS
.- Specified by:
build
in interfaceBuilder<ConfigSource>
- Specified by:
build
in classAbstractSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint,ConfigSource>
- Returns:
- new instance of
S
.
-
-