Commit 9b7f06ca authored by lukas.burgey's avatar lukas.burgey

User dep.ServiceName to identify services not dep.Service.Name

parent a641384c
Pipeline #121930 failed with stages
in 16 seconds
......@@ -31,7 +31,10 @@ type (
UserInfo scripts.UserInfo `json:"userinfo"`
// The Service which this Dep is related to.
Service config.Service `json:"service"`
Service config.Service
// ServiceName should be used to identify this deployments servic
ServiceName string `json:"service_name"`
// Optional Answers by the users. Must have the same keys as the related Questionnaire
Answers map[string]interface{} `json:"answers,omitempty"`
......@@ -71,10 +74,7 @@ type (
)
func (dep Dep) String() string {
if dep.Service != (config.Service{}) {
return fmt.Sprintf("Dep[%v]#%v", dep.Service.Name, dep.ID)
}
return fmt.Sprintf("Dep#%v", dep.ID)
return fmt.Sprintf("Dep[%v]#%v", dep.ServiceName, dep.ID)
}
// Log logs a message for a Dep
......
......@@ -68,43 +68,36 @@ func completeReply(dep deps.Dep, reply deps.Reply) deps.Reply {
return reply
}
func (sink *Sink) depServices(dep deps.Dep) (services []config.Service, err error) {
func (sink *Sink) setService(dep *deps.Dep) (err error) {
// find the matching service
if dep.Service != (config.Service{}) {
for _, s := range sink.Config.Services {
if s.Name == dep.Service.Name {
services = []config.Service{s}
return
}
for _, s := range sink.Config.Services {
if s.Name == dep.ServiceName {
dep.Service = s
return
}
}
err = fmt.Errorf("Service for Dep does not exist: '%s'", dep.Service.Name)
err = fmt.Errorf("Service for Dep does not exist: '%s'", dep.ServiceName)
return
}
func (sink *Sink) scheduleDep(dep deps.Dep) (err error) {
// determine the services of the deployment
var services []config.Service
services, err = sink.depServices(dep)
// determine the services of the deployment and set dep.Service
err = sink.setService(&dep)
if err != nil {
return
}
// execute the deployment for all the services
for _, svc := range services {
if sink.Config.Debug.Scripts {
dep.Log("Scheduling execution for %s", svc.Name)
}
// track the scheduled deployment in the wait group
sink.wgDeployments.Add(1)
if sink.Config.Debug.Scripts {
dep.Log("Scheduling execution for %s", dep.Service.Name)
}
// schedule the deployment
sink.Scheduled <- dep
// track the scheduled deployment in the wait group
sink.wgDeployments.Add(1)
}
// schedule the deployment
sink.Scheduled <- dep
return
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment