• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Twingate / terraform-provider-twingate / 23786352640

31 Mar 2026 07:46AM UTC coverage: 86.812% (-1.4%) from 88.194%
23786352640

push

github

web-flow
Added SSH and Kubernetes resource (#838)

Co-authored-by: Bob Lee <bob@twingate.com>
Co-authored-by: Minh Tu Le <minhtu@twingate.com>

1402 of 1872 new or added lines in 47 files covered. (74.89%)

2 existing lines in 1 file now uncovered.

12000 of 13823 relevant lines covered (86.81%)

2.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.89
/twingate/internal/customvalidator/stringvalidator_also_requires_when_value.go
1
package customvalidator
2

3
import (
4
        "context"
5
        "fmt"
6

7
        "github.com/hashicorp/terraform-plugin-framework/path"
8
        "github.com/hashicorp/terraform-plugin-framework/schema/validator"
9
        "github.com/hashicorp/terraform-plugin-framework/types"
10
)
11

12
var _ validator.String = alsoRequiresWhenValueValidator{}
13

14
type alsoRequiresWhenValueValidator struct {
15
        expression path.Expression
16
        value      string
17
}
18

NEW
19
func (v alsoRequiresWhenValueValidator) Description(_ context.Context) string {
×
NEW
20
        return fmt.Sprintf("when this attribute equals %q, %q must also be set", v.value, v.expression)
×
NEW
21
}
×
22

NEW
23
func (v alsoRequiresWhenValueValidator) MarkdownDescription(ctx context.Context) string {
×
NEW
24
        return v.Description(ctx)
×
NEW
25
}
×
26

NEW
27
func (v alsoRequiresWhenValueValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
×
NEW
28
        if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
×
NEW
29
                return
×
NEW
30
        }
×
31

NEW
32
        if req.ConfigValue.ValueString() != v.value {
×
NEW
33
                return
×
NEW
34
        }
×
35

NEW
36
        paths, diags := req.Config.PathMatches(ctx, req.PathExpression.Merge(v.expression))
×
NEW
37
        resp.Diagnostics.Append(diags...)
×
NEW
38

×
NEW
39
        if resp.Diagnostics.HasError() {
×
NEW
40
                return
×
NEW
41
        }
×
42

NEW
43
        for _, attributePath := range paths {
×
NEW
44
                var attributeVal types.String
×
NEW
45

×
NEW
46
                diags = req.Config.GetAttribute(ctx, attributePath, &attributeVal)
×
NEW
47
                resp.Diagnostics.Append(diags...)
×
NEW
48

×
NEW
49
                if resp.Diagnostics.HasError() {
×
NEW
50
                        return
×
NEW
51
                }
×
52

NEW
53
                if attributeVal.IsNull() || attributeVal.IsUnknown() || attributeVal.ValueString() == "" {
×
NEW
54
                        resp.Diagnostics.AddAttributeError(
×
NEW
55
                                req.Path,
×
NEW
56
                                "Invalid attribute combination",
×
NEW
57
                                fmt.Sprintf("%q is %q, so %q must also be set.", req.Path, v.value, attributePath),
×
NEW
58
                        )
×
NEW
59
                }
×
60
        }
61
}
62

63
// AlsoRequiresWhenValueIs returns a validator that, when the current
64
// attribute equals triggerValue, requires the expression attribute at siblingPath
65
// to be set (non-null, non-empty). Attach this to the attribute whose value
66
// controls whether the expression is required (e.g. type = "iam" requires
67
// service_account_email).
68
func AlsoRequiresWhenValueIs(expression path.Expression, triggerValue string) validator.String {
2✔
69
        return alsoRequiresWhenValueValidator{expression: expression, value: triggerValue}
2✔
70
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc