-
Notifications
You must be signed in to change notification settings - Fork 0
/
dgraph.go
47 lines (36 loc) · 865 Bytes
/
dgraph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright 2024 Hypermode, Inc.
*/
package manifest
import (
"crypto/sha256"
"encoding/hex"
"fmt"
)
const (
HostTypeDgraph string = "dgraph"
)
type DgraphHostInfo struct {
Name string `json:"-"`
Type string `json:"type"`
GrpcTarget string `json:"grpcTarget"`
Key string `json:"key"`
}
func (p DgraphHostInfo) HostName() string {
return p.Name
}
func (DgraphHostInfo) HostType() string {
return HostTypeDgraph
}
func (h DgraphHostInfo) GetVariables() []string {
return extractVariables(h.Key)
}
func (h DgraphHostInfo) Hash() string {
// Concatenate the attributes into a single string
data := fmt.Sprintf("%v|%v|%v", h.Name, h.Type, h.GrpcTarget)
// Compute the SHA-256 hash
hash := sha256.Sum256([]byte(data))
// Convert the hash to a hexadecimal string
hashStr := hex.EncodeToString(hash[:])
return hashStr
}