in pkg/api/deploymentapi/depresourceapi/deployment_info.go [62:97]
func GetDeploymentInfo(params GetDeploymentInfoParams) (GetDeploymentInfoResponse, error) {
var emptyRes GetDeploymentInfoResponse
if err := params.Validate(); err != nil {
return emptyRes, err
}
res, err := params.V1API.Deployments.GetDeployment(
deployments.NewGetDeploymentParams().
WithDeploymentID(params.DeploymentID).
WithEnrichWithTemplate(ec.Bool(true)).
WithConvertLegacyPlans(ec.Bool(true)).
WithShowPlans(ec.Bool(true)),
params.AuthWriter,
)
if err != nil {
return emptyRes, apierror.Wrap(err)
}
for _, resource := range res.Payload.Resources.Elasticsearch {
var planInfo = resource.Info.PlanInfo
var hasPlan = planInfo.Current != nil && planInfo.Current.Plan != nil
var refID string
if hasPlan {
refID = *resource.RefID
}
if hasPlan && planInfo.Current.Plan.DeploymentTemplate != nil {
return GetDeploymentInfoResponse{
RefID: refID,
DeploymentTemplate: *planInfo.Current.Plan.DeploymentTemplate.ID,
}, nil
}
}
return emptyRes, errors.New("unable to obtain deployment template ID from existing deployment ID, please specify a one")
}