utils

package
v0.0.0-...-ad57b4d Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHashCode

func GetHashCode(i interface{}) string

GetHashCode generates hashcode of given type

func GetLastChunkOfSlashed

func GetLastChunkOfSlashed(s string) string

GetLastChunkOfSlashed splits a string by slash and returns the last chunk.

func GetResourceKey

func GetResourceKey(namespace, name string) string

GetResourceKey generates the key in k8s format for a given resource

func ParseResourceID

func ParseResourceID(ID string) (SubscriptionID, ResourceGroup, ResourceName)

ParseResourceID gets subscriptionId, resource group, resource name from resourceID

func ParseSubResourceID

func ParseSubResourceID(ID string) (SubscriptionID, ResourceGroup, ResourceName, ResourceName)

ParseSubResourceID gets subscriptionId, resource group, resource name, sub resource name from resourceID

func PrettyJSON

func PrettyJSON(js []byte, prefix string) ([]byte, error)

PrettyJSON Unmarshals and Marshall again with Indent so it is human readable

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes generates n length random string

func RemoveDuplicateStrings

func RemoveDuplicateStrings(list []string) []string

RemoveDuplicates returns a copy of a slice with duplicates removed

func ResourceGroupID

func ResourceGroupID(subscriptionID SubscriptionID, resourceGroup ResourceGroup) string

ResourceGroupID generates a resource group resource id

func ResourceID

func ResourceID(subscriptionID SubscriptionID, resourceGroup ResourceGroup, provider string, resourceKind string, resourcePath string) string

ResourceID generates a resource id

func Retry

func Retry(totalRetryCount int, retryPause time.Duration, retriableFunction RetriableFunction) (err error)

Retry retries retriableFunction for totalRetryCount times with a gap of retryPause. if retriableFunction returns boolean as false, then Retry will not retry and return error if retriableFunction returns boolean as true, then Retry will retry if fn returned an error if totalRetryCount is -1, then retry happen forever until one of the two above conditions are satisfied.

func SaveToFile

func SaveToFile(fileName string, content []byte) (string, error)

SaveToFile saves the content into a file named "fileName" - a tool primarily used for debugging purposes.

Types

type ResourceGroup

type ResourceGroup string

ResourceGroup is the resource group in which resource is deployed in the resourceID

type ResourceName

type ResourceName string

ResourceName is the resource name in the resourceID

type Retriable

type Retriable bool

Retriable is returned by RetriableFunction and tells whether to retry the function or not.

type RetriableFunction

type RetriableFunction func() (Retriable, error)

RetriableFunction is function that can be retried

type SubscriptionID

type SubscriptionID string

SubscriptionID is the subscription of the resource in the resourceID

type ThreadsafeMultiMap

type ThreadsafeMultiMap interface {
	Insert(key interface{}, value interface{})
	Clear(key interface{})
	Erase(key interface{}) bool
	EraseValue(value interface{}) bool
	ContainsPair(key interface{}, value interface{}) bool
	ContainsValue(value interface{}) bool
}

ThreadsafeMultiMap is a thread safe implementation of a multimap.

func NewThreadsafeMultimap

func NewThreadsafeMultimap() ThreadsafeMultiMap

NewThreadsafeMultimap creates a ThreadsafeMultiMap.

Jump to

Keyboard shortcuts

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