utils

package
v1.9.0-beta.14 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDKey       = "requestid"
	ValidatorKey       = "validator"
	LocalizerKey       = "localizer"
	TokenizerKey       = "tokenizer"
	TokenClaimKey      = "tokenClaim"
	NewrelicContextKey = "newRelicContext"
)
View Source
const (
	NotFoundErrCode     = "404"
	ValidationErrCode   = "509"
	UnexpectedErrCode   = "500"
	UnauthorizedErrCode = "401"
	BodyParserErrCode   = "400"

	NotFoundMsg     = "Not found!"
	UnexpectedMsg   = "An unexpected error has occurred."
	ValidationMsg   = "The given data was invalid."
	UnauthorizedMsg = "Authentication failed."
	BodyParserMsg   = "The given values could not be parsed."

	// App Errors
	FailedToGetAppMsg            = "failed to get app information."
	FailedToGetClusterDetailsMsg = "failed to get cluster details."
	FailedToGetClusterMsg        = "failed to get cluster information."
	FailedToUpdateClusterMsg     = "failed to update cluster information."
	FailedToGetClusterListMsg    = "failed to get cluster list."
	FailedToCreateClusterMsg     = "failed to create cluster."
	FailedToDeleteClusterMsg     = "failed to delete cluster."
	FailedToGetKubeconfigMsg     = "failed to get kubeconfig."
	FailedToDecodeKubeconfigMsg  = "failed to decode kubeconfig."
	FailedToAddNodeMsg           = "failed to add node."
	FailedToGetInstancesMsg      = "failed to get instances."
	FailedToGetNodeGroupsMsg     = "failed to get node groups."
	FailedToGetClusterFlavorMsg  = "failed to get cluster flavor."
	FailedToDeleteNodeGroupMsg   = "failed to delete node group."
)
View Source
const (
	AuthorizationHeaderKey = "Authorization"
)

HTTP Header

View Source
const (
	BearerAuthType = "Bearer"
)

Variables

View Source
var (
	TranslateByTemplateWithContextFunc = TranslateByTemplateWithContext
	TranslateByIDWithContextFunc       = TranslateByIDWithContext
)
View Source
var (
	GenerateUUIDv4Func = GenerateUUIDv4
)

Functions

func DecryptAESGCM

func DecryptAESGCM(key []byte, b64 string) (string, error)

func EncryptAESGCM

func EncryptAESGCM(key []byte, plaintext string) (string, error)

EncryptAESGCM encrypts plaintext with key (32 bytes recommended) and returns base64(nonce|ciphertext).

func GenerateRandomCode

func GenerateRandomCode(seed string, length int) string

func GenerateUUIDv4

func GenerateUUIDv4() string

func GetLanguageWithContext

func GetLanguageWithContext() string

func TranslateByIDWithContext

func TranslateByIDWithContext(ctx context.Context, msgID string) string

func TranslateByTemplateWithContext

func TranslateByTemplateWithContext(ctx context.Context, msgID string, template map[string]interface{}) string

func ValidateWithContext

func ValidateWithContext(ctx context.Context, i interface{}) map[string]string

Types

type ErrorBag

type ErrorBag struct {
	Message string `json:"message"`
	Code    string `json:"code"`
	Cause   error  `json:"cause"`
}

func (ErrorBag) Error

func (e ErrorBag) Error() string

func (ErrorBag) GetCode

func (e ErrorBag) GetCode() string

Jump to

Keyboard shortcuts

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