Skip to content

Commit d24133f

Browse files
committed
refactor: Fix naming of functions and data sources.
1 parent d4a065d commit d24133f

File tree

7 files changed

+37
-42
lines changed

7 files changed

+37
-42
lines changed

CONTRIBUTING.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ We're going to assume you already have [Homebrew](https://mac.install.guide/home
5454
## Ensure the provider is installed correctly
5555
5656
```bash
57-
cd ./examples/data-sources/corefunc_truncate_label
57+
cd ./examples/data-sources/corefunc_str_truncate_label
5858
5959
# As a developer using `make build`, SKIP `terraform init`.
6060
terraform plan
@@ -65,21 +65,15 @@ terraform plan
6565
### Success looks like…
6666
6767
```plain
68-
data.corefunc_truncate_label.label: Reading...
69-
data.corefunc_truncate_label.label: Read complete after 0s
68+
data.corefunc_str_truncate_label.label: Reading...
69+
data.corefunc_str_truncate_label.label: Read complete after 0s
7070
7171
Changes to Outputs:
7272
+ name = "NW-ZZZ-CLOUD-TEST-APP-CLOUD-PR…: K8S Pods Not Running Deploymen…"
7373
7474
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
7575
```
7676
77-
### Failure looks like…
78-
79-
> **Error: Failed to load plugin schemas**
80-
>
81-
> @TODO
82-
8377
## Testing and fuzzing
8478
8579
The `nproc` binary is commonly available on most Linux distributions. To install in Alpine Linux or macOS, you should install the `coreutils` package from `apk` (Alpine Linux) or `brew` (macOS).
@@ -127,7 +121,7 @@ Benchmarks test the performance/scalability of a package. Different versions of
127121
```bash
128122
go test \
129123
-bench=. \
130-
-benchtime=2s \
124+
-benchtime=10s \
131125
-benchmem \
132126
-cpuprofile=_cpu.out \
133127
-memprofile=_mem.out \

README.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,28 @@ See the `docs/` directory for user-facing documentation.
1919

2020
## Planned Functions
2121

22-
* [ ] utils_str_snake(string)
23-
* [ ] utils_str_camel(string)
24-
* [ ] utils_str_kebab(string)
25-
* [ ] utils_str_constant(string)
26-
* [ ] utils_str_word(string)
27-
* [ ] utils_str_leftpad(any, string, length)
28-
* [ ] utils_str_recursive_replace(string, map[string]any)
29-
* [ ] utils_str_resolve_markers(string)
30-
* [ ] utils_list_first(arr)
31-
* [ ] utils_list_last(arr)
32-
* [ ] utils_list_push(arr, any)
33-
* [ ] utils_list_pop(array)
34-
* [ ] utils_list_shift(arr, any)
35-
* [ ] utils_list_unshift(arr)
36-
* [ ] utils_list_sort_icase(arr)
37-
* [ ] utils_list_sort_version(arr)
38-
* [ ] utils_map_has_key(map)
39-
* [ ] utils_env_get(string, string)
40-
* [ ] utils_env_ensure([]string)
41-
* [ ] utils_dump(any)
42-
* [ ] utils_println(string)
22+
* [ ] corefunc_dump(any)
23+
* [ ] corefunc_env_ensure([]string)
24+
* [ ] corefunc_env_get(string, string)
25+
* [ ] corefunc_list_first(arr)
26+
* [ ] corefunc_list_last(arr)
27+
* [ ] corefunc_list_pop(array)
28+
* [ ] corefunc_list_push(arr, any)
29+
* [ ] corefunc_list_shift(arr, any)
30+
* [ ] corefunc_list_sort_icase(arr)
31+
* [ ] corefunc_list_sort_version(arr)
32+
* [ ] corefunc_list_unshift(arr)
33+
* [ ] corefunc_map_has_key(map)
34+
* [ ] corefunc_println(string)
35+
* [ ] corefunc_str_camel(string)
36+
* [ ] corefunc_str_constant(string)
37+
* [ ] corefunc_str_kebab(string)
38+
* [ ] corefunc_str_leftpad(any, string, length)
39+
* [ ] corefunc_str_recursive_replace(string, map[string]any)
40+
* [ ] corefunc_str_resolve_markers(string)
41+
* [ ] corefunc_str_snake(string)
42+
* [X] corefunc_str_truncate_label(int, string, string)
43+
* [ ] corefunc_str_word(string)
4344

4445
## Documentation
4546

corefunc/truncate_label_data_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (d *truncateLabelDataSource) Metadata(
5454
) {
5555
tflog.Info(ctx, "Starting TruncateLabel DataSource Metadata method.")
5656

57-
resp.TypeName = req.ProviderTypeName + "_truncate_label"
57+
resp.TypeName = req.ProviderTypeName + "_str_truncate_label"
5858

5959
tflog.Debug(ctx, fmt.Sprintf("req.ProviderTypeName = %s", req.ProviderTypeName))
6060
tflog.Debug(ctx, fmt.Sprintf("resp.TypeName = %s", resp.TypeName))

corefunc/truncate_label_data_source_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ func TestAccTruncateLabelDataSourceDefaultMaxLength64(t *testing.T) {
1414
Steps: []resource.TestStep{
1515
{
1616
Config: providerConfig + `
17-
data "corefunc_truncate_label" "truncated" {
17+
data "corefunc_str_truncate_label" "truncated" {
1818
prefix = "NW-ZZZ-CLOUD-TEST-APP-CLOUD-PROD-CRIT"
1919
label = "K8S Pods Not Running Deployment Check"
2020
}
2121
`,
2222
Check: resource.ComposeAggregateTestCheckFunc(
2323
resource.TestCheckResourceAttr(
24-
"data.corefunc_truncate_label.truncated",
24+
"data.corefunc_str_truncate_label.truncated",
2525
"value",
2626
"NW-ZZZ-CLOUD-TEST-APP-CLOUD-PR…: K8S Pods Not Running Deploymen…",
2727
),
@@ -46,7 +46,7 @@ func TestAccTruncateLabelDataSourceTruncateTests(t *testing.T) {
4646
Steps: []resource.TestStep{
4747
{
4848
Config: providerConfig + `
49-
data "corefunc_truncate_label" "label" {
49+
data "corefunc_str_truncate_label" "label" {
5050
prefix = "` + tc.prefix + `"
5151
label = "` + tc.label + `"
5252
max_length = ` +
@@ -61,7 +61,7 @@ func TestAccTruncateLabelDataSourceTruncateTests(t *testing.T) {
6161
`,
6262
Check: resource.ComposeAggregateTestCheckFunc(
6363
resource.TestCheckResourceAttr(
64-
"data.corefunc_truncate_label.label",
64+
"data.corefunc_str_truncate_label.label",
6565
"value",
6666
func() string {
6767
if tc.expected == "" {

docs/data-sources/truncate_label.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
---
3-
page_title: "corefunc_truncate_label Data Source - corefunc"
3+
page_title: "corefunc_str_truncate_label Data Source - corefunc"
44
subcategory: ""
55
description: |-
66
TruncateLabel supports prepending a prefix to a label, while truncating them
@@ -9,7 +9,7 @@ description: |-
99
---
1010
-->
1111

12-
# corefunc_truncate_label (Data Source)
12+
# corefunc_str_truncate_label (Data Source)
1313

1414
TruncateLabel supports prepending a prefix to a label, while truncating them
1515
to meet the maximum length constraints. Useful when grouping labels with a
@@ -19,15 +19,15 @@ kind of prefix. Both the prefix and the label will be truncated if necessary.
1919

2020
```terraform
2121
# Pass the prefix and the label, then limit to 64 characters.
22-
data "corefunc_truncate_label" "label" {
22+
data "corefunc_str_truncate_label" "label" {
2323
prefix = "NW-ZZZ-CLOUD-TEST-APP-CLOUD-PROD-CRIT"
2424
label = "K8S Pods Not Running Deployment Check"
2525
max_length = 64
2626
}
2727
2828
# `value` is the read-only attribute containing the truncated label.
2929
output "value" {
30-
value = data.corefunc_truncate_label.label.value
30+
value = data.corefunc_str_truncate_label.label.value
3131
}
3232
3333
#=> NW-ZZZ-CLOUD-TEST-APP-CLOUD-PR…: K8S Pods Not Running Deploymen…
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Pass the prefix and the label, then limit to 64 characters.
2-
data "corefunc_truncate_label" "label" {
2+
data "corefunc_str_truncate_label" "label" {
33
prefix = "NW-ZZZ-CLOUD-TEST-APP-CLOUD-PROD-CRIT"
44
label = "K8S Pods Not Running Deployment Check"
55
max_length = 64
66
}
77

88
# `value` is the read-only attribute containing the truncated label.
99
output "value" {
10-
value = data.corefunc_truncate_label.label.value
10+
value = data.corefunc_str_truncate_label.label.value
1111
}
1212

1313
#=> NW-ZZZ-CLOUD-TEST-APP-CLOUD-PR…: K8S Pods Not Running Deploymen…

0 commit comments

Comments
 (0)