1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

feat(support): collect system info bundle to assist support troubleshooting [r8s-157] (#154)

This commit is contained in:
Malcolm Lockyer 2024-12-06 15:38:10 +13:00 committed by GitHub
parent 17648d12fe
commit 783ab253af
17 changed files with 1367 additions and 440 deletions

30
pkg/edge/utils.go Normal file
View file

@ -0,0 +1,30 @@
package edge
import (
"encoding/base64"
"errors"
"strconv"
"strings"
)
// GetPortainerURLFromEdgeKey returns the portainer URL from an edge key
// format: <portainer_instance_url>|<tunnel_server_addr>|<tunnel_server_fingerprint>|<endpoint_id>
func GetPortainerURLFromEdgeKey(edgeKey string) (string, error) {
decodedKey, err := base64.RawStdEncoding.DecodeString(edgeKey)
if err != nil {
return "", err
}
keyInfo := strings.Split(string(decodedKey), "|")
if len(keyInfo) != 4 {
return "", errors.New("invalid key format")
}
_, err = strconv.Atoi(keyInfo[3])
if err != nil {
return "", errors.New("invalid key format")
}
return keyInfo[0], nil
}