public final class GitConfigSourceBuilder extends AbstractParsableConfigSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>
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 calling Files.createTempFile(String, String, FileAttribute[]) with the prefix helidon-config-git-source-branch - a git branch - a default value is masteroptional - is existence of configuration resource mandatory (by default) or is optional?media-type - configuration content media type to be used to look for appropriate ConfigParser;parser - or directly set ConfigParser 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.
If Git ConfigSource is mandatory and a uri is not responsive or key does not exist
then Source.load() throws ConfigException.
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
GitConfigSourceBuilder.GitEndpoint
Git source endpoint descriptor.
|
| Modifier and Type | Method and Description |
|---|---|
GitConfigSourceBuilder |
branch(String branch)
Sets a git branch to checkout.
|
GitConfigSource |
build()
Builds new instance of
S. |
static GitConfigSourceBuilder |
create(Config metaConfig)
Initializes config source instance from meta configuration properties,
see
ConfigSources.load(Config). |
static GitConfigSourceBuilder |
create(String path)
Creates a builder with mandatory path to the configuration source.
|
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.
|
mediaType, mediaType, parser, parserget, mediaTypeMapping, mediaTypeMapping, parserMapping, parserMappingchangesExecutor, changesExecutor, changesMaxBuffer, changesMaxBuffer, isMandatory, optional, pollingStrategy, pollingStrategy, pollingStrategy, retryPolicy, retryPolicy, thisBuilderpublic static GitConfigSourceBuilder create(String path)
path - a path to the configuration filecreate(Config)public static GitConfigSourceBuilder create(Config metaConfig) throws ConfigMappingException, MissingValueException
ConfigSources.load(Config).
Mandatory properties, see create(String):
path - type Stringproperties: see init(Config).metaConfig - meta-configuration used to initialize returned config source builder instance from.metaConfigMissingValueException - 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.create(String),
init(Config)protected GitConfigSourceBuilder init(Config metaConfig)
Supported configuration properties:
optional - type boolean, see AbstractSource.Builder.optional()polling-strategy - see PollingStrategy for details about configuration format,
see AbstractSource.Builder.pollingStrategy(Supplier) or AbstractSource.Builder.pollingStrategy(Function)media-type-mapping - type Map - key to media type, see AbstractConfigSource.Builder.mediaTypeMapping(Function)media-type - type String, see AbstractParsableConfigSource.Builder.mediaType(String)uri - type URI, see uri(URI)branch - type String, see branch(String)directory - type Path, see directory(Path)init in class AbstractParsableConfigSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint>metaConfig - configuration properties used to initialize a builder instance.protected GitConfigSourceBuilder.GitEndpoint target()
AbstractSource.Buildertarget in class AbstractSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint,ConfigSource>public GitConfigSourceBuilder branch(String branch)
branch - a git branchpublic GitConfigSourceBuilder directory(Path directory)
directory - a local git repositorypublic GitConfigSourceBuilder uri(URI uri)
uri - an uri to the repositorypublic GitConfigSource build()
AbstractSource.BuilderS.build in interface Builder<ConfigSource>build in class AbstractSource.Builder<GitConfigSourceBuilder,GitConfigSourceBuilder.GitEndpoint,ConfigSource>S.Copyright © 2018–2019 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.