util

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AppKubernetesComponentName = "app.kubernetes.io/component"
	AppKubernetesInstanceName  = "app.kubernetes.io/instance"
	AppKubernetesNameName      = "app.kubernetes.io/name"
	AppKubernetesManagedByName = "app.kubernetes.io/managed-by"
	AppKubernetesRoleGroupName = "app.kubernetes.io/role-group"

	StackDomain = "zncdata.dev"
)
View Source
const (
	XMLStylesheet = `<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>` + "\n"
)

Variables

View Source
var DefaultRepository = "qury.io/zncdatadev"

Functions

func GenerateRandomStr

func GenerateRandomStr(length int, useLetters bool, useSpecial bool, useNum bool) string

GenerateRandomStr generates a random string of the specified length. The string can contain letters, special characters, and numbers based on the flags provided.

func GenerateSimplePassword added in v0.8.1

func GenerateSimplePassword(length int) string

GenerateSimplePassword generates a simple password of the specified length. The password will contain only letters and numbers.

func Indent2SpacesToTab

func Indent2SpacesToTab(code string) string

func Indent4SpacesToTab

func Indent4SpacesToTab(code string) string

func IndentSpacesToTab

func IndentSpacesToTab(code string, spacesPerTab int) string

IndentSpacesToTab converts leading spaces in a string to tabs, optimized for 2 or 4 spaces per tab.

func IndentTab2Spaces

func IndentTab2Spaces(code string) string

func IndentTab4Spaces

func IndentTab4Spaces(code string) string

func IndentTabToSpaces

func IndentTabToSpaces(code string, spacesPerTab int) string

IndentTabToSpaces converts leading tabs in a string to a specified number of spaces per tab.

func MergeStringMaps added in v0.8.0

func MergeStringMaps(maps ...map[string]string) map[string]string

func NewEnvVarsFromMap added in v0.8.1

func NewEnvVarsFromMap(envs map[string]string) []corev1.EnvVar

func RemoveSpecialCharacter

func RemoveSpecialCharacter(str string) string

RemoveSpecialCharacter - remove special character

Types

type Base64

type Base64[T []byte | string] struct {
	Data T
}

func (Base64[T]) Decode

func (b Base64[T]) Decode() (T, error)

func (Base64[T]) Encode

func (b Base64[T]) Encode() T

type Image added in v0.6.0

type Image struct {
	Custom         string
	Repository     string
	ProductName    string
	StackVersion   string
	ProductVersion string
	PullPolicy     corev1.PullPolicy
	PullSecretName string
}

Image represents a container image Required fields: - ProductName - StackVersion - ProductVersion

If Custom is set, it will be used as the image tag, so the Custom field must be a valid image tag, eg. "myrepo/myimage:latest"

func NewImage added in v0.8.0

func NewImage(
	productName string,
	stackVersion string,
	productVersion string,
	opts ...ImageOption,
) *Image

NewImage creates a new Image object

Example:

image := util.NewImage(
	"myproduct",
	"1.0",
	"1.0.0",
)

image := util.NewImage(
	"myproduct",
	"1.0",
	"1.0.0",
	func (options *util.ImageOptions) {
		options.Custom = "myrepo/myimage:latest"
	}
)

func (*Image) GetImageTag added in v0.6.0

func (i *Image) GetImageTag() string

func (*Image) String added in v0.6.0

func (i *Image) String() string

type ImageOption added in v0.8.0

type ImageOption func(*ImageOptions)

type ImageOptions added in v0.8.0

type ImageOptions struct {
	Custom         string
	Repository     string
	PullPolicy     corev1.PullPolicy
	PullSecretName string
}

type Property added in v0.8.1

type Property struct {
	XMLName     xml.Name `xml:"property"`
	Name        string   `xml:"name"`
	Value       string   `xml:"value"`
	Description string   `xml:"description,omitempty"`
}

type ResourceNameGenerator

type ResourceNameGenerator struct {
	InstanceName string
	RoleName     string
	GroupName    string
}

func NewResourceNameGenerator

func NewResourceNameGenerator(instanceName, roleName, groupName string) *ResourceNameGenerator

NewResourceNameGenerator new a ResourceNameGenerator

func NewResourceNameGeneratorOneRole

func NewResourceNameGeneratorOneRole(instanceName, groupName string) *ResourceNameGenerator

NewResourceNameGeneratorOneRole new a ResourceNameGenerator without roleName

func (*ResourceNameGenerator) GenerateResourceName

func (r *ResourceNameGenerator) GenerateResourceName(extraSuffix string) string

GenerateResourceName generate resource Name

type XMLConfiguration added in v0.8.1

type XMLConfiguration struct {
	Configuration *configuration
	Header        string
}

func NewXMLConfiguration added in v0.8.1

func NewXMLConfiguration() *XMLConfiguration

func NewXMLConfigurationFromMap added in v0.8.1

func NewXMLConfigurationFromMap(properties map[string]string) *XMLConfiguration

func NewXMLConfigurationFromString added in v0.8.1

func NewXMLConfigurationFromString(xmlData string) (*XMLConfiguration, error)

func (*XMLConfiguration) AddPropertiesWithMap added in v0.8.1

func (x *XMLConfiguration) AddPropertiesWithMap(properties map[string]string)

func (*XMLConfiguration) AddProperty added in v0.8.1

func (x *XMLConfiguration) AddProperty(p Property)

func (*XMLConfiguration) AddPropertyWithString added in v0.8.1

func (x *XMLConfiguration) AddPropertyWithString(name, value, description string)

func (*XMLConfiguration) DeleteProperties added in v0.8.1

func (x *XMLConfiguration) DeleteProperties(names ...string)

func (*XMLConfiguration) GetProperty added in v0.8.1

func (x *XMLConfiguration) GetProperty(name string) (Property, bool)

func (*XMLConfiguration) Marshal added in v0.8.1

func (x *XMLConfiguration) Marshal() (string, error)

Jump to

Keyboard shortcuts

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