Skip to content

Commit cf79e84

Browse files
committed
docs(terraform): More documentation edits.
1 parent e9e2ad6 commit cf79e84

File tree

5 files changed

+52
-19
lines changed

5 files changed

+52
-19
lines changed

.golangci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,11 @@ issues:
841841
- tagliatelle
842842
source: lint:allow_format
843843

844+
- text: (is unused)
845+
linters:
846+
- unused
847+
source: lint:allow_unused
848+
844849
# Independently from option `exclude` we use default exclude patterns, it can be disabled by this
845850
# option. To list all excluded by default patterns execute `golangci-lint run --help`. Default
846851
# value for this option is true.

corefunc/test_helpers.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ import (
66
"strings"
77
)
88

9-
func traceFuncName() string {
10-
pc := make([]uintptr, 15)
11-
n := runtime.Callers(2, pc)
9+
const (
10+
// Terratest displays a Markdown link to Terratest.
11+
Terratest = "[Terratest](https://terratest.gruntwork.io)"
12+
13+
// TPF displays a Markdown link to the Terraform Plugin Framework.
14+
TPF = "[Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework)"
15+
)
16+
17+
func traceFuncName() string { // lint:allow_unused
18+
pc := make([]uintptr, 15) // lint:allow_raw_number
19+
n := runtime.Callers(2, pc) // lint:allow_raw_number
1220
frames := runtime.CallersFrames(pc[:n])
1321
frame, _ := frames.Next()
1422

@@ -20,3 +28,11 @@ func traceFuncName() string {
2028
),
2129
)
2230
}
31+
32+
func linkPackage(functionName string) string {
33+
return "[`corefunc." +
34+
functionName +
35+
"()`](https://pkg.go.dev/github.com/northwood-labs/terraform-provider-corefunc/corefunc#" +
36+
functionName +
37+
")"
38+
}

corefunc/truncate_label_data_source.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ type (
4141
}
4242
)
4343

44-
// TruncateLabelDataSource is a helper function to simplify the provider implementation.
44+
// TruncateLabelDataSource is a method that exposes its paired Go function as a
45+
// Terraform Data Source.
4546
func TruncateLabelDataSource() datasource.DataSource { // lint:allow_return_interface
4647
return &truncateLabelDataSource{}
4748
}
@@ -72,26 +73,28 @@ func (d *truncateLabelDataSource) Schema(
7273

7374
resp.Schema = schema.Schema{
7475
MarkdownDescription: strings.TrimSpace(dedent.Dedent(`
75-
TruncateLabel supports prepending a prefix to a label, while truncating them
76+
Supports prepending a prefix to a label, while truncating them
7677
to meet the maximum length constraints. Useful when grouping labels with a
7778
kind of prefix. Both the prefix and the label will be truncated if necessary.
7879
79-
Uses a "balancing" algorithm between the prefix and the label, so that each
80+
Uses a balancing algorithm between the prefix and the label, so that each
8081
section is truncated as a factor of how much space it takes up in the merged
8182
string.
8283
8384
-> The motivation for this is in working with monitoring systems such
8485
as New Relic and Datadog where there are hundreds of applications in a
85-
monitoring "prod" account, and also hundreds of applications in a monitoring
86-
"nonprod" account. This allows us to group lists of monitors together using a
86+
monitoring prod account, and also hundreds of applications in a monitoring
87+
nonprod account. This allows us to group lists of monitors together using a
8788
shared prefix, but also truncate them appropriately to fit length
8889
constraints for names.
90+
91+
Maps to the ` + linkPackage("TruncateLabel") + ` Go method, which can be used in
92+
` + Terratest + `.
8993
`)),
9094
Attributes: map[string]schema.Attribute{
9195
"id": schema.Int64Attribute{
92-
Description: "Not used. Required by the " +
93-
"[Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework).",
94-
Computed: true,
96+
Description: "Not used. Required by the " + TPF + ".",
97+
Computed: true,
9598
},
9699
"max_length": schema.Int64Attribute{
97100
Description: "The maximum allowed length of the combined label. " +

docs/data-sources/str_truncate_label.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@
33
page_title: "corefunc_str_truncate_label Data Source - corefunc"
44
subcategory: ""
55
description: |-
6-
TruncateLabel supports prepending a prefix to a label, while truncating them
6+
Supports prepending a prefix to a label, while truncating them
77
to meet the maximum length constraints. Useful when grouping labels with a
88
kind of prefix. Both the prefix and the label will be truncated if necessary.
9-
Uses a "balancing" algorithm between the prefix and the label, so that each
9+
Uses a balancing algorithm between the prefix and the label, so that each
1010
section is truncated as a factor of how much space it takes up in the merged
1111
string.
1212
-> The motivation for this is in working with monitoring systems such
1313
as New Relic and Datadog where there are hundreds of applications in a
14-
monitoring "prod" account, and also hundreds of applications in a monitoring
15-
"nonprod" account. This allows us to group lists of monitors together using a
14+
monitoring prod account, and also hundreds of applications in a monitoring
15+
nonprod account. This allows us to group lists of monitors together using a
1616
shared prefix, but also truncate them appropriately to fit length
1717
constraints for names.
18+
Maps to the corefunc.TruncateLabel() https://pkg.go.dev/github.com/northwood-labs/terraform-provider-corefunc/corefunc#TruncateLabel Go method, which can be used in
19+
Terratest https://terratest.gruntwork.io.
1820
---
1921
-->
2022

2123
# corefunc_str_truncate_label (Data Source)
2224

23-
TruncateLabel supports prepending a prefix to a label, while truncating them
25+
Supports prepending a prefix to a label, while truncating them
2426
to meet the maximum length constraints. Useful when grouping labels with a
2527
kind of prefix. Both the prefix and the label will be truncated if necessary.
2628

27-
Uses a "balancing" algorithm between the prefix and the label, so that each
29+
Uses a balancing algorithm between the prefix and the label, so that each
2830
section is truncated as a factor of how much space it takes up in the merged
2931
string.
3032

3133
-> The motivation for this is in working with monitoring systems such
3234
as New Relic and Datadog where there are hundreds of applications in a
33-
monitoring "prod" account, and also hundreds of applications in a monitoring
34-
"nonprod" account. This allows us to group lists of monitors together using a
35+
monitoring prod account, and also hundreds of applications in a monitoring
36+
nonprod account. This allows us to group lists of monitors together using a
3537
shared prefix, but also truncate them appropriately to fit length
3638
constraints for names.
3739

40+
Maps to the [`corefunc.TruncateLabel()`](https://pkg.go.dev/github.com/northwood-labs/terraform-provider-corefunc/corefunc#TruncateLabel) Go method, which can be used in
41+
[Terratest](https://terratest.gruntwork.io).
42+
3843
## Example Usage
3944

4045
```terraform

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
`main.go` is the entrypoint of the Terraform provider. See
3+
[`corefunc`](./corefunc) for the Go library code.
4+
*/
15
package main
26

37
import (

0 commit comments

Comments
 (0)