From 55c98912edcabcccd92c4e32fe3310bbfa8d0091 Mon Sep 17 00:00:00 2001 From: Yajith Dayarathna Date: Mon, 13 Jan 2025 17:06:10 +1300 Subject: [PATCH] feat(omni): support for omni [R8S-75] (#105) Co-authored-by: stevensbkang Co-authored-by: testA113 Co-authored-by: Malcolm Lockyer Co-authored-by: Ali <83188384+testA113@users.noreply.github.com> --- pkg/edge/utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/edge/utils.go b/pkg/edge/utils.go index 1bf851d73..f704708ce 100644 --- a/pkg/edge/utils.go +++ b/pkg/edge/utils.go @@ -30,6 +30,19 @@ func GetPortainerURLFromEdgeKey(edgeKey string) (string, error) { return keyInfo[0], nil } +// GetEndpointIDFromEdgeKey returns the endpoint ID from an edge key +// format: ||| +func GetEndpointIDFromEdgeKey(edgeKey string) (int, error) { + decodedKey, err := base64.RawStdEncoding.DecodeString(edgeKey) + if err != nil { + return 0, err + } + + keyInfo := strings.Split(string(decodedKey), "|") + + return strconv.Atoi(keyInfo[3]) +} + // IsValidEdgeStackName validates an edge stack name // Edge stack name must be between 1 and 255 characters long // and can only contain lowercase letters, digits, hyphens and underscores