mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
8f42c5a024
Add nomad_sd_config support for service discovery
28 lines
541 B
Go
28 lines
541 B
Go
package nomad
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// Agent is Nomad agent.
|
|
//
|
|
// See https://developer.hashicorp.com/nomad/api-docs/agent
|
|
type Agent struct {
|
|
Config AgentConfig
|
|
}
|
|
|
|
// AgentConfig is Nomad agent config.
|
|
//
|
|
// See https://developer.hashicorp.com/nomad/api-docs/agent
|
|
type AgentConfig struct {
|
|
Datacenter string
|
|
}
|
|
|
|
func parseAgent(data []byte) (*Agent, error) {
|
|
var a Agent
|
|
if err := json.Unmarshal(data, &a); err != nil {
|
|
return nil, fmt.Errorf("cannot unmarshal agent info from %q: %w", data, err)
|
|
}
|
|
return &a, nil
|
|
}
|