- 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
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.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 Instance Methods Concrete Methods Modifier and Type Method Description GitConfigSourceBuilderbranch(String branch)Sets a git branch to checkout.GitConfigSourcebuild()Build the instance from this builder.GitConfigSourceBuilderconfig(Config metaConfig)Configure builder from meta configuration.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.GitConfigSourceBuildermediaType(String mediaType)Media type if this is aParsableSourceand explicit media type is configured.GitConfigSourceBuilderparser(ConfigParser parser)A parser if this is aParsableSourceand explicit parser is configured.GitConfigSourceBuilderpath(String path)Configure path to use.GitConfigSourceBuilderpollingStrategy(PollingStrategy pollingStrategy)Configure a polling strategy.GitConfigSourceBuilderuri(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:BuilderBuild the instance from this builder.- Specified by:
buildin 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 falseConfigure to trueif 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 propertiessub 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 propertiessub 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 propertiessub 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:
configin 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:AbstractConfigSourceBuilderA parser if this is aParsableSourceand explicit parser is configured.- Specified by:
parserin interfaceParsableSource.Builder<GitConfigSourceBuilder>- Overrides:
parserin 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:AbstractConfigSourceBuilderMedia type if this is aParsableSourceand explicit media type is configured.- Specified by:
mediaTypein interfaceParsableSource.Builder<GitConfigSourceBuilder>- Overrides:
mediaTypein 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:AbstractSourceBuilderConfigure 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:
pollingStrategyin interfacePollableSource.Builder<GitConfigSourceBuilder>- Overrides:
pollingStrategyin 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 newCredentialsProviderwhich should be used by application.- Parameters:
credentialsProvider- credentials provider- Returns:
- this builder
-
-