From 5ac790d1651d4a9b8e3611de6a0bcd302f64ee1e Mon Sep 17 00:00:00 2001 From: Robert Hoppe Date: Wed, 10 Jul 2024 12:04:34 +0200 Subject: [PATCH] Task/hotfix adjust networking error handling (#248) * Adjust the Check how Nameservers are validated * Add function change --------- Co-authored-by: Robert Hoppe --- go.mod | 2 +- go.sum | 4 ++-- stackit/internal/resources/network/actions.go | 4 ++++ stackit/pkg/validate/functions.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index c992a51f..5b7fecf1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Masterminds/semver v1.5.0 - github.com/SchwarzIT/community-stackit-go-client v1.30.1 + github.com/SchwarzIT/community-stackit-go-client v1.30.2 github.com/go-test/deep v1.0.3 github.com/google/uuid v1.3.0 github.com/hashicorp/terraform-plugin-framework v1.2.0 diff --git a/go.sum b/go.sum index 8997e41d..531c97c4 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= -github.com/SchwarzIT/community-stackit-go-client v1.30.1 h1:pD+CvhC4qACvPboT/flp92edD/hdEPAyn02apmYXjgs= -github.com/SchwarzIT/community-stackit-go-client v1.30.1/go.mod h1:hlTfBNOKE1fokWE8g3KrI0AHo0SqzTKkS+LrIdhH8Qg= +github.com/SchwarzIT/community-stackit-go-client v1.30.2 h1:g7A1dQXb1KSiM3LTJx560bo6g1+a13++cMLOXBa8twM= +github.com/SchwarzIT/community-stackit-go-client v1.30.2/go.mod h1:hlTfBNOKE1fokWE8g3KrI0AHo0SqzTKkS+LrIdhH8Qg= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= diff --git a/stackit/internal/resources/network/actions.go b/stackit/internal/resources/network/actions.go index ccc950c0..74515433 100644 --- a/stackit/internal/resources/network/actions.go +++ b/stackit/internal/resources/network/actions.go @@ -72,6 +72,10 @@ func (r Resource) createNetwork(ctx context.Context, resp *resource.CreateRespon projectID, _ := uuid.Parse(plan.ProjectID.String()) res, err := r.client.IAAS.V1CreateNetwork(ctx, projectID, body) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("failed creating network %s", body.Name), err.Error()) + return plan + } timeout, d := plan.Timeouts.Create(ctx, 5*time.Minute) if resp.Diagnostics.Append(d...); resp.Diagnostics.HasError() { diff --git a/stackit/pkg/validate/functions.go b/stackit/pkg/validate/functions.go index 58f3a922..9e0cf19b 100644 --- a/stackit/pkg/validate/functions.go +++ b/stackit/pkg/validate/functions.go @@ -126,7 +126,7 @@ func NameServers() *Validator { description: "validate name servers", validateList: func(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) { for _, v := range req.ConfigValue.Elements() { - if err := clientValidate.NameServer(v.String()); err != nil { + if err := clientValidate.IsIP(v.String()); err != nil { resp.Diagnostics.AddError(err.Error(), err.Error()) } }