diff --git a/.licenses.cache.json b/.licenses.cache.json index 27b4937b..e75ed282 100644 --- a/.licenses.cache.json +++ b/.licenses.cache.json @@ -49,13 +49,13 @@ ], "Indirect": true, "DependsOn": [ - "github.com/imdario/mergo@v0.3.11", + "github.com/Masterminds/goutils@v1.1.1", "github.com/mitchellh/copystructure@v1.0.0", "golang.org/x/crypto@v0.3.0", - "github.com/Masterminds/goutils@v1.1.1", "github.com/Masterminds/semver/v3@v3.2.0", - "github.com/huandu/xstrings@v1.3.3", "github.com/google/uuid@v1.1.1", + "github.com/huandu/xstrings@v1.3.3", + "github.com/imdario/mergo@v0.3.11", "github.com/shopspring/decimal@v1.2.0", "github.com/spf13/cast@v1.3.1" ], @@ -185,8 +185,8 @@ ], "Indirect": true, "DependsOn": [ - "github.com/inconshreveable/mousetrap@v1.1.0", - "github.com/spf13/pflag@v1.0.5" + "github.com/spf13/pflag@v1.0.5", + "github.com/inconshreveable/mousetrap@v1.1.0" ], "Layer": {} }, @@ -246,16 +246,16 @@ ], "Indirect": true, "DependsOn": [ + "github.com/spf13/cast@v1.5.0", "github.com/Masterminds/goutils@v1.1.1", "github.com/Masterminds/semver/v3@v3.1.1", - "github.com/google/uuid@v1.3.1", "github.com/imdario/mergo@v0.3.15", - "github.com/stretchr/testify@v1.8.4", - "github.com/huandu/xstrings@v1.3.2", "github.com/mitchellh/copystructure@v1.2.0", "github.com/shopspring/decimal@v1.3.1", - "github.com/spf13/cast@v1.5.0", - "golang.org/x/crypto@v0.15.0" + "github.com/stretchr/testify@v1.8.4", + "golang.org/x/crypto@v0.15.0", + "github.com/google/uuid@v1.3.1", + "github.com/huandu/xstrings@v1.3.2" ], "Layer": {} }, @@ -357,9 +357,9 @@ ], "Indirect": true, "DependsOn": [ + "github.com/mattn/go-colorable@v0.1.13", "github.com/mattn/go-isatty@v0.0.20", - "golang.org/x/sys@v0.14.0", - "github.com/mattn/go-colorable@v0.1.13" + "golang.org/x/sys@v0.14.0" ], "Layer": {} }, @@ -418,9 +418,9 @@ "MIT" ], "DependsOn": [ + "github.com/hexops/gotextdiff@v1.0.3", "github.com/fatih/color@v1.16.0", - "github.com/stretchr/testify@v1.8.4", - "github.com/hexops/gotextdiff@v1.0.3" + "github.com/stretchr/testify@v1.8.4" ], "Layer": {} }, @@ -467,9 +467,9 @@ ], "Indirect": true, "DependsOn": [ - "github.com/google/go-cmp@v0.6.0", "github.com/vmihailenco/msgpack@v4.0.4+incompatible", - "golang.org/x/text@v0.14.0" + "golang.org/x/text@v0.14.0", + "github.com/google/go-cmp@v0.6.0" ], "Layer": {} }, @@ -512,12 +512,12 @@ "Indirect": true, "DependsOn": [ "github.com/mitchellh/go-testing-interface@v1.14.1", - "github.com/oklog/run@v1.1.0", - "github.com/hashicorp/go-hclog@v1.5.0", - "github.com/hashicorp/yamux@v0.1.1", "google.golang.org/grpc@v1.59.0", + "google.golang.org/protobuf@v1.31.0", + "github.com/hashicorp/go-hclog@v1.5.0", + "github.com/oklog/run@v1.1.0", "github.com/golang/protobuf@v1.5.3", - "google.golang.org/protobuf@v1.31.0" + "github.com/hashicorp/yamux@v0.1.1" ], "Layer": {} }, @@ -550,15 +550,15 @@ ], "Indirect": true, "DependsOn": [ - "github.com/mitchellh/cli@v1.1.5", + "github.com/hashicorp/go-cleanhttp@v0.5.2", "github.com/hashicorp/go-multierror@v1.1.1", + "github.com/google/go-cmp@v0.6.0", + "github.com/mitchellh/cli@v1.1.5", "github.com/ProtonMail/go-crypto@v0.0.0-20230923063757-afb1ddc0824c", - "github.com/hashicorp/go-cleanhttp@v0.5.2", - "github.com/hashicorp/go-checkpoint@v0.5.0", "github.com/hashicorp/logutils@v1.0.0", - "golang.org/x/mod@v0.14.0", - "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/go-version@v1.6.0" + "github.com/hashicorp/go-checkpoint@v0.5.0", + "github.com/hashicorp/go-version@v1.6.0", + "golang.org/x/mod@v0.14.0" ], "Layer": {} }, @@ -571,14 +571,14 @@ ], "Indirect": true, "DependsOn": [ + "github.com/davecgh/go-spew@v1.1.1", "github.com/mitchellh/go-wordwrap@v1.0.1", + "github.com/agext/levenshtein@v1.2.3", "github.com/spf13/pflag@v1.0.5", + "github.com/google/go-cmp@v0.6.0", "github.com/zclconf/go-cty@v1.14.1", "golang.org/x/crypto@v0.15.0", - "github.com/agext/levenshtein@v1.2.3", - "github.com/apparentlymart/go-textseg/v15@v15.0.0", - "github.com/davecgh/go-spew@v1.1.1", - "github.com/google/go-cmp@v0.6.0" + "github.com/apparentlymart/go-textseg/v15@v15.0.0" ], "Layer": {} }, @@ -601,11 +601,11 @@ ], "Indirect": true, "DependsOn": [ - "github.com/hashicorp/terraform-json@v0.18.0", + "github.com/hashicorp/hc-install@v0.6.1", "github.com/google/go-cmp@v0.6.0", - "github.com/zclconf/go-cty@v1.14.1", "github.com/hashicorp/go-version@v1.6.0", - "github.com/hashicorp/hc-install@v0.6.1" + "github.com/hashicorp/terraform-json@v0.18.0", + "github.com/zclconf/go-cty@v1.14.1" ], "Layer": {} }, @@ -619,9 +619,9 @@ "Indirect": true, "DependsOn": [ "github.com/davecgh/go-spew@v1.1.1", + "github.com/google/go-cmp@v0.6.0", "github.com/hashicorp/go-version@v1.6.0", "github.com/mitchellh/copystructure@v1.2.0", - "github.com/google/go-cmp@v0.6.0", "github.com/zclconf/go-cty@v1.14.1" ], "Layer": {} @@ -634,17 +634,17 @@ "MPL-2.0" ], "DependsOn": [ + "github.com/hashicorp/go-version@v1.6.0", + "github.com/hashicorp/hc-install@v0.6.1", "github.com/google/go-cmp@v0.6.0", + "github.com/russross/blackfriday@v1.6.0", "golang.org/x/exp@v0.0.0-20230626212559-97b1e661b5df", + "github.com/mattn/go-colorable@v0.1.13", "github.com/hashicorp/terraform-exec@v0.19.0", - "github.com/hashicorp/hc-install@v0.6.1", - "golang.org/x/text@v0.14.0", - "github.com/russross/blackfriday@v1.6.0", + "github.com/mitchellh/cli@v1.1.5", "github.com/hashicorp/terraform-json@v0.18.0", - "github.com/mattn/go-colorable@v0.1.13", - "github.com/zclconf/go-cty@v1.14.1", - "github.com/hashicorp/go-version@v1.6.0", - "github.com/mitchellh/cli@v1.1.5" + "golang.org/x/text@v0.14.0", + "github.com/zclconf/go-cty@v1.14.1" ], "Layer": {} }, @@ -656,8 +656,8 @@ "MPL-2.0" ], "DependsOn": [ - "github.com/google/go-cmp@v0.6.0", "github.com/hashicorp/terraform-plugin-go@v0.19.1", + "github.com/google/go-cmp@v0.6.0", "github.com/hashicorp/terraform-plugin-log@v0.9.0" ], "Layer": {} @@ -670,9 +670,9 @@ "MPL-2.0" ], "DependsOn": [ - "github.com/hashicorp/terraform-plugin-go@v0.19.1", "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/terraform-plugin-framework@v1.4.2" + "github.com/hashicorp/terraform-plugin-framework@v1.4.2", + "github.com/hashicorp/terraform-plugin-go@v0.19.1" ], "Layer": {} }, @@ -684,16 +684,16 @@ "MPL-2.0" ], "DependsOn": [ - "github.com/hashicorp/terraform-registry-address@v0.2.3", + "github.com/hashicorp/go-uuid@v1.0.3", "google.golang.org/protobuf@v1.31.0", + "github.com/google/go-cmp@v0.6.0", + "github.com/hashicorp/go-hclog@v1.5.0", "github.com/hashicorp/go-plugin@v1.6.0", - "github.com/mitchellh/go-testing-interface@v1.14.1", + "github.com/hashicorp/terraform-registry-address@v0.2.3", "github.com/vmihailenco/msgpack/v5@v5.4.1", "google.golang.org/grpc@v1.59.0", - "github.com/hashicorp/go-uuid@v1.0.3", "github.com/hashicorp/terraform-plugin-log@v0.9.0", - "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/go-hclog@v1.5.0" + "github.com/mitchellh/go-testing-interface@v1.14.1" ], "Layer": {} }, @@ -705,9 +705,9 @@ "MPL-2.0" ], "DependsOn": [ + "github.com/mitchellh/go-testing-interface@v1.14.1", "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/go-hclog@v1.5.0", - "github.com/mitchellh/go-testing-interface@v1.14.1" + "github.com/hashicorp/go-hclog@v1.5.0" ], "Layer": {} }, @@ -719,25 +719,25 @@ "MPL-2.0" ], "DependsOn": [ - "github.com/mitchellh/go-testing-interface@v1.14.1", - "github.com/zclconf/go-cty@v1.14.1", - "github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320", - "github.com/hashicorp/go-version@v1.6.0", + "github.com/hashicorp/go-hclog@v1.5.0", "github.com/hashicorp/hcl/v2@v2.19.1", - "github.com/hashicorp/terraform-json@v0.18.0", - "github.com/mitchellh/copystructure@v1.2.0", - "github.com/hashicorp/go-plugin@v1.6.0", "github.com/hashicorp/logutils@v1.0.0", + "github.com/hashicorp/go-uuid@v1.0.3", + "github.com/mitchellh/go-testing-interface@v1.14.1", "github.com/hashicorp/terraform-plugin-go@v0.19.1", - "github.com/hashicorp/hc-install@v0.6.1", "github.com/hashicorp/terraform-plugin-log@v0.9.0", - "github.com/mitchellh/reflectwalk@v1.0.2", - "golang.org/x/crypto@v0.15.0", + "github.com/zclconf/go-cty@v1.14.1", "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/go-uuid@v1.0.3", + "github.com/hashicorp/go-plugin@v1.6.0", "github.com/mitchellh/mapstructure@v1.5.0", - "github.com/hashicorp/go-hclog@v1.5.0", - "github.com/hashicorp/terraform-exec@v0.19.0" + "github.com/hashicorp/hc-install@v0.6.1", + "github.com/hashicorp/terraform-exec@v0.19.0", + "github.com/mitchellh/copystructure@v1.2.0", + "github.com/mitchellh/reflectwalk@v1.0.2", + "golang.org/x/crypto@v0.15.0", + "github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320", + "github.com/hashicorp/go-version@v1.6.0", + "github.com/hashicorp/terraform-json@v0.18.0" ], "Layer": {} }, @@ -750,9 +750,9 @@ ], "Indirect": true, "DependsOn": [ + "golang.org/x/net@v0.18.0", "github.com/google/go-cmp@v0.6.0", - "github.com/hashicorp/terraform-svchost@v0.1.1", - "golang.org/x/net@v0.18.0" + "github.com/hashicorp/terraform-svchost@v0.1.1" ], "Layer": {} }, @@ -765,11 +765,11 @@ ], "Indirect": true, "DependsOn": [ + "github.com/hashicorp/go-cleanhttp@v0.5.2", "github.com/google/go-cmp@v0.6.0", "github.com/hashicorp/go-version@v1.6.0", "github.com/zclconf/go-cty@v1.14.1", - "golang.org/x/net@v0.18.0", - "github.com/hashicorp/go-cleanhttp@v0.5.2" + "golang.org/x/net@v0.18.0" ], "Layer": {} }, @@ -870,12 +870,12 @@ ], "Indirect": true, "DependsOn": [ - "github.com/Masterminds/sprig/v3@v3.2.2", - "github.com/armon/go-radix@v1.0.0", - "github.com/bgentry/speakeasy@v0.1.0", "github.com/fatih/color@v1.16.0", "github.com/mattn/go-isatty@v0.0.20", - "github.com/posener/complete@v1.2.3" + "github.com/posener/complete@v1.2.3", + "github.com/Masterminds/sprig/v3@v3.2.2", + "github.com/armon/go-radix@v1.0.0", + "github.com/bgentry/speakeasy@v0.1.0" ], "Layer": {} }, @@ -892,6 +892,15 @@ ], "Layer": {} }, + { + "ID": "github.com/mitchellh/go-homedir@v1.1.0", + "Name": "github.com/mitchellh/go-homedir", + "Version": "1.1.0", + "Licenses": [ + "MIT" + ], + "Layer": {} + }, { "ID": "github.com/mitchellh/go-testing-interface@v1.14.1", "Name": "github.com/mitchellh/go-testing-interface", @@ -1134,8 +1143,8 @@ ], "Indirect": true, "DependsOn": [ - "golang.org/x/net@v0.18.0", - "golang.org/x/sys@v0.14.0" + "golang.org/x/sys@v0.14.0", + "golang.org/x/net@v0.18.0" ], "Layer": {} }, @@ -1235,10 +1244,10 @@ ], "Indirect": true, "DependsOn": [ - "github.com/google/go-cmp@v0.6.0", - "github.com/google/uuid@v1.3.1", - "golang.org/x/sys@v0.14.0", "google.golang.org/protobuf@v1.31.0", + "golang.org/x/sys@v0.14.0", + "github.com/google/uuid@v1.3.1", + "github.com/google/go-cmp@v0.6.0", "github.com/golang/protobuf@v1.5.3", "golang.org/x/net@v0.18.0", "google.golang.org/genproto/googleapis/rpc@v0.0.0-20231120223509-83a465c0220f" diff --git a/acc-coverage.png b/acc-coverage.png index 8bf0e79b..f5b4d761 100644 Binary files a/acc-coverage.png and b/acc-coverage.png differ diff --git a/acc-coverage.svg b/acc-coverage.svg index 30e3fb7c..0279e1fa 100644 --- a/acc-coverage.svg +++ b/acc-coverage.svg @@ -7,7 +7,7 @@ > - + - + env_ensure_data_source.go @@ -33,12 +33,12 @@ - + helpers.go @@ -46,12 +46,25 @@ - + homedir_get_data_source.go + + + + + + + +int_leftpad_data_source.go @@ -59,12 +72,12 @@ - + provider.go @@ -72,12 +85,12 @@ - + str_camel_data_source.go @@ -85,12 +98,12 @@ - + str_constant_data_source.go @@ -98,12 +111,12 @@ - + str_iterative_replace_data_source.go @@ -111,12 +124,12 @@ - + str_kebab_data_source.go @@ -124,12 +137,12 @@ - + str_leftpad_data_source.go @@ -137,12 +150,12 @@ - + str_pascal_data_source.go @@ -150,12 +163,12 @@ - + str_snake_data_source.go @@ -163,12 +176,12 @@ - + truncate_label_data_source.go diff --git a/bats/homedir_get.bats.sh b/bats/homedir_get.bats.sh new file mode 100644 index 00000000..3d381b05 --- /dev/null +++ b/bats/homedir_get.bats.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bats +# https://bats-core.readthedocs.io/en/stable/writing-tests.html + +@test "corefunc_homedir_get: attrs" { + run bash -c "tfschema data show -format=json corefunc_homedir_get | jq -Mrc '.attributes[]'" + + [ "$status" -eq 0 ] + [[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] + [[ ${lines[1]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] +} diff --git a/bats/tfschema_listing.bats.sh b/bats/tfschema_listing.bats.sh index 75f7a3fd..5cfe43c1 100644 --- a/bats/tfschema_listing.bats.sh +++ b/bats/tfschema_listing.bats.sh @@ -6,13 +6,14 @@ [ "$status" -eq 0 ] [[ ${lines[0]} == "corefunc_env_ensure" ]] - [[ ${lines[1]} == "corefunc_int_leftpad" ]] - [[ ${lines[2]} == "corefunc_str_camel" ]] - [[ ${lines[3]} == "corefunc_str_constant" ]] - [[ ${lines[4]} == "corefunc_str_iterative_replace" ]] - [[ ${lines[5]} == "corefunc_str_kebab" ]] - [[ ${lines[6]} == "corefunc_str_leftpad" ]] - [[ ${lines[7]} == "corefunc_str_pascal" ]] - [[ ${lines[8]} == "corefunc_str_snake" ]] - [[ ${lines[9]} == "corefunc_str_truncate_label" ]] + [[ ${lines[1]} == "corefunc_homedir_get" ]] + [[ ${lines[2]} == "corefunc_int_leftpad" ]] + [[ ${lines[3]} == "corefunc_str_camel" ]] + [[ ${lines[4]} == "corefunc_str_constant" ]] + [[ ${lines[5]} == "corefunc_str_iterative_replace" ]] + [[ ${lines[6]} == "corefunc_str_kebab" ]] + [[ ${lines[7]} == "corefunc_str_leftpad" ]] + [[ ${lines[8]} == "corefunc_str_pascal" ]] + [[ ${lines[9]} == "corefunc_str_snake" ]] + [[ ${lines[10]} == "corefunc_str_truncate_label" ]] } diff --git a/corefunc/homedir.go b/corefunc/homedir.go new file mode 100644 index 00000000..24c2e77b --- /dev/null +++ b/corefunc/homedir.go @@ -0,0 +1,33 @@ +// Copyright 2023, Ryan Parman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package corefunc + +import "github.com/mitchellh/go-homedir" + +/* +Homedir returns the home directory for the executing user without requiring CGO +for macOS. +*/ +func Homedir() (string, error) { + return homedir.Dir() // lint:allow_unwrapped_errors +} + +/* +HomedirExpand expands the path to include the home directory if the path is prefixed +with `~`. If it isn't prefixed with `~`, the path is returned as-is. +*/ +func HomedirExpand(path string) (string, error) { + return homedir.Expand(path) // lint:allow_unwrapped_errors +} diff --git a/corefunc/homedir_test.go b/corefunc/homedir_test.go new file mode 100644 index 00000000..72e56b4c --- /dev/null +++ b/corefunc/homedir_test.go @@ -0,0 +1,69 @@ +// Copyright 2023, Ryan Parman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package corefunc + +import ( + "os" + "testing" + + "github.com/northwood-labs/terraform-provider-corefunc/testfixtures" +) + +func TestHomedir(t *testing.T) { + if os.Getenv("GITHUB_ACTIONS") == "" { + t.SkipNow() + } + + for name, tc := range testfixtures.HomedirGetTestTable { + t.Run(name, func(t *testing.T) { + output, err := Homedir() + if err != nil { + t.Error("Failed to lookup the home directory") + } + + if output != tc.Expected { + t.Errorf("Expected %s, got %s", tc.Expected, output) + } + }) + } +} + +func BenchmarkHomedir(b *testing.B) { + b.ReportAllocs() + + for name := range testfixtures.HomedirGetTestTable { + b.Run(name, func(b *testing.B) { + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, _ = Homedir() // lint:allow_unhandled + } + }) + } +} + +func BenchmarkHomedirParallel(b *testing.B) { + b.ReportAllocs() + + for name := range testfixtures.HomedirGetTestTable { + b.Run(name, func(b *testing.B) { + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + _, _ = Homedir() // lint:allow_unhandled + } + }) + }) + } +} diff --git a/corefuncprovider/env_ensure_data_source_test.go b/corefuncprovider/env_ensure_data_source_test.go index 8d04e32d..dc5aa9e4 100644 --- a/corefuncprovider/env_ensure_data_source_test.go +++ b/corefuncprovider/env_ensure_data_source_test.go @@ -32,7 +32,7 @@ import ( func TestAccEnvEnsureDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.EnvEnsureTestTable { + for name, tc := range testfixtures.EnvEnsureTestTable { // lint:no_dupe var err error fmt.Printf( diff --git a/corefuncprovider/homedir_get_data_source.go b/corefuncprovider/homedir_get_data_source.go new file mode 100644 index 00000000..6cc8b1f5 --- /dev/null +++ b/corefuncprovider/homedir_get_data_source.go @@ -0,0 +1,166 @@ +// Copyright 2023, Ryan Parman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package corefuncprovider // lint:no_dupe + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/lithammer/dedent" + "github.com/northwood-labs/terraform-provider-corefunc/corefunc" +) + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &homedirGetDataSource{} + _ datasource.DataSourceWithConfigure = &homedirGetDataSource{} +) + +// homedirGetDataSource is the data source implementation. +type ( + homedirGetDataSource struct{} + + // homedirGetDataSourceModel maps the data source schema data. + homedirGetDataSourceModel struct { + Value types.String `tfsdk:"value"` + ID types.Int64 `tfsdk:"id"` + } +) + +// HomedirGetDataSource is a method that exposes its paired Go function as a +// Terraform Data Source. +func HomedirGetDataSource() datasource.DataSource { // lint:allow_return_interface + return &homedirGetDataSource{} +} + +// Metadata returns the data source type name. +func (d *homedirGetDataSource) Metadata( + ctx context.Context, + req datasource.MetadataRequest, + resp *datasource.MetadataResponse, +) { + tflog.Info(ctx, "Starting HomedirGet DataSource Metadata method.") + + resp.TypeName = req.ProviderTypeName + "_homedir_get" + + tflog.Debug(ctx, fmt.Sprintf("req.ProviderTypeName = %s", req.ProviderTypeName)) + tflog.Debug(ctx, fmt.Sprintf("resp.TypeName = %s", resp.TypeName)) + + tflog.Info(ctx, "Ending HomedirGet DataSource Metadata method.") +} + +// Schema defines the schema for the data source. +func (d *homedirGetDataSource) Schema( + ctx context.Context, + _ datasource.SchemaRequest, + resp *datasource.SchemaResponse, +) { + tflog.Info(ctx, "Starting HomedirGet DataSource Schema method.") + + resp.Schema = schema.Schema{ + MarkdownDescription: strings.TrimSpace(dedent.Dedent(` + Returns the path to the home directory of the current user. + + Maps to the ` + linkPackage("Homedir") + ` Go method, which can be used in ` + Terratest + `.`)), + Attributes: map[string]schema.Attribute{ + "id": schema.Int64Attribute{ + Description: "Not used. Required by the " + TPF + ".", + Computed: true, + }, + "value": schema.StringAttribute{ + Description: "The value of the string.", + Computed: true, + }, + }, + } + + tflog.Info(ctx, "Ending HomedirGet DataSource Schema method.") +} + +// Configure adds the provider configured client to the data source. +func (d *homedirGetDataSource) Configure( + ctx context.Context, + req datasource.ConfigureRequest, + _ *datasource.ConfigureResponse, +) { + tflog.Info(ctx, "Starting HomedirGet DataSource Configure method.") + + if req.ProviderData == nil { + return + } + + tflog.Info(ctx, "Ending HomedirGet DataSource Configure method.") +} + +func (d *homedirGetDataSource) Create( + ctx context.Context, + req resource.CreateRequest, // lint:allow_large_memory + resp *resource.CreateResponse, +) { + tflog.Info(ctx, "Starting HomedirGet DataSource Create method.") + + var plan homedirGetDataSourceModel + + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Info(ctx, "Ending HomedirGet DataSource Create method.") +} + +// Read refreshes the Terraform state with the latest data. +func (d *homedirGetDataSource) Read( // lint:no_dupe + ctx context.Context, + _ datasource.ReadRequest, // lint:allow_large_memory + resp *datasource.ReadResponse, +) { + tflog.Info(ctx, "Starting HomedirGet DataSource Read method.") + + var state homedirGetDataSourceModel + diags := resp.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + + state.ID = types.Int64Value(1) + + homedir, err := corefunc.Homedir() + if err != nil { + resp.Diagnostics.AddError( + "Unable to get the user's home directory", + err.Error(), + ) + + return + } + + state.Value = types.StringValue(homedir) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Info(ctx, "Ending HomedirGet DataSource Read method.") +} diff --git a/corefuncprovider/homedir_get_data_source_fixture.tftpl b/corefuncprovider/homedir_get_data_source_fixture.tftpl new file mode 100644 index 00000000..0ad4105e --- /dev/null +++ b/corefuncprovider/homedir_get_data_source_fixture.tftpl @@ -0,0 +1,2 @@ +data "corefunc_homedir_get" "home" {} +#=> {{ .Expected }} diff --git a/corefuncprovider/homedir_get_data_source_test.go b/corefuncprovider/homedir_get_data_source_test.go new file mode 100644 index 00000000..4a7447dc --- /dev/null +++ b/corefuncprovider/homedir_get_data_source_test.go @@ -0,0 +1,71 @@ +// Copyright 2023, Ryan Parman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package corefuncprovider + +import ( + "bytes" + "fmt" + "log" + "os" + "strings" + "testing" + "text/template" + + "github.com/northwood-labs/terraform-provider-corefunc/testfixtures" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccHomedirGetDataSource(t *testing.T) { + if os.Getenv("GITHUB_ACTIONS") == "" { + t.SkipNow() + } + + funcName := traceFuncName() + + for name, tc := range testfixtures.HomedirGetTestTable { // lint:no_dupe + fmt.Printf( + "=== RUN %s/%s\n", + strings.TrimSpace(funcName), + strings.TrimSpace(name), + ) + + buf := &bytes.Buffer{} + tmpl := template.Must( + template.ParseFiles("homedir_get_data_source_fixture.tftpl"), + ) + + err := tmpl.Execute(buf, tc) + if err != nil { + log.Fatalln(err) + } + + if os.Getenv("PROVIDER_DEBUG") != "" { + fmt.Fprintln(os.Stderr, buf.String()) + } + + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: providerConfig + buf.String(), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.corefunc_homedir_get.home", "value", tc.Expected), + ), + }, + }, + }) + } +} diff --git a/corefuncprovider/int_leftpad_data_source_test.go b/corefuncprovider/int_leftpad_data_source_test.go index 028ccb5f..3ad81004 100644 --- a/corefuncprovider/int_leftpad_data_source_test.go +++ b/corefuncprovider/int_leftpad_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccIntLeftpadDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.IntLeftPadTestTable { + for name, tc := range testfixtures.IntLeftPadTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/provider.go b/corefuncprovider/provider.go index 5af33f5e..68138925 100644 --- a/corefuncprovider/provider.go +++ b/corefuncprovider/provider.go @@ -102,6 +102,7 @@ func (p *coreFuncProvider) DataSources(ctx context.Context) []func() datasource. return []func() datasource.DataSource{ EnvEnsureDataSource, + HomedirGetDataSource, IntLeftpadDataSource, StrCamelDataSource, StrConstantDataSource, diff --git a/corefuncprovider/str_camel_data_source_test.go b/corefuncprovider/str_camel_data_source_test.go index 16b52129..85c4f861 100644 --- a/corefuncprovider/str_camel_data_source_test.go +++ b/corefuncprovider/str_camel_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrCamelDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrCamelTestTable { + for name, tc := range testfixtures.StrCamelTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_constant_data_source_test.go b/corefuncprovider/str_constant_data_source_test.go index 122c0b5c..9db06c7e 100644 --- a/corefuncprovider/str_constant_data_source_test.go +++ b/corefuncprovider/str_constant_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrConstantDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrConstantTestTable { + for name, tc := range testfixtures.StrConstantTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_iterative_replace_data_source_test.go b/corefuncprovider/str_iterative_replace_data_source_test.go index 49b10d5a..b50d28d6 100644 --- a/corefuncprovider/str_iterative_replace_data_source_test.go +++ b/corefuncprovider/str_iterative_replace_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrIterativeReplaceDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrIterativeReplaceTestTable { + for name, tc := range testfixtures.StrIterativeReplaceTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_kebab_data_source_test.go b/corefuncprovider/str_kebab_data_source_test.go index ae20ecd2..de04a9c0 100644 --- a/corefuncprovider/str_kebab_data_source_test.go +++ b/corefuncprovider/str_kebab_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrKebabDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrKebabTestTable { + for name, tc := range testfixtures.StrKebabTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_leftpad_data_source_test.go b/corefuncprovider/str_leftpad_data_source_test.go index 23d81f24..b18f0d79 100644 --- a/corefuncprovider/str_leftpad_data_source_test.go +++ b/corefuncprovider/str_leftpad_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrLeftpadDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrLeftPadTestTable { + for name, tc := range testfixtures.StrLeftPadTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_pascal_data_source_test.go b/corefuncprovider/str_pascal_data_source_test.go index d0bc8210..3ef4d534 100644 --- a/corefuncprovider/str_pascal_data_source_test.go +++ b/corefuncprovider/str_pascal_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrPascalDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrPascalTestTable { + for name, tc := range testfixtures.StrPascalTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/str_snake_data_source_test.go b/corefuncprovider/str_snake_data_source_test.go index 76144aa1..0c1869b3 100644 --- a/corefuncprovider/str_snake_data_source_test.go +++ b/corefuncprovider/str_snake_data_source_test.go @@ -31,7 +31,7 @@ import ( func TestAccStrSnakeDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.StrSnakeTestTable { + for name, tc := range testfixtures.StrSnakeTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/corefuncprovider/truncate_label_data_source_test.go b/corefuncprovider/truncate_label_data_source_test.go index fd259399..8b8d12d7 100644 --- a/corefuncprovider/truncate_label_data_source_test.go +++ b/corefuncprovider/truncate_label_data_source_test.go @@ -59,7 +59,7 @@ func TestAccTruncateLabelDataSourceDefaultMaxLength64(t *testing.T) { func TestAccTruncateLabelDataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.TruncateLabelTestTable { + for name, tc := range testfixtures.TruncateLabelTestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/docs/data-sources/homedir_get.md b/docs/data-sources/homedir_get.md new file mode 100644 index 00000000..f9dc5644 --- /dev/null +++ b/docs/data-sources/homedir_get.md @@ -0,0 +1,32 @@ + + +# corefunc_homedir_get (Data Source) + +Returns the path to the home directory of the current user. + +Maps to the [`corefunc.Homedir()`](https://pkg.go.dev/github.com/northwood-labs/terraform-provider-corefunc/corefunc#Homedir) Go method, which can be used in [Terratest](https://terratest.gruntwork.io). + +## Example Usage + +```terraform +data "corefunc_homedir_get" "home" {} +#=> /Users/me +``` + + +## Schema + +### Read-Only + +* `id` (Number) Not used. Required by the [Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework). +* `value` (String) The value of the string. + + diff --git a/examples/data-sources/corefunc_homedir_get/data-source.tf b/examples/data-sources/corefunc_homedir_get/data-source.tf new file mode 100644 index 00000000..efbccbaf --- /dev/null +++ b/examples/data-sources/corefunc_homedir_get/data-source.tf @@ -0,0 +1,2 @@ +data "corefunc_homedir_get" "home" {} +#=> /Users/me diff --git a/examples/data-sources/corefunc_homedir_get/versions.tftpl b/examples/data-sources/corefunc_homedir_get/versions.tftpl new file mode 100644 index 00000000..90ced86e --- /dev/null +++ b/examples/data-sources/corefunc_homedir_get/versions.tftpl @@ -0,0 +1,13 @@ +terraform { + required_version = "~> 1.1, < 1.6" + + required_providers { + corefunc = { + source = "northwood-labs/corefunc" + version = "~> 1.0" + } + } +} + +# There are no configuration options +provider "corefunc" {} diff --git a/generator/corefuncprovider/data_source_test.gotmpl b/generator/corefuncprovider/data_source_test.gotmpl index 00de65de..67b66414 100644 --- a/generator/corefuncprovider/data_source_test.gotmpl +++ b/generator/corefuncprovider/data_source_test.gotmpl @@ -31,7 +31,7 @@ import ( func TestAcc{{ .PascalStrip }}DataSource(t *testing.T) { funcName := traceFuncName() - for name, tc := range testfixtures.{{ .PascalStrip }}TestTable { + for name, tc := range testfixtures.{{ .PascalStrip }}TestTable { // lint:no_dupe fmt.Printf( "=== RUN %s/%s\n", strings.TrimSpace(funcName), diff --git a/go.mod b/go.mod index d433dfc9..447231bc 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 github.com/lithammer/dedent v1.1.0 + github.com/mitchellh/go-homedir v1.1.0 github.com/northwood-labs/golang-utils/archstring v0.0.0-20230302161720-ec685e2f274a github.com/northwood-labs/golang-utils/exiterrorf v0.0.0-20230302161720-ec685e2f274a github.com/spf13/cobra v1.8.0 @@ -22,8 +23,8 @@ require ( require ( github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -33,7 +34,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.3.1 // indirect + github.com/google/uuid v1.4.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -43,7 +44,7 @@ require ( github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.6.1 // indirect + github.com/hashicorp/hc-install v0.6.2 // indirect github.com/hashicorp/hcl/v2 v2.19.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.19.0 // indirect @@ -52,8 +53,8 @@ require ( github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect - github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.15 // indirect + github.com/huandu/xstrings v1.4.0 // indirect + github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -69,18 +70,18 @@ require ( github.com/posener/complete v1.2.3 // indirect github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/zclconf/go-cty v1.14.1 // indirect - golang.org/x/crypto v0.15.0 // indirect - golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect + golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect diff --git a/go.sum b/go.sum index 3839a234..9925f481 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,14 @@ github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJ github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= @@ -45,12 +50,14 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= +github.com/go-git/go-git/v5 v5.10.1 h1:tu8/D8i+TWxgKpzQ3Vc43e+kkhXqtsZCKI/egajKnxk= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -68,6 +75,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gtramontina/ooze v0.2.0 h1:QDW1zeq1TQgTLbIWuk76GCgNV3adkamYxY1aJNYp/Bc= @@ -96,6 +105,8 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hc-install v0.6.1 h1:IGxShH7AVhPaSuSJpKtVi/EFORNjO+OYVJJrAtGG2mY= github.com/hashicorp/hc-install v0.6.1/go.mod h1:0fW3jpg+wraYSnFDJ6Rlie3RvLf1bIqVIkzoon4KoVE= +github.com/hashicorp/hc-install v0.6.2 h1:V1k+Vraqz4olgZ9UzKiAcbman9i9scg9GgSt/U3mw/M= +github.com/hashicorp/hc-install v0.6.2/go.mod h1:2JBpd+NCFKiHiu/yYCGaPyPHhZLxXTpz8oreHa/a3Ps= github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= @@ -127,9 +138,14 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= +github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -165,6 +181,8 @@ github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2c github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= @@ -204,6 +222,8 @@ github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2Iqp github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -234,12 +254,17 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= @@ -275,6 +300,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= diff --git a/templates/data-sources/int_leftpad.md.tmpl b/templates/data-sources/int_leftpad.md.tmpl deleted file mode 100644 index a71c4c73..00000000 --- a/templates/data-sources/int_leftpad.md.tmpl +++ /dev/null @@ -1,20 +0,0 @@ - - -# {{ .Name }} ({{ .Type }}) - -{{ .Description | trimspace }} - -## Example Usage - -{{ tffile "examples/data-sources/corefunc_int_leftpad/data-source.tf" }} - -{{ .SchemaMarkdown | trimspace }} - - diff --git a/templates/data-sources/str_leftpad.md.tmpl b/templates/data-sources/str_leftpad.md.tmpl deleted file mode 100644 index 93577be9..00000000 --- a/templates/data-sources/str_leftpad.md.tmpl +++ /dev/null @@ -1,20 +0,0 @@ - - -# {{ .Name }} ({{ .Type }}) - -{{ .Description | trimspace }} - -## Example Usage - -{{ tffile "examples/data-sources/corefunc_str_leftpad/data-source.tf" }} - -{{ .SchemaMarkdown | trimspace }} - - diff --git a/testfixtures/homedir_get.go b/testfixtures/homedir_get.go new file mode 100644 index 00000000..b4cefaa4 --- /dev/null +++ b/testfixtures/homedir_get.go @@ -0,0 +1,40 @@ +// Copyright 2023, Ryan Parman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testfixtures // lint:no_dupe + +import ( + "os/user" +) + +// HomedirGetTestTable is used by both the standard Go tests and also the +// Terraform acceptance tests. +// +var HomedirGetTestTable = map[string]struct { // lint:no_dupe + Input string + Expected string +}{ + "home": { + Expected: getUserHome(), + }, +} + +func getUserHome() string { + u, err := user.Current() + if err != nil { + return "" + } + + return u.HomeDir +} diff --git a/unit-coverage.png b/unit-coverage.png index 5f9705a3..32ff82f1 100644 Binary files a/unit-coverage.png and b/unit-coverage.png differ diff --git a/unit-coverage.svg b/unit-coverage.svg index 50108c63..5de1592e 100644 --- a/unit-coverage.svg +++ b/unit-coverage.svg @@ -7,25 +7,25 @@ > - + github.com/northwood-labs/terraform-provider-corefunc/corefunc - + env_ensure.go @@ -33,12 +33,25 @@ - + + +homedir.go + + + + + + int_pad.go @@ -46,12 +59,12 @@ - + str_iterative_replace.go @@ -59,12 +72,12 @@ - + str_pad.go @@ -72,7 +85,7 @@ - +