Utility Functions

These functions are useful when writing playbooks that deal with Kubernetes objects:

parse_kubernetes_datetime(k8s_datetime)[source]

Parse a date/time related field in a Kubernetes object and convert it from string to a python datetime object

Return type

datetime

duplicate_without_fields(obj, omitted_fields)[source]

Duplicate a hikaru object, omitting the specified fields

This is useful when you want to compare two versions of an object and first "cleanup" fields that shouldn't be compared.

Parameters
  • obj (HikaruBase) -- A kubernetes object

  • omitted_fields (List[str]) -- List of fields to be omitted. Field name format should be '.' separated For example: ["status", "metadata.generation"]