@Experimental public class ChartRepository extends AbstractChartResolver
resolve(String, String)
Modifier and Type | Class and Description |
---|---|
static class |
ChartRepository.Index
A class representing certain of the contents of a Helm
chart repository's
index.yaml file. |
Constructor and Description |
---|
ChartRepository(String name,
URI uri)
Creates a new
ChartRepository whose cached index path will be a Path
relative to the absolute directory represented by the value of
the helm.home system property, or the value of the HELM_HOME environment variable, and bearing a name consisting of
the supplied name suffixed with -index.yaml . |
ChartRepository(String name,
URI uri,
boolean reifyHelmHomeIfNecessary)
Creates a new
ChartRepository whose cached index path will be a Path
relative to the absolute directory represented by the value of
the helm.home system property, or the value of the HELM_HOME environment variable, and bearing a name consisting of
the supplied name suffixed with -index.yaml . |
ChartRepository(String name,
URI uri,
Path cachedIndexPath)
Creates a new
ChartRepository . |
ChartRepository(String name,
URI uri,
Path cachedIndexPath,
boolean reifyHelmHomeIfNecessary)
Creates a new
ChartRepository . |
ChartRepository(String name,
URI uri,
Path archiveCacheDirectory,
Path indexCacheDirectory,
Path cachedIndexPath)
Creates a new
ChartRepository . |
ChartRepository(String name,
URI uri,
Path archiveCacheDirectory,
Path indexCacheDirectory,
Path cachedIndexPath,
boolean reifyHelmHomeIfNecessary)
Creates a new
ChartRepository . |
ChartRepository(String name,
URI uri,
Path archiveCacheDirectory,
Path indexCacheDirectory,
Path cachedIndexPath,
boolean reifyHelmHomeIfNecessary,
Proxy proxy)
Creates a new
ChartRepository . |
ChartRepository(String name,
URI uri,
Path archiveCacheDirectory,
Path indexCacheDirectory,
Path cachedIndexPath,
Proxy proxy)
Creates a new
ChartRepository . |
Modifier and Type | Method and Description |
---|---|
ChartRepository.Index |
clearIndex()
Clears the
ChartRepository.Index stored internally by this ChartRepository , paving the way for a fresh copy to be installed
by the getIndex(boolean) method, and returns the old
value. |
Path |
downloadIndex()
Invokes the
downloadIndexTo(Path, CopyOption...) method
with the return value of the getCachedIndexPath() method
as its first parameter value, and StandardCopyOption.REPLACE_EXISTING as its second parameter
value. |
@Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path |
downloadIndex(CopyOption... copyOptions)
Invokes the
downloadIndexTo(Path, CopyOption...) method
with the return value of the getCachedIndexPath()
method. |
Path |
downloadIndexTo(Path path)
Downloads a copy of the chart repository's
index.yaml file to the Path specified and returns
the canonical representation of the Path to which the
file was actually downloaded. |
@Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path |
downloadIndexTo(Path path,
CopyOption... copyOptions)
Downloads a copy of the chart repository's
index.yaml file to the Path specified and returns
the canonical representation of the Path to which the
file was actually downloaded. |
Path |
getCachedChartPath(String chartName,
String chartVersion)
Given a Helm chart name and its version, returns the local
Path , representing a local copy of the Helm chart as downloaded
from the chart repository represented by this ChartRepository , downloading the archive if necessary, and
replacing any prior copy that may exist. |
@Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path |
getCachedChartPath(String chartName,
String chartVersion,
CopyOption... copyOptions)
Given a Helm chart name and its version, returns the local
Path , representing a local copy of the Helm chart as downloaded
from the chart repository represented by this ChartRepository , downloading the archive if necessary. |
Path |
getCachedIndexPath()
Returns a non-
null , absolute Path to the file that contains or will contain
a copy of the chart repository's index.yaml file. |
ChartRepository.Index |
getIndex()
Returns the
ChartRepository.Index for this ChartRepository . |
ChartRepository.Index |
getIndex(boolean forceDownload)
Returns the
ChartRepository.Index for this ChartRepository . |
@Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") ChartRepository.Index |
getIndex(boolean forceDownload,
CopyOption... copyOptions)
Returns the
ChartRepository.Index for this ChartRepository . |
String |
getName()
Returns the name of this
ChartRepository . |
URI |
getUri()
Returns the
URI of the root of this ChartRepository . |
boolean |
isCachedIndexExpired()
|
ChartRepository.Index |
loadIndex()
Creates a new
ChartRepository.Index from the contents of the cached copy of the chart repository's
index.yaml file and returns it. |
protected InputStream |
openStream(URL url)
Returns an
InputStream corresponding to the supplied
URL . |
ChartOuterClass.Chart.Builder |
resolve(String chartName,
String chartVersion)
Uses the supplied
chartName and chartVersion
parameters to find an appropriate Helm
chart and returns it in the form of a Chart.Builder
object. |
public ChartRepository(String name, URI uri)
ChartRepository
whose cached index path will be a Path
relative to the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of
the supplied name
suffixed with -index.yaml
.name
- the name of this ChartRepository
; must not be
null
uri
- the absolute URI
to the root of this ChartRepository
; must not be null
NullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directoryChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, boolean reifyHelmHomeIfNecessary)
ChartRepository
whose cached index path will be a Path
relative to the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of
the supplied name
suffixed with -index.yaml
.name
- the name of this ChartRepository
; must not be
null
uri
- the absolute URI
to the root of this ChartRepository
; must not be null
reifyHelmHomeIfNecessary
- if true
and, for whatever
reason, the local Helm home directory structure needs to be
partially or entirely created, then this constructor will attempt
to reify itNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directoryChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path cachedIndexPath)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
cachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directoryChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path cachedIndexPath, boolean reifyHelmHomeIfNecessary)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
cachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadreifyHelmHomeIfNecessary
- if true
and, for whatever
reason, the local Helm home directory structure needs to be
partially or entirely created, then this constructor will attempt
to reify itNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directoryChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path archiveCacheDirectory, Path indexCacheDirectory, Path cachedIndexPath)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
archiveCacheDirectory
- an absolute Path
representing a directory where Helm chart
archives may be stored; if null
then a Path
beginning with the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, appended with cache/archive
will be used insteadindexCacheDirectory
- an absolute Path
representing a directory that the supplied
cachedIndexPath
parameter value will be considered to be
relative to; will be ignored and hence may be null
if the supplied cachedIndexPath
parameter
value is absolutecachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directory, or if archiveCacheDirectory
is
non-null
and either empty or not Path.isAbsolute()ChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path archiveCacheDirectory, Path indexCacheDirectory, Path cachedIndexPath, boolean reifyHelmHomeIfNecessary)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
archiveCacheDirectory
- an absolute Path
representing a directory where Helm chart
archives may be stored; if null
then a Path
beginning with the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, appended with cache/archive
will be used insteadindexCacheDirectory
- an absolute Path
representing a directory that the supplied
cachedIndexPath
parameter value will be considered to be
relative to; will be ignored and hence may be null
if the supplied cachedIndexPath
parameter
value is absolutecachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadreifyHelmHomeIfNecessary
- if true
and, for whatever
reason, the local Helm home directory structure needs to be
partially or entirely created, then this constructor will attempt
to reify itNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directory and/or it could not be reified, or if archiveCacheDirectory
is non-null
and either empty or
not Path.isAbsolute()ChartRepository(String, URI, Path, Path, Path, boolean,
Proxy)
,
getName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path archiveCacheDirectory, Path indexCacheDirectory, Path cachedIndexPath, Proxy proxy)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
archiveCacheDirectory
- an absolute Path
representing a directory where Helm chart
archives may be stored; if null
then a Path
beginning with the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, appended with cache/archive
will be used insteadindexCacheDirectory
- an absolute Path
representing a directory that the supplied
cachedIndexPath
parameter value will be considered to be
relative to; will be ignored and hence may be null
if the
supplied cachedIndexPath
parameter value Path.isAbsolute()cachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadproxy
- a Proxy
representing a proxy server used to
establish a connection to the chart repository represented by
this ChartRepository
; may be null
in which case
Proxy.NO_PROXY
will be used insteadNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directorygetName()
,
getUri()
,
getCachedIndexPath()
public ChartRepository(String name, URI uri, Path archiveCacheDirectory, Path indexCacheDirectory, Path cachedIndexPath, boolean reifyHelmHomeIfNecessary, Proxy proxy)
ChartRepository
.name
- the name of this ChartRepository
; must not be
null
uri
- the URI
to the root of this ChartRepository
; must not be null
archiveCacheDirectory
- an absolute Path
representing a directory where Helm chart
archives may be stored; if null
then a Path
beginning with the absolute directory represented by the value of
the helm.home
system property, or the value of the HELM_HOME
environment variable, appended with cache/archive
will be used insteadindexCacheDirectory
- an absolute Path
representing a directory that the supplied
cachedIndexPath
parameter value will be considered to be
relative to; will be ignored and hence may be null
if the
supplied cachedIndexPath
parameter value Path.isAbsolute()cachedIndexPath
- a Path
naming the file that will
store a copy of the chart repository's index.yaml
file;
if null
then a Path
relative to the absolute
directory represented by the value of the helm.home
system property, or the value of the HELM_HOME
environment variable, and bearing a name consisting of the
supplied name
suffixed with -index.yaml
will be
used insteadreifyHelmHomeIfNecessary
- if true
and, for whatever
reason, the local Helm home directory structure needs to be
partially or entirely created, then this constructor will attempt
to reify itproxy
- a Proxy
representing a proxy server used to
establish a connection to the chart repository represented by
this ChartRepository
; may be null
in which case
Proxy.NO_PROXY
will be used insteadNullPointerException
- if either name
or uri
is null
IllegalArgumentException
- if uri
is not absolute, or if there is no existing "Helm
home" directory and/or it could not be reifiedgetName()
,
getUri()
,
getCachedIndexPath()
public final String getName()
ChartRepository
.
This method never returns null
.
null
name of this ChartRepository
public final URI getUri()
URI
of the root of this ChartRepository
.
This method never returns null
.
The URI
returned by this method is guaranteed to be
absolute.
null
, absolute URI
of the root of this ChartRepository
public final Path getCachedIndexPath()
null
, absolute Path
to the file that contains or will contain
a copy of the chart repository's index.yaml
file.
This method never returns null
.
null
, absolute Path
to the file that contains or will contain
a copy of the chart repository's index.yaml
filepublic final ChartRepository.Index getIndex() throws IOException, URISyntaxException
ChartRepository.Index
for this ChartRepository
.
This method never returns null
.
If this method has not been invoked before on this ChartRepository
, then the cached copy of the chart repository's index.yaml
file is parsed into an ChartRepository.Index
and that
ChartRepository.Index
is stored in an instance variable before it is
returned.
If no cached copy of the
chart repository's index.yaml
file exists, then one is downloaded first.
ChartRepository.Index
representing the contents of this ChartRepository
; never null
IOException
- if there was a problem either parsing an
index.yaml
file or downloading itURISyntaxException
- if one of the URIs in the index.yaml
file is invalidgetIndex(boolean, CopyOption...)
,
downloadIndex()
public final ChartRepository.Index getIndex(boolean forceDownload) throws IOException, URISyntaxException
ChartRepository.Index
for this ChartRepository
.
This method never returns null
.
If this method has not been invoked before on this ChartRepository
, then the cached copy of the chart repository's index.yaml
file is parsed into an ChartRepository.Index
and that
ChartRepository.Index
is stored in an instance variable before it is
returned.
If the cached copy of the
chart repository's index.yaml
file has
expired, then one is downloaded
first.
forceDownload
- if true
then no caching will happenChartRepository.Index
representing the contents of this ChartRepository
; never null
IOException
- if there was a problem either parsing an
index.yaml
file or downloading itURISyntaxException
- if one of the URIs in the index.yaml
file is invalidgetIndex(boolean, CopyOption...)
,
downloadIndexTo(Path, CopyOption...)
,
isCachedIndexExpired()
@Issue(id="156", uri="https://github.com/microbean/microbean-helm/issues/156") public final @Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") ChartRepository.Index getIndex(boolean forceDownload, CopyOption... copyOptions) throws IOException, URISyntaxException
ChartRepository.Index
for this ChartRepository
.
This method never returns null
.
If this method has not been invoked before on this ChartRepository
, then the cached copy of the chart repository's index.yaml
file is parsed into an ChartRepository.Index
and that
ChartRepository.Index
is stored in an instance variable before it is
returned.
If the cached copy of the
chart repository's index.yaml
file has
expired, then one is downloaded
first.
forceDownload
- if true
then no caching will happencopyOptions
- any CopyOption
instances that will be
passed to any Files.move(Path, Path, CopyOption...)
invocation that may be necessary; may be null
ChartRepository.Index
representing the contents of this ChartRepository
; never null
IOException
- if there was a problem either parsing an
index.yaml
file or downloading itURISyntaxException
- if one of the URIs in the index.yaml
file is invaliddownloadIndexTo(Path, CopyOption...)
,
isCachedIndexExpired()
public boolean isCachedIndexExpired()
true
if the cached copy of the index.yaml
file is to be considered stale.
The default implementation of this method returns the negation
of the return value of an invocation of the Files.isRegularFile(Path, LinkOption...)
method on the return value of the
getCachedIndexPath()
method.
true
if the cached copy of the index.yaml
file is to be considered stale; false
otherwisegetIndex(boolean)
public final ChartRepository.Index clearIndex()
ChartRepository.Index
stored internally by this ChartRepository
, paving the way for a fresh copy to be installed
by the getIndex(boolean)
method, and returns the old
value.
This method may return null
if #getIndex(boolean)
has not yet been called.
ChartRepository.Index
, or null
public final Path downloadIndex() throws IOException
downloadIndexTo(Path, CopyOption...)
method
with the return value of the getCachedIndexPath()
method
as its first parameter value, and StandardCopyOption.REPLACE_EXISTING
as its second parameter
value.
This method never returns null
.
Path
the Path
to which the index.yaml
file was downloaded; never null
IOException
- if there was a problem downloadingdownloadIndexTo(Path, CopyOption...)
@Issue(id="156", uri="https://github.com/microbean/microbean-helm/issues/156") public final @Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path downloadIndex(CopyOption... copyOptions) throws IOException
downloadIndexTo(Path, CopyOption...)
method
with the return value of the getCachedIndexPath()
method.
This method never returns null
.
copyOptions
- any CopyOption
instances that will be
passed to any Files.move(Path, Path, CopyOption...)
invocations that may be necessary; may be null
Path
the Path
to which the index.yaml
file was downloaded; never null
IOException
- if there was a problem downloadingdownloadIndexTo(Path, CopyOption...)
public Path downloadIndexTo(Path path) throws IOException
index.yaml
file to the Path
specified and returns
the canonical representation of the Path
to which the
file was actually downloaded.
This method never returns null
.
Overrides of this method must not return null
.
The default implementation of this method actually downloads
the index.yaml
file to a temporary
file first, and then renames it, replacing any existing file
with that name.
path
- the Path
to download the index.yaml
file to; may be null
in which case the
return value of the getCachedIndexPath()
method will be
used insteadPath
to the file; never null
IOException
- if there was a problem downloadingdownloadIndexTo(Path, CopyOption...)
@Issue(id="156", uri="https://github.com/microbean/microbean-helm/issues/156") public @Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path downloadIndexTo(Path path, CopyOption... copyOptions) throws IOException
index.yaml
file to the Path
specified and returns
the canonical representation of the Path
to which the
file was actually downloaded.
This method never returns null
.
Overrides of this method must not return null
.
The default implementation of this method actually downloads
the index.yaml
file to a temporary
file first, and then renames it, replacing any existing file
with that name.
path
- the Path
to download the index.yaml
file to; may be null
in which case the
return value of the getCachedIndexPath()
method will be
used insteadcopyOptions
- any CopyOption
instances that will be
passed to an Files.move(Path, Path, CopyOption...)
invocation; may be null
Path
to the file; never null
IOException
- if there was a problem downloadingpublic ChartRepository.Index loadIndex() throws IOException, URISyntaxException
ChartRepository.Index
from the contents of the cached copy of the chart repository's
index.yaml
file and returns it.
This method never returns null
.
Overrides of this method must not return null
.
ChartRepository.Index
; never null
IOException
- if there was a problem reading the fileURISyntaxException
- if a URI in the file was invalidChartRepository.Index.loadFrom(Path)
public final Path getCachedChartPath(String chartName, String chartVersion) throws IOException, URISyntaxException
Path
, representing a local copy of the Helm chart as downloaded
from the chart repository represented by this ChartRepository
, downloading the archive if necessary, and
replacing any prior copy that may exist.
This method may return null
.
chartName
- the name of the chart whose local Path
should be returned; must not be null
chartVersion
- the version of the chart to select; may be
null
in which case "latest" semantics are impliedPath
to the chart archive, or null
IOException
- if there was a problem downloadingURISyntaxException
- if this ChartRepository
's
associated Index
could not
be parsedNullPointerException
- if chartName
is null
getCachedChartPath(String, String, CopyOption...)
@Issue(id="156", uri="https://github.com/microbean/microbean-helm/issues/156") public final @Issue(id="156",uri="https://github.com/microbean/microbean-helm/issues/156") Path getCachedChartPath(String chartName, String chartVersion, CopyOption... copyOptions) throws IOException, URISyntaxException
Path
, representing a local copy of the Helm chart as downloaded
from the chart repository represented by this ChartRepository
, downloading the archive if necessary.
This method may return null
.
chartName
- the name of the chart whose local Path
should be returned; must not be null
chartVersion
- the version of the chart to select; may be
null
in which case "latest" semantics are impliedcopyOptions
- any CopyOption
instances that will be
passed to any Files.move(Path, Path, CopyOption...)
invocations that may be necessary; may be null
Path
to the chart archive, or null
IOException
- if there was a problem downloadingURISyntaxException
- if this ChartRepository
's
associated Index
could not
be parsedNullPointerException
- if chartName
is null
protected InputStream openStream(URL url) throws IOException
InputStream
corresponding to the supplied
URL
.
This method may return null
.
Overrides of this method are permitted to return null
.
url
- the URL
whose affiliated InputStream
should be returned; may be null
in which case null
will be returnedInputStream
appropriate for the supplied
URL
, or null
IOException
- if an error occurs while connecting to the
supplied URL
public ChartOuterClass.Chart.Builder resolve(String chartName, String chartVersion) throws ChartResolverException
chartName
and chartVersion
parameters to find an appropriate Helm
chart and returns it in the form of a Chart.Builder
object.
Implementations of this method may return null
.
This implementation calls the getCachedChartPath(String, String)
method with the supplied
arguments and uses a TapeArchiveChartLoader
to load the
resulting archive into a Chart.Builder
object.
resolve
in class AbstractChartResolver
chartName
- the name of the chart to resolve; must not be
null
chartVersion
- the version of the chart to resolve; may be
null
which normally implies "latest" semanticsChart.Builder
representing a suitable Helm
chart, or null
if no such chart could be foundChartResolverException
- if there was a problem with
resolutionCopyright © 2017–2018, microBean. All rights reserved.