Skip to content

Commit 2e4a8b2

Browse files
author
Lucas Stephens
authored
fix: update terraform provider with latest vpc api schema changes (#58)
* fix: update terraform provider with latest vpc api schema changes * chore: regenerate docs & examples * fix: handle gRPC errors without details * chore: fix golangci-lint job * chore: fix golangci-lint job * chore: switch tagging job to use PAT * chore: update documentation * fix: update security vulnerabilities * chore: tidy docs
1 parent 7093093 commit 2e4a8b2

File tree

14 files changed

+617
-367
lines changed

14 files changed

+617
-367
lines changed

.github/workflows/tag.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0 # ✅ Fetch all commits and tags
20+
token: ${{ secrets.GHA_PAT_TAGS }}
2021

2122
- name: Push Tag for Release
2223
id: push_tag
@@ -35,9 +36,6 @@ jobs:
3536
exit 0
3637
else
3738
echo "Pushing tag $VERSION"
38-
git config user.name "github-actions[bot]"
39-
git config user.email "github-actions[bot]@users.noreply.github.com"
40-
4139
# Create and push the tag (auth is already configured)
4240
git tag "$VERSION"
4341
git push origin "$VERSION"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Run linters
3030
uses: golangci/golangci-lint-action@v6
3131
with:
32-
version: latest
32+
version: v1.64.5
3333

3434
generate:
3535
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Visit https://golangci-lint.run/ for usage documentation
44
# and information on other useful linters
55
issues:
6-
max-per-linter: 0
76
max-same-issues: 0
87

98
linters:
@@ -22,7 +21,6 @@ linters:
2221
- nilerr
2322
- predeclared
2423
- staticcheck
25-
- tenv
2624
- unconvert
2725
- unparam
2826
- unused

coreweave/cks/resource_cluster.go

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -309,47 +309,55 @@ func (r *ClusterResource) Schema(ctx context.Context, req resource.SchemaRequest
309309
stringplanmodifier.UseStateForUnknown(),
310310
},
311311
},
312-
"vpc_id": schema.StringAttribute{
313-
Required: true,
312+
"name": schema.StringAttribute{
313+
Required: true,
314+
MarkdownDescription: "The name of the cluster. Must not be longer than 30 characters.",
314315
PlanModifiers: []planmodifier.String{
315316
stringplanmodifier.RequiresReplace(),
316317
},
317318
},
318319
"zone": schema.StringAttribute{
319-
Required: true,
320+
Required: true,
321+
MarkdownDescription: "The Availability Zone in which the cluster is located.",
320322
PlanModifiers: []planmodifier.String{
321323
stringplanmodifier.RequiresReplace(),
322324
},
323325
},
324-
"name": schema.StringAttribute{
325-
Required: true,
326+
"vpc_id": schema.StringAttribute{
327+
Required: true,
328+
MarkdownDescription: "The ID of the VPC in which the cluster is located. Must be a VPC in the same Availability Zone as the cluster.",
326329
PlanModifiers: []planmodifier.String{
327330
stringplanmodifier.RequiresReplace(),
328331
},
329332
},
330-
"version": schema.StringAttribute{
331-
Required: true,
332-
},
333333
"public": schema.BoolAttribute{
334-
Optional: true,
335-
Computed: true,
336-
Default: booldefault.StaticBool(false),
334+
Optional: true,
335+
Computed: true,
336+
MarkdownDescription: "Whether the cluster's api-server is publicly accessible from the internet.",
337+
Default: booldefault.StaticBool(false),
338+
},
339+
"version": schema.StringAttribute{
340+
Required: true,
341+
MarkdownDescription: "The version of Kubernetes to run on the cluster, in minor version format (e.g. 'v1.32'). Patch versions are automatically applied by CKS as they are released.",
337342
},
338343
"pod_cidr_name": schema.StringAttribute{
339-
Required: true,
344+
Required: true,
345+
MarkdownDescription: "The name of the vpc prefix to use as the pod CIDR range. The prefix must exist in the cluster's VPC.",
340346
PlanModifiers: []planmodifier.String{
341347
stringplanmodifier.RequiresReplace(),
342348
},
343349
},
344350
"service_cidr_name": schema.StringAttribute{
345-
Required: true,
351+
Required: true,
352+
MarkdownDescription: "The name of the vpc prefix to use as the service CIDR range. The prefix must exist in the cluster's VPC.",
346353
PlanModifiers: []planmodifier.String{
347354
stringplanmodifier.RequiresReplace(),
348355
},
349356
},
350357
"internal_lb_cidr_names": schema.SetAttribute{
351-
ElementType: types.StringType,
352-
Required: true,
358+
ElementType: types.StringType,
359+
Required: true,
360+
MarkdownDescription: "The names of the vpc prefixes to use as internal load balancer CIDR ranges. Internal load balancers are reachable within the VPC but not accessible from the internet.\nThe prefixes must exist in the cluster's VPC. This field is append-only.",
353361
PlanModifiers: []planmodifier.Set{
354362
setplanmodifier.RequiresReplaceIf(func(ctx context.Context, req planmodifier.SetRequest, resp *setplanmodifier.RequiresReplaceIfFuncResponse) {
355363
// Skip if there's no prior state or if the config is unknown
@@ -393,61 +401,77 @@ func (r *ClusterResource) Schema(ctx context.Context, req resource.SchemaRequest
393401
},
394402
},
395403
"audit_policy": schema.StringAttribute{
396-
Optional: true,
404+
Optional: true,
405+
MarkdownDescription: "Audit policy for the cluster. Must be provided as a base64-encoded JSON/YAML string.",
397406
},
398407
"authn_webhook": schema.SingleNestedAttribute{
399-
Optional: true,
408+
Optional: true,
409+
MarkdownDescription: "Authentication webhook configuration for the cluster.",
400410
Attributes: map[string]schema.Attribute{
401411
"server": schema.StringAttribute{
402-
Required: true,
412+
Required: true,
413+
MarkdownDescription: "The URL of the webhook server.",
403414
},
404415
"ca": schema.StringAttribute{
405-
Optional: true,
416+
Optional: true,
417+
MarkdownDescription: "The CA certificate for the webhook server. Must be a base64-encoded PEM-encoded certificate.",
406418
},
407419
},
408420
},
409421
"authz_webhook": schema.SingleNestedAttribute{
410-
Optional: true,
422+
Optional: true,
423+
MarkdownDescription: "Authorization webhook configuration for the cluster.",
411424
Attributes: map[string]schema.Attribute{
412425
"server": schema.StringAttribute{
413-
Required: true,
426+
Required: true,
427+
MarkdownDescription: "The URL of the webhook server.",
414428
},
415429
"ca": schema.StringAttribute{
416-
Optional: true,
430+
Optional: true,
431+
MarkdownDescription: "The CA certificate for the webhook server. Must be a base64-encoded PEM-encoded certificate.",
417432
},
418433
},
419434
},
420435
"oidc": schema.SingleNestedAttribute{
421-
MarkdownDescription: "Kubernetes OIDC Configuration",
436+
MarkdownDescription: "OpenID Connect (OIDC) configuration for authentication to the api-server.",
422437
Optional: true,
423438
Attributes: map[string]schema.Attribute{
424439
"issuer_url": schema.StringAttribute{
425-
Required: true,
440+
Required: true,
441+
MarkdownDescription: "The URL of the OIDC issuer.",
426442
},
427443
"client_id": schema.StringAttribute{
428-
Required: true,
444+
Required: true,
445+
MarkdownDescription: "The client ID for the OIDC client.",
429446
},
430447
"username_claim": schema.StringAttribute{
431-
Optional: true,
448+
Optional: true,
449+
MarkdownDescription: "The claim to use as the username.",
432450
},
433451
"username_prefix": schema.StringAttribute{
434-
Optional: true,
452+
Optional: true,
453+
MarkdownDescription: "The prefix to use for the username.",
435454
},
436455
"groups_claim": schema.StringAttribute{
437-
Optional: true,
456+
Optional: true,
457+
MarkdownDescription: "The claim to use as the groups.",
438458
},
439459
"groups_prefix": schema.StringAttribute{
440-
Optional: true,
460+
Optional: true,
461+
MarkdownDescription: "The prefix to use for the groups.",
441462
},
442463
"ca": schema.StringAttribute{
443-
Optional: true,
464+
Optional: true,
465+
MarkdownDescription: "The CA certificate for the OIDC issuer. Must be a base64-encoded PEM-encoded certificate.",
444466
},
445467
"required_claim": schema.StringAttribute{
446-
Optional: true,
468+
Optional: true,
469+
MarkdownDescription: "The claim to require for authentication.",
447470
},
448471
"signing_algs": schema.SetAttribute{
449-
ElementType: types.StringType,
450-
Optional: true,
472+
ElementType: types.StringType,
473+
Optional: true,
474+
MarkdownDescription: "A list of signing algorithms that the OpenID Connect discovery endpoint uses.",
451475
},
452476
},
453477
},

coreweave/cks/resource_cluster_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ func TestClusterSchema(t *testing.T) {
4545
}
4646

4747
func TestClusterResource(t *testing.T) {
48+
t.Parallel()
4849
randomInt := rand.IntN(100)
4950
clusterName := fmt.Sprintf("test-acc-cks-cluster-%x", randomInt)
5051
resourceName := fmt.Sprintf("test_acc_cks_cluster_%x", randomInt)
5152
fullResourceName := fmt.Sprintf("coreweave_cks_cluster.%s", resourceName)
5253
vpc := &networking.VpcResourceModel{
53-
Name: types.StringValue(clusterName),
54-
Zone: types.StringValue("US-EAST-04A"),
55-
HostPrefixes: types.SetValueMust(types.StringType, []attr.Value{types.StringValue("10.16.192.0/18")}),
54+
Name: types.StringValue(clusterName),
55+
Zone: types.StringValue("US-EAST-04A"),
56+
HostPrefix: types.StringValue("10.16.192.0/18"),
5657
VpcPrefixes: []networking.VpcPrefixResourceModel{
5758
{
5859
Name: types.StringValue("pod cidr"),

coreweave/client.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ func HandleAPIError(ctx context.Context, err error, diagnostics *diag.Diagnostic
6666
violation.Type+": "+violation.Description,
6767
)
6868
}
69+
break
6970
}
71+
72+
diagnostics.AddError(connectErr.Error(), connectErr.Message())
7073
}
7174

7275
case connect.CodeInvalidArgument:
@@ -83,7 +86,10 @@ func HandleAPIError(ctx context.Context, err error, diagnostics *diag.Diagnostic
8386
field.Field+": "+field.Description,
8487
)
8588
}
89+
break
8690
}
91+
92+
diagnostics.AddError(connectErr.Error(), connectErr.Message())
8793
}
8894

8995
case connect.CodeUnauthenticated:
@@ -112,7 +118,10 @@ func HandleAPIError(ctx context.Context, err error, diagnostics *diag.Diagnostic
112118
violation.Subject+": "+violation.Description,
113119
)
114120
}
121+
break
115122
}
123+
124+
diagnostics.AddError(connectErr.Error(), connectErr.Message())
116125
}
117126

118127
default:
@@ -126,4 +135,9 @@ func HandleAPIError(ctx context.Context, err error, diagnostics *diag.Diagnostic
126135
"An unexpected error occurred. Please check the provider logs for more details.",
127136
)
128137
}
138+
139+
// safeguard for any buggy case statements
140+
if !diagnostics.HasError() {
141+
diagnostics.AddError(connectErr.Error(), connectErr.Message())
142+
}
129143
}

0 commit comments

Comments
 (0)