file

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GivenBundleController

func GivenBundleController(fileName string) (*v1alpha1.PackageBundleController, error)

func GivenPackage

func GivenPackage(fileName string) (*v1alpha1.Package, error)

func GivenPackageBundle

func GivenPackageBundle(filename string) (*v1alpha1.PackageBundle, error)

func MustPackageBundleFromFilename

func MustPackageBundleFromFilename(t *testing.T, filename string) (bundle *v1alpha1.PackageBundle)

MustPackageBundleFromFilename is a helper to load a bundle or fail trying.

It is intended primarily for use in automated tests or utilities.

func ParseByteSlice

func ParseByteSlice(data []byte, clusterConfig KindAccessor) error

Types

type FileReader

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

func NewFileReader

func NewFileReader(fileName string) *FileReader

func (*FileReader) Initialize

func (reader *FileReader) Initialize(clusterConfig KindAccessor) error

func (*FileReader) Parse

func (reader *FileReader) Parse(clusterConfig KindAccessor) error

type KindAccessor

type KindAccessor interface {
	// MetaKind is the kind actually read when unmarshaling from a file.
	MetaKind() string

	// ExpectedKind is the kind we expect to read while unmarshaling.
	ExpectedKind() string
}

KindAccessor exposes the Kind field for Cluster type.

The FileReader will compare the Kind field (accessed via MetaKind()) with the result of ExpectedKind() to ensure that the data we unmarshaled was meant for a struct of the correct type. That is, it prevents us from unmarshaling bytes meant for a Foo struct into a Bar struct.

Jump to

Keyboard shortcuts

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