v0

package
v0.5.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// this is used in internal/provider and pkg/threeport-installer to configure
	// the AWS role session name used for cross-account access to AWS resources
	AwsResourceManagerRoleSessionName = "threeport-control-plane"

	// used to query GetProviderRegionForLocation to determine the AWS region
	AwsProvider = "aws"

	// namespace used by the gateway system
	GatewaySystemNamespace = "nukleros-gateway-system"
)

these are constants used throughout the threeport codebase, and may in some cases be placed here to avoid import cycles if placed elsewhere

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(str string) (string, error)

Base64Decode base64 decodes any string.

func Base64Encode

func Base64Encode(str string) string

Base64Encode base64 encodes any string.

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the bool value passed in.

func CreateQueryStringFromMap

func CreateQueryStringFromMap(queryMap map[string]string) string

Given a map of key value pairs, creates a formatted http query string

func DataTypesJsonSliceToUnstructuredList added in v0.5.0

func DataTypesJsonSliceToUnstructuredList(
	input datatypes.JSONSlice[datatypes.JSON],
) ([]*unstructured.Unstructured, error)

DataTypesJsonSliceToUnstructuredList converts a slice of datatypes.JSON objects to a slice of unstructured objects

func DataTypesJsonToUnstructured added in v0.5.0

func DataTypesJsonToUnstructured(input *datatypes.JSON) (*unstructured.Unstructured, error)

DatatypesJsonToUnstructured converts a datatypes.JSON object to an unstructured object

func DerefString added in v0.5.2

func DerefString(s *string) string

DerefString returns the value of a string pointer or an empty string if the pointer is nil.

func GetAge

func GetAge(timestamp *time.Time) *time.Duration

GetAge returns the age of a timestamp, rounded to the nearest second.

func GetObjectFieldValue added in v0.5.0

func GetObjectFieldValue(
	object interface{},
	fieldName string,
) (reflect.Value, error)

GetObjectFieldValue takes a struct object and a field name as a string and returns the value for that field from the struct if it exists. If the value of the field is a nil pointer, the string 'no value' will be returned.

func GetStringPtrValue

func GetStringPtrValue(field reflect.Value) (string, error)

GetStringPtrValue returns the string value of a pointer field.

func HyphenDelimitedString added in v0.4.0

func HyphenDelimitedString(input []string) string

HyphenDelimitedString takes a slice of strings and returns a hyphen delimited string.

func IntPtr added in v0.4.0

func IntPtr(i int) *int

IntPtr returns a pointer to the int value passed in.

func IsNonNilPtr

func IsNonNilPtr(field reflect.Value) bool

IsNonNilPtr returns true if the field is a nil pointer.

func JsonPtr added in v0.5.0

func JsonPtr(j datatypes.JSON) *datatypes.JSON

JsonPtr returns a pointer to the datatypes.JSON value passed in.

func MarshalJSON

func MarshalJSON(mapDef map[string]interface{}) (datatypes.JSON, error)

MarshalJSON marshals a map[string]interface{} into a datatypes.JSON object

func MarshalObject

func MarshalObject(object interface{}) ([]byte, error)

MarshalObject takes an object interface and returns its json byte array.

func NestedInt64OrFloat64 added in v0.4.0

func NestedInt64OrFloat64(input map[string]interface{}, fields ...string) (int64, bool, error)

NestedInt64OrFloat64 returns the int64 value of the nested field in the unstructured object and gracefully handles the case where the value is a float64

func ParseImage

func ParseImage(image string) (string, string, string, error)

ParseImage takes a full image and returns the registry, name and tag values.

func ParseStructTag added in v0.5.0

func ParseStructTag(tagString string) map[string]string

ParseStructTag parses a struct tag string into a map[string]string

func Ptr added in v0.5.0

func Ptr[T any](input T) *T

Ptr returns a pointer to the value passed in.

func RandomAlphaNumericString

func RandomAlphaNumericString(length int) string

RandomAlphaNumericString returns a random string with the provided length using alpha-numeric charcaters.

func RandomAlphaString

func RandomAlphaString(length int) string

RandomAlphaString returns a random string with the provided length using alphabetic charcaters.

func RemoveDataTypesJsonFromDataTypesJsonSlice added in v0.5.0

func RemoveDataTypesJsonFromDataTypesJsonSlice(
	name,
	kind string,
	instances *datatypes.JSONSlice[datatypes.JSON],
) error

RemoveDataTypesJsonFromDataTypesJsonSlice removes a datatypes.JSON object from a slice of datatypes.JSON objects

func Retry

func Retry(
	attemptsMax int,
	waitDurationSeconds int,
	f func() error,
) error

Retry will retry a function until it succeeds or the maximum number of attempts is reached.

func SqlNullInt64 added in v0.5.0

func SqlNullInt64(input *uint) *sql.NullInt64

SqlNullInt64 returns a pointer to a sql.NullInt64 value that represents NULL if the input pointer is nil.

func StringListContains

func StringListContains(value string, input []string) bool

StringListContains returns true if a string is in a list of strings.

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the string value passed in.

func StringPtrToString added in v0.5.0

func StringPtrToString(input *string) string

StringPtrToString converts a string pointer to a string.

func StringSliceContains

func StringSliceContains(sl []string, name string, caseSensitive bool) bool

StringSliceContains returns true if a slice contains a certain string.

func StringToInterfaceList

func StringToInterfaceList(input []string) []interface{}

StringToInterfaceList converts a string slice to an interface slice.

func TimePtr

func TimePtr(t time.Time) *time.Time

TimePtr returns a pointer to the time value passed in.

func TypeName added in v0.5.0

func TypeName(in any) string

TypeName returns the type name of the input.

func UnmarshalJSON

func UnmarshalJSON(marshaledJson datatypes.JSON) (map[string]interface{}, error)

UnmarshalJSON unmarshals a datatypes.JSON object into a map[string]interface{}

func UnmarshalYAML

func UnmarshalYAML(marshaledYaml string) (map[string]interface{}, error)

UnmarshalYAML unmarshals a YAML string into a map[string]interface{}

func UnstructuredListToDatatypesJsonSlice added in v0.5.0

func UnstructuredListToDatatypesJsonSlice(input []*unstructured.Unstructured) (
	datatypes.JSONSlice[datatypes.JSON],
	error,
)

UnstructuredListToDatatypesJsonSlice converts a slice of unstructured objects to a slice of datatypes.JSON objects

func UnstructuredToDatatypesJson added in v0.5.0

func UnstructuredToDatatypesJson(input *unstructured.Unstructured) (datatypes.JSON, error)

UnstructuredToDatatypesJson converts an unstructured object to a datatypes.JSON object

func UnstructuredToYaml added in v0.5.0

func UnstructuredToYaml(input *unstructured.Unstructured) (string, error)

UnstructuredToYaml converts an unstructured object to a yaml string

func UpdateNamespace added in v0.5.0

func UpdateNamespace(jsonDef datatypes.JSON, namespace string) ([]byte, error)

updateNamespace takes the JSON definition for a Kubernetes resource and sets the namespace.

Types

type MultiError

type MultiError struct {
	Errors []error
}

MultiError is an error type that contains multiple errors.

func (*MultiError) AppendError

func (me *MultiError) AppendError(err error)

AppendError adds an error to the MultiError.

func (MultiError) Error

func (me MultiError) Error() error

Error returns a string representation of the MultiError.

type Operation

type Operation struct {
	Name   string
	Create func() error
	Update func() error
	Delete func() error
}

Operation contains a create, update and delete function for a Threeport API object.

type Operations

type Operations struct {
	Operations []*Operation
}

Operations contains a list of operations that have been performed on the Threeport API.

func (*Operations) AppendOperation

func (r *Operations) AppendOperation(operation Operation)

AppendOperation adds a create operation to the operation stack.

func (*Operations) Create

func (r *Operations) Create() error

Create executes all create operations in the operation stack.

func (*Operations) Delete

func (r *Operations) Delete() error

ExecuteUpdateOperations executes all delete operations in the operation stack.

Jump to

Keyboard shortcuts

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