View Source Bonny.API.CRD (bonny v1.4.0)

A Custom Resource Definition.

The %Bonny.API.CRD{} struct contains the fields group, resource_type, scope and version. New definitions can be created directly, using the new!/1 function.

Summary

Types

Defines the names section of the CRD.

t()

A Custom Resource Definition.

Functions

Build a map of names form the given kind.

Creates a new %Bonny.API.CRD{} struct from the given values. :scope is optional and defaults to :Namespaced.

Converts the internally used structure to a map representing a kubernetes CRD manifest.

Types

@type names_t() :: %{
  :singular => binary(),
  :plural => binary(),
  :kind => binary(),
  optional(:shortNames) => [binary()]
}

Defines the names section of the CRD.

  • plural: name to be used in the URL: /apis/<group>/<version>/<plural> - e.g. crontabs
  • singular: singular name to be used as an alias on the CLI and for display - e.g. crontab
  • kind: is normally the CamelCased singular type. Your resource manifests use this. - e.g. CronTab
  • shortnames: allow shorter string to match your resource on the CLI - e.g. [ct]
@type t() :: %Bonny.API.CRD{
  group: binary(),
  names: names_t(),
  scope: :Namespaced | :Cluster,
  versions: [module()]
}

A Custom Resource Definition.

  • scope: either Namespaced or Cluster
  • group: group name to use for REST API: /apis/<group>/<version>, defaults to the group in config.exs
  • names: see names_t
  • versions: list of API Version modules for this Resource, defaults to the versions in config.exs

Functions

See Map.fetch/2.

See Map.get/3.

Link to this function

get_and_update(term, key, fun)

View Source

See Map.get_and_update/3.

Link to this function

kind_to_names(kind, short_names \\ [])

View Source
@spec kind_to_names(binary(), [binary()]) :: names_t()

Build a map of names form the given kind.

Examples

iex> Bonny.API.CRD.kind_to_names("SomeKind")
%{singular: "somekind", plural: "somekinds", kind: "SomeKind", shortNames: []}

The :inflex library is used to generate the plural form.

iex> Bonny.API.CRD.kind_to_names("Hero")
%{singular: "hero", plural: "heroes", kind: "Hero", shortNames: []}

Accepts an optional list of abbreviations as second argument.

iex> Bonny.API.CRD.kind_to_names("SomeKind", ["sk", "some"])
%{singular: "somekind", plural: "somekinds", kind: "SomeKind", shortNames: ["sk", "some"]}
@spec new!(keyword()) :: t()

Creates a new %Bonny.API.CRD{} struct from the given values. :scope is optional and defaults to :Namespaced.

@spec to_manifest(t()) :: map()

Converts the internally used structure to a map representing a kubernetes CRD manifest.