2018-09-28 06:52:17 +00:00
|
|
|
package register
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/consul/agent/config"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
)
|
|
|
|
|
|
|
|
// configToAgentService converts a ServiceDefinition struct to an
|
|
|
|
// AgentServiceRegistration API struct.
|
|
|
|
func configToAgentService(svc *config.ServiceDefinition) (*api.AgentServiceRegistration, error) {
|
2018-10-01 02:17:45 +00:00
|
|
|
// mapstructure can do this for us, but we encapsulate it in this
|
|
|
|
// helper function in case we need to change the logic in the future.
|
2018-09-28 06:52:17 +00:00
|
|
|
var result api.AgentServiceRegistration
|
2018-10-01 02:17:45 +00:00
|
|
|
return &result, mapstructure.Decode(svc, &result)
|
2018-09-28 06:52:17 +00:00
|
|
|
}
|