fix nil derefence panic
All checks were successful
Pipeline was successful

This commit is contained in:
Tobias Trabelsi 2023-11-04 21:13:01 +01:00
parent 72c63f3508
commit 80686523f5
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E

View File

@ -78,7 +78,7 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) {
labels["ControledBy"] = "WoodpeckerAutoscaler" labels["ControledBy"] = "WoodpeckerAutoscaler"
if err != nil { if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create new Agent: %s", err.Error())) return nil, errors.New(fmt.Sprintf("Could not parse agent spec: %s", err.Error()))
} }
res, _, err := client.Server.Create(context.Background(), hcloud.ServerCreateOpts{ res, _, err := client.Server.Create(context.Background(), hcloud.ServerCreateOpts{
@ -93,6 +93,10 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) {
Labels: labels, Labels: labels,
}) })
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create new Agent: %s", err.Error()))
}
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"Caller": "CreateNewAgent", "Caller": "CreateNewAgent",
}).Infof("Created new Build Agent %s", res.Server.Name) }).Infof("Created new Build Agent %s", res.Server.Name)