Class 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 repository
    • uri - an uri to the repository
    • directory - 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 master
    • optional - 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.