util

package
v1.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alternate

func Alternate(tree map[string][]string, algorithm string) ([]string, error)

Alternate : inverts the order given by a Topology Sorting algorithm (e.g., Kahn, Tarjan). Example: [1, N-1, 2, N-2, ...] (element indices)

func AlternateKahn

func AlternateKahn(tree map[string][]string) ([]string, error)

AlternateKahn : inverts the order of the elements given by KahnSort in the resulting sorted list.

func AlternateTarjan

func AlternateTarjan(tree map[string][]string) ([]string, error)

AlternateTarjan : inverts the order of the elements given by TarjanSort in the resulting sorted list.

func CreateMergePatch

func CreateMergePatch(original, new interface{}) ([]byte, error)

CreateMergePatch return patch generated from original and new interfaces

func FindWorkloadBySelector

func FindWorkloadBySelector(workloadList v1alpha1.AppGroupWorkloadList, selector string) *v1alpha1.AppGroupWorkloadInfo

FindWorkloadBySelector : return the workload's Info based on its selector

func GetPodAppGroupLabel

func GetPodAppGroupLabel(pod *v1.Pod) string

GetPodAppGroupLabel : get AppGroup from pod annotations

func GetPodAppGroupSelector

func GetPodAppGroupSelector(pod *v1.Pod) string

GetPodAppGroupSelector : get Workload Selector from pod annotations

func KahnSort

func KahnSort(tree map[string][]string) ([]string, error)

Implementation of Topology Sorting algorithms based on https://github.com/otaviokr/topological-sort KahnSort : receives a tree (AppGroup Service Topology) and returns an array with the pods sorted.

func NormalizeTree

func NormalizeTree(source map[string][]string) map[string][]string

NormalizeTree: checks if all Pods referred in the slices are present in the map as key too. If not, it will create the entry to make sure all nodes are accounted for.

func Reverse

func Reverse(tree map[string][]string, algorithm string) ([]string, error)

Reverse : inverts the order given by a Topology Sorting algorithm (e.g., Kahn, Tarjan).

func ReverseKahn

func ReverseKahn(tree map[string][]string) ([]string, error)

ReverseKahn : reverses the order of the elements given by KahnSort in the resulting sorted list.

func ReverseTarjan

func ReverseTarjan(tree map[string][]string) ([]string, error)

ReverseTarjan : reverses the order of the elements given by TarjanSort in the resulting sorted list.

func TarjanSort

func TarjanSort(tree map[string][]string) ([]string, error)

TarjanSort : receives a description of a search tree and returns a sorted array based on the Tarjan Sort algorithm.

Types

type BySelector

type BySelector v1alpha1.AppGroupWorkloadList

Sort AppGroupWorkloadList by Workload.Selector

func (BySelector) Len

func (s BySelector) Len() int

func (BySelector) Less

func (s BySelector) Less(i, j int) bool

func (BySelector) Swap

func (s BySelector) Swap(i, j int)

type ByWorkloadSelector

type ByWorkloadSelector v1alpha1.AppGroupTopologyList

Sort AppGroupTopologyList by Workload.Selector

func (ByWorkloadSelector) Len

func (s ByWorkloadSelector) Len() int

func (ByWorkloadSelector) Less

func (s ByWorkloadSelector) Less(i, j int) bool

func (ByWorkloadSelector) Swap

func (s ByWorkloadSelector) Swap(i, j int)

Jump to

Keyboard shortcuts

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