k8s v0.2.8 K8s.Version
Kubernetes API Versioning
Link to this section Summary
Functions
Returns only alpha versions
Returns only beta versions
Retuns all non-stable versions
Parses a Kubernetes API version into a K8s.Version
struct
Returns the recommended version from a list of versions.
Returns only stable versions
Sorts a list of K8s.Version
s
Returns only stable versions
Link to this section Types
Link to this type
t()
t()
t() :: %K8s.Version{major: pos_integer(), minor: binary(), patch: pos_integer()}
t() :: %K8s.Version{major: pos_integer(), minor: binary(), patch: pos_integer()}
Link to this section Functions
Link to this function
alpha(versions)
alpha(versions)
alpha([binary()]) :: [K8s.Version.t()]
alpha([binary()]) :: [K8s.Version.t()]
Returns only alpha versions
Examples
iex> K8s.Version.alpha(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "alpha", patch: 1}]
Link to this function
beta(versions)
beta(versions)
beta([binary()]) :: [K8s.Version.t()]
beta([binary()]) :: [K8s.Version.t()]
Returns only beta versions
Examples
iex> K8s.Version.beta(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 2, minor: "beta", patch: 1}]
Link to this function
edge(versions)
edge(versions)
edge([binary()]) :: [K8s.Version.t()]
edge([binary()]) :: [K8s.Version.t()]
Retuns all non-stable versions
Examples
iex> K8s.Version.edge(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "alpha", patch: 1}, %K8s.Version{major: 2, minor: "beta", patch: 1}]
Link to this function
parse(version)
parse(version)
parse(binary()) :: K8s.Version.t()
parse(binary()) :: K8s.Version.t()
Parses a Kubernetes API version into a K8s.Version
struct
Examples
iex> K8s.Version.parse("v1")
%K8s.Version{major: 1, minor: "stable", patch: nil}
iex> K8s.Version.parse("v1beta2")
%K8s.Version{major: 1, minor: "beta", patch: 2}
iex> K8s.Version.parse("v1alpha1")
%K8s.Version{major: 1, minor: "alpha", patch: 1}
Link to this function
recommended(versions)
Returns the recommended version from a list of versions.
It will return the most stable version if any, otherwise the newest "edge" version.
Examples
iex> K8s.Version.recommended(["v1beta1", "v1", "v2"])
"v2"
iex> K8s.Version.recommended(["v1beta1", "v1"])
"v1"
iex> K8s.Version.recommended(["v1beta2", "v1beta1"])
"v1beta2"
iex> K8s.Version.recommended(["v1alpha1", "v1alpha2", "v1beta1"])
"v1beta1"
Link to this function
serialize(version)
serialize(version)
serialize(K8s.Version.t()) :: binary()
serialize(K8s.Version.t()) :: binary()
Returns only stable versions
Examples
iex> K8s.Version.serialize(%K8s.Version{major: 1, minor: "stable", patch: nil})
"v1"
iex> K8s.Version.serialize(%K8s.Version{major: 1, minor: "beta", patch: 1})
"v1beta1"
iex> K8s.Version.serialize(%K8s.Version{major: 1, minor: "alpha", patch: 1})
"v1alpha1"
Link to this function
sort(versions)
Sorts a list of K8s.Version
s
Examples
iex> raw_versions = Enum.shuffle(["v1", "v2beta1", "v2", "v1alpha1", "v1alpha2"])
iex> versions = raw_versions |> Enum.map(&(K8s.Version.parse(&1)))
iex> sorted_versions = versions |> K8s.Version.sort()
iex> sorted_versions |> Enum.map(&(K8s.Version.serialize(&1)))
["v2", "v1", "v2beta1", "v1alpha2", "v1alpha1"]
Link to this function
stable(versions)
stable(versions)
stable([binary()]) :: [K8s.Version.t()]
stable([binary()]) :: [K8s.Version.t()]
Returns only stable versions
Examples
iex> K8s.Version.stable(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "stable", patch: nil}]