View Source K8s.Version (k8s v1.1.1)
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
Specs
t() :: %K8s.Version{major: pos_integer(), minor: binary(), patch: pos_integer()}
Link to this section Functions
Specs
Returns only alpha versions
examples
Examples
iex> K8s.Version.alpha(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "alpha", patch: 1}]
Specs
Returns only beta versions
examples
Examples
iex> K8s.Version.beta(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 2, minor: "beta", patch: 1}]
Specs
Retuns all non-stable versions
examples
Examples
iex> K8s.Version.edge(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "alpha", patch: 1}, %K8s.Version{major: 2, minor: "beta", patch: 1}]
Specs
Parses a Kubernetes API version into a K8s.Version
struct
examples
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}
Specs
Returns the recommended version from a list of versions.
It will return the most stable version if any, otherwise the newest "edge" version.
examples
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"
Specs
Returns only stable versions
examples
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"
Specs
Sorts a list of K8s.Version
s
examples
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"]
Specs
Returns only stable versions
examples
Examples
iex> K8s.Version.stable(["v1alpha1", "v1", "v2beta1"])
[%K8s.Version{major: 1, minor: "stable", patch: nil}]