hembed

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hembed manages the helm chart embedding mechanism. It is used when the user wants to embed a custom helm chart into the embedded-cluster binary. Writes the chart and adds a mark to the end of the file. The mark is on the format EMBEDDEDCLUSTERCHARTS0000000000 where the number is the length of the embedded data.

Index

Constants

View Source
const (
	// EndMark is a string that is used to mark the end of the binary.
	EndMark = "EMBEDDEDCLUSTERCHARTS"
)

Variables

This section is empty.

Functions

func CalculateRewind

func CalculateRewind(fpath string) (int64, int64, error)

CalculateRewind calculates how far back we need to rewind inside the file to start reading the embedded data. Returns the number of bytes to rewind and the size of the embedded data to be read.

func ReadEmbeddedData

func ReadEmbeddedData(fpath string) ([]byte, error)

ReadEmbeddedData reads the embedded data from the binary. It reads the binary from the disk and looks for a mark at the end of the file. If the mark is found, it reads the data that is embedded in the binary and returns it. The mark is on the format EMBEDDEDCLUSTERCHARTS0000000000 where the number is the length of the embedded data.

Types

type Binary

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

Binary is a helpes struct that holds a closer and a reader separately. Reads happen on the reader and Closes happen on the closer.

func Embed

func Embed(ctx context.Context, fpath string, opts EmbedOptions) (*Binary, error)

Embed embeds helmcharts into the embedded-cluster binary.

func (*Binary) Close

func (b *Binary) Close() error

Close closes the internal closer.

func (*Binary) Read

func (b *Binary) Read(p []byte) (n int, err error)

Read reads from the internal reader.

func (*Binary) Size

func (b *Binary) Size() int64

Size returns the total size of the binary.

type EmbedOptions

type EmbedOptions struct {
	OS     string
	Arch   string
	Charts []HelmChart
}

EmbedOptions are the options for embedding helmcharts into embedded-cluster.

func ReadEmbedOptionsFromBinary

func ReadEmbedOptionsFromBinary(fpath string) (*EmbedOptions, error)

ReadEmbedOptionsFromBinary reads the embedded charts from the binary. It reads the binary from the disk and looks for a mark at the end of the file.

type HelmChart

type HelmChart struct {
	Content string `yaml:"content"`
	Values  string `yaml:"values"`
}

HelmChart represents a helm chart. It has a base64 encoded content. Images that are used by the chart can be passed in the Images field if they need to be pulled for disconnected installs.

func (*HelmChart) ChartReader

func (c *HelmChart) ChartReader() io.Reader

ChartReader returns an io.Reader that can be used to read the contents of the helm chart. Content is decoded from base64.

Jump to

Keyboard shortcuts

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