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
GitConfigSourcewhile 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 ismasteroptional- 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 setConfigParserinstance to be used to parse the source;
The application should invoke the builder's
buildmethod in atry-releaseblock -- or otherwise make sure that it invokes theGitConfigSource#closemethod -- 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
mandatoryand auriis not responsive orkeydoes not exist thenSource.load()throwsConfigException.One of
media-typeandparserproperties must be set to be clear how to parse the content. If both of them are set, thenparserhas precedence.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGitConfigSourceBuilder.GitEndpointGit source endpoint descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GitConfigSourceBuilderbranch(String branch)Sets a git branch to checkout.GitConfigSourcebuild()Builds new instance ofS.static GitConfigSourceBuildercreate(Config metaConfig)Initializes config source instance from meta configuration properties, seeConfigSources.load(Config).static GitConfigSourceBuildercreate(String path)Creates a builder with mandatory path to the configuration source.GitConfigSourceBuildercredentials(String user, String password)Sets user and password to the repository.GitConfigSourceBuildercredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider credentialsProvider)Sets newCredentialsProviderwhich should be used by application.GitConfigSourceBuilderdirectory(Path directory)Sets a directory where the repository is cloned or should be cloned.protected GitConfigSourceBuilderinit(Config metaConfig)Initialize builder from specified configuration properties.protected GitConfigSourceBuilder.GitEndpointtarget()Returns key source attributes (target).GitConfigSourceBuilderuri(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- seePollingStrategyfor 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:
initin 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.BuilderReturns key source attributes (target).- Overrides:
targetin 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 newCredentialsProviderwhich should be used by application.- Parameters:
credentialsProvider- credentials provider- Returns:
- this builder
-
build
public GitConfigSource build()
Description copied from class:AbstractSource.BuilderBuilds new instance ofS.- Specified by:
buildin interfaceBuilder<ConfigSource>- Specified by:
buildin classAbstractSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint,ConfigSource>- Returns:
- new instance of
S.
-
-