make subnet subsys dynamic and simplify callhome (#15927)

This commit is contained in:
Harshavardhana
2022-10-27 00:20:01 -07:00
committed by GitHub
parent 86420a1f46
commit ec77d28e62
7 changed files with 136 additions and 60 deletions
+5 -2
View File
@@ -35,8 +35,8 @@ const (
// Post submit 'payload' to specified URL
func (c Config) Post(reqURL string, payload interface{}) (string, error) {
if len(c.APIKey) == 0 {
return "", errors.New("Deployment is not registered with SUBNET. Please register the deployment via 'mc support register ALIAS'")
if !c.Registered() {
return "", errors.New("Deployment is not registered with SUBNET. Please register the deployment via 'mc license register ALIAS'")
}
body, err := json.Marshal(payload)
if err != nil {
@@ -47,7 +47,10 @@ func (c Config) Post(reqURL string, payload interface{}) (string, error) {
return "", err
}
configLock.RLock()
r.Header.Set("Authorization", c.APIKey)
configLock.RUnlock()
r.Header.Set("Content-Type", "application/json")
client := &http.Client{