From 6103e67ae97434991e1d85d368dbea738f6c8041 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:20:34 -0400 Subject: [PATCH] fix(repo): fix source.list path validation on Windows (#1429) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- .github/workflows/testacc.yml | 1 - fwprovider/nodes/apt/repo_test.go | 10 +--------- fwprovider/nodes/apt/resource_repo.go | 3 +-- fwprovider/validators/strings.go | 12 ++++++------ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/testacc.yml b/.github/workflows/testacc.yml index 96033831..cfc33ad9 100644 --- a/.github/workflows/testacc.yml +++ b/.github/workflows/testacc.yml @@ -10,7 +10,6 @@ on: jobs: acceptance: - if: github.repository_owner == 'bpg' strategy: fail-fast: false matrix: diff --git a/fwprovider/nodes/apt/repo_test.go b/fwprovider/nodes/apt/repo_test.go index 4b7438cf..3b51641b 100644 --- a/fwprovider/nodes/apt/repo_test.go +++ b/fwprovider/nodes/apt/repo_test.go @@ -36,15 +36,8 @@ const ( testAccResourceStandardRepoHandle = "no-subscription" ) -func testAccRepoInit(t *testing.T) *test.Environment { - t.Helper() - t.Parallel() - - return test.InitEnvironment(t) -} - func TestAccDataSourceRepo(t *testing.T) { - te := testAccRepoInit(t) + te := test.InitEnvironment(t) tests := []struct { name string @@ -213,7 +206,6 @@ func TestAccDataSourceStandardRepo(t *testing.T) { // [Read]: https://developer.hashicorp.com/terraform/plugin/framework/resources/read // [Update]: https://developer.hashicorp.com/terraform/plugin/framework/resources/update func TestAccResourceRepoValidInput(t *testing.T) { - t.Helper() t.Parallel() te := test.InitEnvironment(t) diff --git a/fwprovider/nodes/apt/resource_repo.go b/fwprovider/nodes/apt/resource_repo.go index eabb8ab9..9599e060 100644 --- a/fwprovider/nodes/apt/resource_repo.go +++ b/fwprovider/nodes/apt/resource_repo.go @@ -9,7 +9,6 @@ package apt import ( "context" "fmt" - "path/filepath" "strconv" "strings" @@ -179,7 +178,7 @@ func (r *resourceRepo) ImportState( rp.Node = types.StringValue(parts[0]) - if !filepath.IsAbs(parts[1]) { + if !strings.HasPrefix(parts[1], "/") { resp.Diagnostics.AddError( "Invalid resource ID", fmt.Sprintf("given source list file path %q is not an absolute path: %s", parts[1], idFormatErrMsg), diff --git a/fwprovider/validators/strings.go b/fwprovider/validators/strings.go index 0c6177da..90ac935b 100644 --- a/fwprovider/validators/strings.go +++ b/fwprovider/validators/strings.go @@ -1,15 +1,15 @@ /* - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at https://mozilla.org/MPL/2.0/. -*/ + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ package validators import ( "fmt" - "path/filepath" "regexp" + "strings" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -19,7 +19,7 @@ import ( func AbsoluteFilePathValidator() validator.String { return NewParseValidator( func(s string) (string, error) { - if filepath.IsAbs(s) { + if strings.HasPrefix(s, "/") { return s, nil }