2020-05-04 17:48:02 +00:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Agent is Consul agent.
|
|
|
|
//
|
|
|
|
// See https://www.consul.io/api/agent.html#read-configuration
|
|
|
|
type Agent struct {
|
|
|
|
Config AgentConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
// AgentConfig is Consul agent config.
|
|
|
|
//
|
|
|
|
// See https://www.consul.io/api/agent.html#read-configuration
|
|
|
|
type AgentConfig struct {
|
|
|
|
Datacenter string
|
|
|
|
}
|
|
|
|
|
|
|
|
func parseAgent(data []byte) (*Agent, error) {
|
|
|
|
var a Agent
|
|
|
|
if err := json.Unmarshal(data, &a); err != nil {
|
2020-06-30 19:58:18 +00:00
|
|
|
return nil, fmt.Errorf("cannot unmarshal agent info from %q: %w", data, err)
|
2020-05-04 17:48:02 +00:00
|
|
|
}
|
|
|
|
return &a, nil
|
|
|
|
}
|