openslosdk

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package openslosdk provides utilities for working with openslo.Object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, format ObjectFormat) ([]openslo.Object, error)

Decode reads objects from io.Reader and decodes them, according to the provided ObjectFormat, into a slice of openslo.Object.

func Encode

func Encode(out io.Writer, format ObjectFormat, objects ...openslo.Object) error

Encode writes the provided openslo.Object to io.Writer, according to the provided ObjectFormat.

func FilterByKind

func FilterByKind[T openslo.Object](objects []openslo.Object) []T

FilterByKind filters openslo.Object slice and returns its subset matching the type constraint.

func Validate

func Validate(objects ...openslo.Object) error

Types

type ObjectFormat

type ObjectFormat int

ObjectFormat represents the serialization format of openslo.Object.

const (
	FormatYAML ObjectFormat = iota + 1
	FormatJSON
)

func (ObjectFormat) String

func (f ObjectFormat) String() string

String implements the fmt.Stringer interface.

func (ObjectFormat) Validate

func (f ObjectFormat) Validate() error

Validate checks if ObjectFormat is supported.

type ReferenceExporter added in v0.4.0

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

func NewReferenceExporter added in v0.4.0

func NewReferenceExporter(objects ...openslo.Object) *ReferenceExporter

func (*ReferenceExporter) Export added in v0.4.0

func (r *ReferenceExporter) Export() []openslo.Object

Export replaces all the inlined objects with references and returns the original objects along with the exported, previously inlined, objects.

type ReferenceInliner added in v0.4.0

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

ReferenceInliner is a utility to inline referenced openslo.Object in referencing object(s).

func NewReferenceInliner added in v0.4.0

func NewReferenceInliner(objects ...openslo.Object) *ReferenceInliner

func (*ReferenceInliner) Inline added in v0.4.0

func (r *ReferenceInliner) Inline() ([]openslo.Object, error)

Inline finds all referenced objects in the provided slice of openslo.Object and replaces the references with an inlined version of the referenced openslo.Object. If the referenced object is not found in the provided openslo.Object slice, an error will be returned.

By default, it will not remove referenced objects from the result. If you want to remove referenced objects, you can use the ReferenceInliner.RemoveReferencedObjects option.

func (*ReferenceInliner) RemoveReferencedObjects added in v0.4.0

func (r *ReferenceInliner) RemoveReferencedObjects() *ReferenceInliner

RemoveReferencedObjects instructs ReferenceInliner to remove referenced objects from the result of ReferenceInliner.Inline.

Jump to

Keyboard shortcuts

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