From 80686523f5e1faa9a7bed9cc9e803bfc2e6a225d Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Sat, 4 Nov 2023 21:13:01 +0100 Subject: [PATCH] fix nil derefence panic --- internal/hetzner/hetzneragent.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/hetzner/hetzneragent.go b/internal/hetzner/hetzneragent.go index 34f947c..f23bd2a 100644 --- a/internal/hetzner/hetzneragent.go +++ b/internal/hetzner/hetzneragent.go @@ -78,7 +78,7 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) { labels["ControledBy"] = "WoodpeckerAutoscaler" 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{ @@ -93,6 +93,10 @@ func CreateNewAgent(cfg *config.Config) (*hcloud.Server, error) { Labels: labels, }) + if err != nil { + return nil, errors.New(fmt.Sprintf("Could not create new Agent: %s", err.Error())) + } + log.WithFields(log.Fields{ "Caller": "CreateNewAgent", }).Infof("Created new Build Agent %s", res.Server.Name)