csctl/config/keys.go

52 lines
1.3 KiB
Go

package config
import (
"io/ioutil"
"strings"
)
// FetchHMACKey is a configuration function that fetches the system HMAC key to interact with CSD
func FetchHMACKey() []byte {
read, err := ioutil.ReadFile("/etc/cscli.conf")
if err != nil {
panic(err)
}
return []byte(strings.TrimSpace(string(read)))
}
// FetchConfigKey is a configuration function that fetches the ConfigCat SDK key
func FetchConfigKey() string {
read, err := ioutil.ReadFile("/etc/cscli-sdk.conf")
if err != nil {
panic(err)
}
return strings.TrimSpace(string(read))
}
// FetchIPKey is a configuration function that fetches the API key for IP address information
func FetchIPKey() string {
read, err := ioutil.ReadFile("/etc/cscli-ip.conf")
if err != nil {
panic(err)
}
return strings.TrimSpace(string(read))
}
// FetchVendorKey is a configuration function that fetches the Vendor key for Community Report data
func FetchVendorKey() string {
read, err := ioutil.ReadFile("/etc/cscli-vend.conf")
if err != nil {
panic(err)
}
return strings.TrimSpace(string(read))
}
// FetchInternalKey is a configuration function that fetches the inter-process internal communication key
func FetchInternalKey() string {
read, err := ioutil.ReadFile("/etc/csctl-internal.conf")
if err != nil {
panic(err)
}
return strings.TrimSpace(string(read))
}