utils

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLimitExceeded is the error returned when a limit was exceeded.
	// Callers will test for ErrLimitExceeded using ==.
	ErrLimitExceeded = errors.New("limit exceeded")
)

Functions

func CreateSecretFromTemplate

func CreateSecretFromTemplate(templateName, secretTemplate string, option string, data map[string]interface{}) (*corev1.Secret, error)

CreateSecretFromTemplate executes the template to create a secret objects, validates and returns it The template needs to be a v1 Secret and in metadata labels and annotations are allowed only Set templateOptions of the "text/template" package to specify the template behavior

func GetSecretDataForTemplate

func GetSecretDataForTemplate(Credential map[string]interface{}, instance map[string]string) map[string]interface{}

func ParseTemplate

func ParseTemplate(templateName, text string) (*template.Template, error)

ParseTemplate create a new template with given name, add allowed sprig functions and parse the template

Types

type LimitedWriter

type LimitedWriter struct {
	W         io.Writer // underlying writer
	N         int64     // max bytes remaining
	Converter func(err error) error
}

A LimitedWriter writes to W but limits the amount of data that can be written to just N bytes. Each call to Write immediately returns ErrLimitExceeded if N <= 0. Otherwise Write writes max N bytes to W and updates N to reflect the new amount remaining. If the number of byte to be written is greater than N, ErrLimitExceeded is returned. Any error from W is returned to the caller of Write, i.e. they have precedence over ErrLimitExceeded.

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (int, error)

Write implements io.Writer

Jump to

Keyboard shortcuts

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