Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Now = time.Now
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter struct {
GVK schema.GroupVersionKind
Columns []rescommon.ColumnDefinition
IsCRD bool
JSONPaths map[string]*jsonpath.JSONPath
}
Converter handles the transformation of date/time columns in resources. There are two cases:
CRD Date Columns: For CRDs, columns defined with type `date` are expected by the UI to contain a timestamp, not a duration. We use the associated JSONPath to extract the raw value from the object. This ensures we pass the correct timestamp format to the UI. We do it in the transformer so that we can correctly sort / filter in the SQLite database.
Built-in Date Columns Kubernetes often returns time fields (like "Age") as human-readable durations (e.g., "6h4m"). Storing this static string in the cache is problematic because it becomes stale immediately. For example, if we store "6h4m", an hour later the resource is effectively "7h4m" old, but the cache still serves "6h4m".
To fix this, we parse the duration string, subtract it from the current time to calculate the approximate absolute timestamp, and store that timestamp (in Unix milliseconds). The UI can then use this timestamp to display a live, accurate relative time (e.g., "7 hours ago").
func (*Converter) Transform ¶
func (d *Converter) Transform(obj *unstructured.Unstructured) (*unstructured.Unstructured, error)