View Source K8s.Version (k8s v2.6.1)
Kubernetes API Versioning
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
Types
@type t() :: %K8s.Version{major: pos_integer(), minor: binary(), patch: pos_integer()}
Functions
Returns only alpha versions
Examples
iex> K8s.Version.alpha(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "alpha", patch: 1}]
Returns only beta versions
Examples
iex> K8s.Version.beta(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 2, minor: "beta", patch: 1}]
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}]
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}
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"
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"
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"]
Returns only stable versions
Examples
iex> K8s.Version.stable(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "stable", patch: nil}]