converter

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package converter provides utilities for converting between various types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeName added in v0.4.1

func SanitizeName(name string) string

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 Demuxer added in v0.5.0

type Demuxer struct {
	// contains filtered or unexported fields
}

Demuxer converts from an object to some serialized format for the object.

func FromObject added in v0.5.0

func FromObject(obj interface{}) *Demuxer

FromObject creates a converting demuxer from an object.

func (*Demuxer) ToContentType added in v0.5.0

func (m *Demuxer) ToContentType(ctype string) ([]byte, error)

ToContentType converts to a custom content type.

func (*Demuxer) ToJSON added in v0.5.0

func (m *Demuxer) ToJSON() ([]byte, error)

ToJSON converts an object to JSON

func (*Demuxer) ToYAML added in v0.5.0

func (m *Demuxer) ToYAML() ([]byte, error)

ToYAML converts an object to YAML

type Muxer added in v0.5.0

type Muxer struct {
	// contains filtered or unexported fields
}

Muxer converts from an object's serialized format to an actual instance of the object.

func FromContentType added in v0.5.0

func FromContentType(ctype string, contents []byte) *Muxer

FromContentType takes an explicit content type to use for creating a conversion Muxer.

func FromFileName added in v0.5.0

func FromFileName(fname string, contents []byte) *Muxer

FromFileName creates a Muxer instance by guessing the type based on the file extension.

func FromJSON added in v0.5.0

func FromJSON(b []byte) *Muxer

FromJSON creates a Muxer instance from a JSON byte array.

func FromJSONString added in v0.5.0

func FromJSONString(s string) *Muxer

FromJSONString creates a Muxer instance from a JSON string.

func FromYAML added in v0.5.0

func FromYAML(b []byte) *Muxer

FromYAML creates a Muxer instance from a YAML byte array.

func FromYAMLString added in v0.5.0

func FromYAMLString(s string) *Muxer

FromYAMLString creates a Muxer instance from a YAML string.

func (*Muxer) ToBundle added in v0.6.0

func (m *Muxer) ToBundle() (*bundle.Bundle, error)

ToBundle converts input data to the Bundle type.

func (*Muxer) ToComponentPackage added in v0.5.0

func (m *Muxer) ToComponentPackage() (*bundle.ComponentPackage, error)

ToComponentPackage converts input data to the ComponentPackage type.

func (*Muxer) ToComponentSet added in v0.5.0

func (m *Muxer) ToComponentSet() (*bundle.ComponentSet, error)

ToComponentSet converts input data to the ComponentSet type.

func (*Muxer) ToObject added in v0.6.1

func (m *Muxer) ToObject(obj interface{}) error

ToObject converts to an arbitrary object via standard YAML / JSON serialization.

func (*Muxer) ToUnstructured added in v0.5.0

func (m *Muxer) ToUnstructured() (*unstructured.Unstructured, error)

ToUnstructured converts input data to the Unstructured type.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL