Documentation ¶
Overview ¶
Package converter provides utilities for converting between various types.
Index ¶
- func SanitizeName(name string) string
- type ContentType
- type Decoder
- func (m *Decoder) AllowUnknownFields(allow bool) *Decoder
- func (m *Decoder) ToBundle() (*bundle.Bundle, error)
- func (m *Decoder) ToBundleBuilder() (*bundle.BundleBuilder, error)
- func (m *Decoder) ToComponent() (*bundle.Component, error)
- func (m *Decoder) ToComponentBuilder() (*bundle.ComponentBuilder, error)
- func (m *Decoder) ToComponentSet() (*bundle.ComponentSet, error)
- func (m *Decoder) ToJSONMap() (map[string]interface{}, error)
- func (m *Decoder) ToObject(obj interface{}) error
- func (m *Decoder) ToUnstructured() (*unstructured.Unstructured, error)
- type Encoder
- type ObjectExporter
- type UnstructuredConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeName ¶ added in v0.4.1
SanitizeName sanitizes a metadata.name field, replacing unsafe characters with _ and truncating if it's longer than 253 characters.
Types ¶
type ContentType ¶ added in v0.5.0
type ContentType string
ContentType for conversion.
var ( // UnknownContent indicates content of unknown type. UnknownContent ContentType // YAML indicates YAML content. YAML ContentType = "yaml" // JSON indicates JSON content. JSON ContentType = "json" )
type Decoder ¶ added in v0.9.0
type Decoder struct {
// contains filtered or unexported fields
}
Decoder converts from an object's serialized format to an actual instance of the object. By default, the Decoder does not allow unknown fields.
func FromContentType ¶ added in v0.5.0
FromContentType takes an explicit content type to use for creating a conversion Decoder.
func FromFileName ¶ added in v0.5.0
FromFileName creates a Decoder instance by guessing the type based on the file extension.
func FromJSONString ¶ added in v0.5.0
FromJSONString creates a Decoder instance from a JSON string.
func FromYAMLString ¶ added in v0.5.0
FromYAMLString creates a Decoder instance from a YAML string.
func (*Decoder) AllowUnknownFields ¶ added in v0.9.0
AllowUnknownFields indicates whether to allow unknown fields during decoding.
func (*Decoder) ToBundleBuilder ¶ added in v0.9.0
func (m *Decoder) ToBundleBuilder() (*bundle.BundleBuilder, error)
ToBundleBuilder converts input data to the BundleBuilder type.
func (*Decoder) ToComponent ¶ added in v0.9.0
ToComponent converts input data to the Component type.
func (*Decoder) ToComponentBuilder ¶ added in v0.9.0
func (m *Decoder) ToComponentBuilder() (*bundle.ComponentBuilder, error)
ToComponentBuilder converts input data to the ComponentBuilder type.
func (*Decoder) ToComponentSet ¶ added in v0.9.0
func (m *Decoder) ToComponentSet() (*bundle.ComponentSet, error)
ToComponentSet converts input data to the ComponentSet type.
func (*Decoder) ToJSONMap ¶ added in v0.9.0
ToJSONMap converts from json/yaml data to a map of string-to-interface.
func (*Decoder) ToObject ¶ added in v0.9.0
ToObject converts to an arbitrary object via standard YAML / JSON serialization.
func (*Decoder) ToUnstructured ¶ added in v0.9.0
func (m *Decoder) ToUnstructured() (*unstructured.Unstructured, error)
ToUnstructured converts input data to the Unstructured type.
type Encoder ¶ added in v0.9.0
type Encoder struct {
// contains filtered or unexported fields
}
Encoder converts from an object to some serialized format for the object.
func FromObject ¶ added in v0.5.0
func FromObject(obj interface{}) *Encoder
FromObject creates a converting encodeer from an object.
func (*Encoder) ToContentType ¶ added in v0.9.0
ToContentType converts to a custom content type.
func (*Encoder) ToJSONString ¶ added in v0.9.0
ToJSONString converts an object to JSON string
func (*Encoder) ToYAMLString ¶ added in v0.9.0
ToYAMLString converts an object to YAML string
type ObjectExporter ¶
type ObjectExporter struct {
Objects []*unstructured.Unstructured
}
ObjectExporter exports cluster objects
func (*ObjectExporter) ExportAsMultiYAML ¶
func (e *ObjectExporter) ExportAsMultiYAML() ([]string, error)
ExportAsMultiYAML converts cluster objects into multiple YAML files.
func (*ObjectExporter) ExportAsYAML ¶
func (e *ObjectExporter) ExportAsYAML() (string, error)
ExportAsYAML converts cluster objects into single YAML file.
type UnstructuredConverter ¶ added in v0.5.0
type UnstructuredConverter struct {
// contains filtered or unexported fields
}
UnstructuredConverter is a converter between unstructured.Unstructured and other types.
func FromUnstructured ¶ added in v0.5.0
func FromUnstructured(o *unstructured.Unstructured) *UnstructuredConverter
FromUnstructured creates an UnstructuredConverter.
func (*UnstructuredConverter) ExtractObjectMeta ¶ added in v0.5.0
func (c *UnstructuredConverter) ExtractObjectMeta() *metav1.ObjectMeta
ExtractObjectMeta creates an ObjectMeta object from an Unstructured object.
func (*UnstructuredConverter) ToObject ¶ added in v0.6.1
func (c *UnstructuredConverter) ToObject(obj interface{}) error
ToObject converts an Unstructured object to an arbitrary interface via JSON.