From 5e360211da8ea5801c3c912740ba3a895801834a Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 7 Jul 2023 19:17:28 +0000 Subject: [PATCH] Update fix command This change is major refactor of the fix command, and it's underlying fixer interface. This change adds support for the `-diff` flag which displays the diff between the unfixed and fixed files, if available. Along with the refactor the ability to apply multiple fixes to the same file without potential write conflicts where previous changes were removed after reprocessing. * Add a scan function that returns a list of files to apply a fix on to provide flexibility in the future for collecting a list of files. * Replace cmp.Diff with github.com/pkg/diff for better file diffs * Return error when missing directory argument * Add error handling when trying to read any scanned files --- cmd/packer-sdc/internal/fix/README.md | 14 +- cmd/packer-sdc/internal/fix/cmd.go | 158 ++++++++++++++++++ cmd/packer-sdc/internal/fix/fix.go | 115 ++----------- cmd/packer-sdc/internal/fix/gocty.go | 128 +++++++------- cmd/packer-sdc/internal/fix/gocty_test.go | 57 ++++--- .../fix/testdata/fixed/many-replace/go.mod | 2 +- .../both}/go.mod | 0 .../testdata/missing-requires/go-cty/go.mod | 19 +++ .../missing-requires/packer-plugin-sdk/go.mod | 19 +++ .../fix/testdata/unfixed/basic/fixed.go.mod | 2 +- .../unfixed/many-replace/fixed.go.mod | 2 +- .../fix/testdata/unfixed/version/fixed.go.mod | 2 +- .../fix/testdata/unfixed/version/go.mod | 2 +- go.mod | 1 + go.sum | 2 + 15 files changed, 317 insertions(+), 206 deletions(-) create mode 100644 cmd/packer-sdc/internal/fix/cmd.go rename cmd/packer-sdc/internal/fix/testdata/{norequire => missing-requires/both}/go.mod (100%) create mode 100644 cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.mod create mode 100644 cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.mod diff --git a/cmd/packer-sdc/internal/fix/README.md b/cmd/packer-sdc/internal/fix/README.md index dc7285b82..a1ecb208e 100644 --- a/cmd/packer-sdc/internal/fix/README.md +++ b/cmd/packer-sdc/internal/fix/README.md @@ -1,12 +1,16 @@ -## `fix` +## `packer-sdc fix` -Fix rewrites parts of the plugin codebase to address known issues or common workarounds used within plugins consuming the Packer plugin SDK. +Fix rewrites parts of the plugin codebase to address known issues or common workarounds used within plugins consuming the Packer plugin SDK. Options: - -check Check for potential fixes [dry-run]. + -diff If the -diff flag is set, no files are rewritten. Instead, fix prints the differences a rewrite would introduce. Available Fixes: - gocty - Adds a replace directive for github.com/zclconf/go-cty to github.com/nywilken/go-cty + gocty Adds a replace directive for github.com/zclconf/go-cty to github.com/nywilken/go-cty + + +### Related Issues +Use `packer-sdc fix` to resolve the [cty.Value does not implement gob.GobEncoder](https://github.com/hashicorp/packer-plugin-sdk/issues/187) + diff --git a/cmd/packer-sdc/internal/fix/cmd.go b/cmd/packer-sdc/internal/fix/cmd.go new file mode 100644 index 000000000..d1bc6ef6d --- /dev/null +++ b/cmd/packer-sdc/internal/fix/cmd.go @@ -0,0 +1,158 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package fix + +import ( + "bytes" + "errors" + "flag" + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/pkg/diff" +) + +const cmdPrefix string = "fix" + +// Command is the base entry for the fix sub-command. +type Command struct { + Dir string + Diff bool +} + +// Flags contain the default flags for the fix sub-command. +func (cmd *Command) Flags() *flag.FlagSet { + fs := flag.NewFlagSet(cmdPrefix, flag.ExitOnError) + fs.BoolVar(&cmd.Diff, "diff", false, "if set prints the differences a rewrite would introduce.") + return fs +} + +// Help displays usage for the command. +func (cmd *Command) Help() string { + var s strings.Builder + for _, fix := range availableFixes { + s.WriteString(fmt.Sprintf(" %s\t\t%s\n", fix.name, fix.description)) + } + + helpText := ` +Usage: packer-sdc fix [options] directory + + Fix rewrites parts of the plugin codebase to address known issues or + common workarounds used within plugins consuming the Packer plugin SDK. + +Options: + -diff If the -diff flag is set fix prints the differences an applied fix would introduce. + +Available fixes: +%s` + return fmt.Sprintf(helpText, s.String()) +} + +// Run executes the command +func (cmd *Command) Run(args []string) int { + if err := cmd.run(args); err != nil { + fmt.Printf("%v", err) + return 1 + } + return 0 +} + +func (cmd *Command) run(args []string) error { + f := cmd.Flags() + err := f.Parse(args) + if err != nil { + return errors.New("unable to parse flags for fix command") + } + + if f.NArg() != 1 { + err := fmt.Errorf("packer-sdc fix: missing directory argument\n%s", cmd.Help()) + return err + } + + dir := f.Arg(0) + if dir == "." || dir == "./..." { + dir, _ = os.Getwd() + } + + info, err := os.Stat(dir) + if err != nil && os.IsNotExist(err) { + return errors.New("a plugin root directory must be specified or a dot for the current directory") + } + + if !info.IsDir() { + return errors.New("a plugin root directory must be specified or a dot for the current directory") + } + + dir, err = filepath.Abs(dir) + if err != nil { + return errors.New("unable to determine the absolute path for the provided plugin root directory") + } + cmd.Dir = dir + + return processFiles(cmd.Dir, cmd.Diff) +} + +func (cmd *Command) Synopsis() string { + return "Rewrites parts of the plugin codebase to address known issues or common workarounds within plugins consuming the Packer plugin SDK." +} + +func processFiles(rootDir string, showDiff bool) error { + srcFiles := make(map[string][]byte) + fixedFiles := make(map[string][]byte) + + var hasErrors error + for _, f := range availableFixes { + matches, err := f.scan(rootDir) + if err != nil { + return fmt.Errorf("failed to apply %s fix: %s", f.name, err) + } + + //matches contains all files to apply the said fix on + for _, filename := range matches { + if _, ok := srcFiles[filename]; !ok { + bs, err := os.ReadFile(filename) + if err != nil { + hasErrors = errors.Join(hasErrors, err) + } + srcFiles[filename] = bytes.Clone(bs) + } + + fixedData, ok := fixedFiles[filename] + if !ok { + fixedData = bytes.Clone(srcFiles[filename]) + } + + fixedData, err := f.fix(filename, fixedData) + if err != nil { + hasErrors = errors.Join(hasErrors, err) + continue + } + if bytes.Equal(fixedData, srcFiles[filename]) { + continue + } + fixedFiles[filename] = bytes.Clone(fixedData) + } + } + + if hasErrors != nil { + return hasErrors + } + + if showDiff { + for filename, fixedData := range fixedFiles { + diff.Text(filename, filename+"fixed", string(srcFiles[filename]), string(fixedData), os.Stdout) + } + return nil + } + + for filename, fixedData := range fixedFiles { + fmt.Println(filename) + info, _ := os.Stat(filename) + os.WriteFile(filename, fixedData, info.Mode()) + } + + return nil +} diff --git a/cmd/packer-sdc/internal/fix/fix.go b/cmd/packer-sdc/internal/fix/fix.go index bdfdea4c6..c1dede85b 100644 --- a/cmd/packer-sdc/internal/fix/fix.go +++ b/cmd/packer-sdc/internal/fix/fix.go @@ -3,116 +3,25 @@ package fix -import ( - _ "embed" //used for embedding the command README - "flag" - "log" - "os" - "path/filepath" - - "github.com/pkg/errors" -) - -const cmdPrefix string = "fix" - -var ( - // availableFixes to apply to a plugin - refer to init func - availableFixes fixes - - //go:embed README.md - readme string -) - -// Command is the base entry for the fix sub-command -type Command struct { - Dir string - Check bool +// Fixer applies all defined fixes on a plugin dir; a Fixer should be idempotent. +// The caller of any fix is responsible for checking if the file context have changed. +type fixer interface { + fix(filename string, data []byte) ([]byte, error) } -func (cmd *Command) Flags() *flag.FlagSet { - fs := flag.NewFlagSet(cmdPrefix, flag.ExitOnError) - fs.BoolVar(&cmd.Check, "check", false, "Check plugin for potential fixes [dry-run].") - return fs -} - -// Help displays usage for the command. -func (cmd *Command) Help() string { - return "\n" + readme -} - -// Run executes the command -func (cmd *Command) Run(args []string) int { - if err := cmd.run(args); err != nil { - log.Printf("%v", err) - return 1 - } - return 0 -} - -func (cmd *Command) run(args []string) error { - f := cmd.Flags() - err := f.Parse(args) - if err != nil { - return errors.Wrap(err, "[packer-sdc fix] unable to parse flags") - } - - if f.NArg() != 1 { - cmd.Help() - return errors.New("a plugin root directory must be specified") - } - - dir := f.Arg(0) - if dir == "." { - dir, _ = os.Getwd() - } - - info, err := os.Stat(dir) - if err != nil && os.IsNotExist(err) { - return errors.New("a plugin root directory must be specified") - } - - if !info.IsDir() { - return errors.New("a plugin root directory must be specified") - } - - dir, err = filepath.Abs(dir) - if err != nil { - return errors.New("unable to determine the absolute path for the plugin root directory") - } - cmd.Dir = dir - - for _, f := range availableFixes { - err = f.Fix(cmd.Dir, cmd.Check) - if err != nil { - return errors.Errorf("failed to apply %s fix: %s", f.Name, err) - } - } - return nil -} - -func (cmd *Command) Synopsis() string { - return "Rewrites parts of the plugin codebase to address known issues or common workarounds within the plugin API." -} - -// Fixer applies all defined fixes on the provide plugin dir. -// A dryRun argument is available to check if a fix will be applied without executing. -// A Fixer should be idempotent. -type Fixer interface { - Fix(pluginRootDir string, dryRun bool) error -} type fix struct { - Name, Description string - Fixer + name, description string + scan func(dir string) ([]string, error) + fixer } -type fixes []fix +var ( + // availableFixes to apply to a plugin - refer to init func + availableFixes []fix +) func init() { availableFixes = []fix{ - { - Name: "gocty", - Description: "Adds a replace directive for github.com/zclconf/go-cty to github.com/nywilken/go-cty", - Fixer: NewGoCtyFixer(), - }, + goctyFix, } } diff --git a/cmd/packer-sdc/internal/fix/gocty.go b/cmd/packer-sdc/internal/fix/gocty.go index d654f6ac1..8bd4507a8 100644 --- a/cmd/packer-sdc/internal/fix/gocty.go +++ b/cmd/packer-sdc/internal/fix/gocty.go @@ -6,119 +6,109 @@ package fix import ( "fmt" "os" - "path/filepath" + "path" - "github.com/pkg/errors" "golang.org/x/mod/modfile" ) const ( - oldPath string = "github.com/zclconf/go-cty" - newPath string = "github.com/nywilken/go-cty" - newVersion string = "1.12.1" + sdkPath string = "github.com/hashicorp/packer-plugin-sdk" + oldPath string = "github.com/zclconf/go-cty" + newPath string = "github.com/nywilken/go-cty" + newVersion string = "1.12.1" + modFilename string = "go.mod" ) -type GoCtyFix struct { - OldPath, NewPath, NewVersion string - data []byte -} - -// NewGoCtyFixer is an entry to the go-cty fix command -func NewGoCtyFixer() GoCtyFix { - return GoCtyFix{ +var goctyFix = fix{ + name: "gocty", + description: "Adds a replace directive for github.com/zclconf/go-cty to github.com/nywilken/go-cty", + scan: modPaths, + fixer: goCtyFix{ OldPath: oldPath, NewPath: newPath, NewVersion: newVersion, + }, +} + +// modPaths scans the incoming dir for potential go.mod files to fix. +func modPaths(dir string) ([]string, error) { + paths := []string{ + path.Join(dir, modFilename), } + return paths, nil + +} + +type goCtyFix struct { + OldPath, NewPath, NewVersion string } -func (f GoCtyFix) modFileFormmatedVersion() string { +func (f goCtyFix) modFileFormattedVersion() string { return fmt.Sprintf("v%s", f.NewVersion) } -func (f GoCtyFix) isUnfixed(dir string) (bool, error) { - modFilePath := filepath.Join(dir, "go.mod") +// Fix applies a replace directive in a projects go.mod file for f.OldPath to f.NewPath. +// This fix applies to the replacement of github.com/zclconf/go-cty, as described in https://github.com/hashicorp/packer-plugin-sdk/issues/187 +// The return data contains the data file with the applied fix. In cases where the fix is already applied or not needed the original data is returned. +func (f goCtyFix) fix(modFilePath string, data []byte) ([]byte, error) { if _, err := os.Stat(modFilePath); err != nil { - return false, errors.Wrap(err, "failed to find go.mod file") - } - data, err := os.ReadFile(modFilePath) - if err != nil { - return false, errors.Wrap(err, "failed to read go.mod file") + return nil, fmt.Errorf("failed to find go.mod file %s", modFilePath) } + mf, err := modfile.Parse(modFilePath, data, nil) if err != nil { - return false, errors.Wrap(err, "failed to parse go.mod file") + return nil, fmt.Errorf("%s: failed to parse go.mod file: %v", modFilePath, err) } - // Basic go.mod with no module dependencies + // fix doesn't apply to go.mod with no module dependencies if len(mf.Require) == 0 { - return false, nil + return data, nil } - // Brute force will be better to Sort then search - var found bool + var requiresSDK, requiresGoCty bool for _, req := range mf.Require { + if req.Mod.Path == sdkPath { + requiresSDK = true + } if req.Mod.Path == f.OldPath { - found = true + requiresGoCty = true + } + + if requiresSDK && requiresGoCty { break } } - if !found { - return false, nil + if !(requiresSDK && requiresGoCty) { + return data, nil } - if len(mf.Replace) == 0 { - return true, nil - } - // what happens with multiple replace for _, r := range mf.Replace { if r.Old.Path != f.OldPath { continue } + if r.New.Path != f.NewPath { - return false, errors.New("found unexpected replace for " + r.Old.Path) + return nil, fmt.Errorf("%s: found unexpected replace for %s", modFilePath, r.Old.Path) } - return r.New.Version != f.modFileFormmatedVersion(), nil - } - return true, nil -} -func (f GoCtyFix) Fix(dir string, check bool) error { - ok, err := f.isUnfixed(dir) - if err != nil { - return err - } - if !ok { - return nil - } - if check { - fmt.Printf("%s %5s\n", "gocty", "Unfixed!") - return nil - } - - modFilePath := filepath.Join(dir, "go.mod") - info, err := os.Stat(modFilePath) - if err != nil { - return errors.Wrap(err, "failed to find plugin go.mod file") - } - data, err := os.ReadFile(modFilePath) - if err != nil { - return errors.Wrap(err, "failed to read plugin go.mod file") - } - mf, err := modfile.Parse(modFilePath, data, nil) - if err != nil { - return errors.Wrap(err, "failed to parse plugin go.mod file") + if r.New.Version == f.modFileFormattedVersion() { + return data, nil + } } if err := mf.DropReplace(f.OldPath, ""); err != nil { - return errors.Wrap(err, "failed to apply gocty fix") + return nil, fmt.Errorf("%s: failed to drop previously added replacement fix %v", modFilePath, err) } - commentSuffix := " // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187" - if err := mf.AddReplace(f.OldPath, "", f.NewPath, f.modFileFormmatedVersion()+commentSuffix); err != nil { - return errors.Wrap(err, "failed to apply gocty fix") + + commentSuffix := " // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187" + if err := mf.AddReplace(f.OldPath, "", f.NewPath, f.modFileFormattedVersion()+commentSuffix); err != nil { + return nil, fmt.Errorf("%s: failed to apply go-cty fix: %v", modFilePath, err) } - bytes, _ := mf.Format() - return os.WriteFile(modFilePath, bytes, info.Mode()) + newData, err := mf.Format() + if err != nil { + return nil, err + } + return newData, nil } diff --git a/cmd/packer-sdc/internal/fix/gocty_test.go b/cmd/packer-sdc/internal/fix/gocty_test.go index b094cdfc5..132898edb 100644 --- a/cmd/packer-sdc/internal/fix/gocty_test.go +++ b/cmd/packer-sdc/internal/fix/gocty_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package fix import ( @@ -19,6 +22,14 @@ func copyToTempFile(t testing.TB, data []byte) string { return dir } +func goctyTestFixer() goCtyFix { + return goCtyFix{ + OldPath: oldPath, + NewPath: newPath, + NewVersion: newVersion, + } +} + func TestFixGoCty_FixNotNeeded(t *testing.T) { tt := []struct { name string @@ -28,9 +39,17 @@ func TestFixGoCty_FixNotNeeded(t *testing.T) { name: "empty mod file", fixtureDir: filepath.Join("testdata", "empty"), }, + { + name: "no requires for go-cty or packer-plugin-sdk modules", + fixtureDir: filepath.Join("testdata", "missing-requires", "both"), + }, { name: "no go-cty module dependency", - fixtureDir: filepath.Join("testdata", "norequire"), + fixtureDir: filepath.Join("testdata", "missing-requires", "go-cty"), + }, + { + name: "no packer-plugin-sdk module dependency", + fixtureDir: filepath.Join("testdata", "missing-requires", "packer-plugin-sdk"), }, { name: "previously fixed mod file", @@ -43,24 +62,19 @@ func TestFixGoCty_FixNotNeeded(t *testing.T) { } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - var dryRun bool - testFixer := NewGoCtyFixer() + testFixer := goctyTestFixer() testFixtureDir := tc.fixtureDir - expectedFn := filepath.Join(testFixtureDir, "go.mod") + expectedFn := filepath.Join(testFixtureDir, modFilename) expected, err := os.ReadFile(expectedFn) if err != nil { t.Fatalf("failed while reading text fixture: %s", err) } outFileDir := copyToTempFile(t, expected) - if err := testFixer.Fix(outFileDir, dryRun); err != nil { - t.Fatalf("expected dryrun check to not err but it did: %v", err) - } - outFileFn := filepath.Join(outFileDir, "go.mod") - fixed, err := os.ReadFile(outFileFn) + fixed, err := testFixer.fix(outFileFn, expected) if err != nil { - t.Fatalf("failed while reading text fixture: %s", err) + t.Fatalf("expected fix to not err but it did: %v", err) } if diff := cmp.Diff(expected, fixed); diff != "" { @@ -93,8 +107,7 @@ func TestFixGoCty_Unfixed(t *testing.T) { } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - var dryRun bool - testFixer := NewGoCtyFixer() + testFixer := goctyTestFixer() if tc.versionStr != "" { testFixer.NewVersion = tc.versionStr } @@ -106,14 +119,10 @@ func TestFixGoCty_Unfixed(t *testing.T) { } outFileDir := copyToTempFile(t, unfixed) - if err := testFixer.Fix(outFileDir, dryRun); err != nil { - t.Fatalf("expected dryrun check to not err but it did: %v", err) - } - - outFileFn := filepath.Join(outFileDir, "go.mod") - fixed, err := os.ReadFile(outFileFn) + outFileFn := filepath.Join(outFileDir, modFilename) + fixed, err := testFixer.fix(outFileFn, unfixed) if err != nil { - t.Fatalf("failed while reading text fixture: %s", err) + t.Fatalf("expected fix to not err but it did: %v", err) } expectedFn := filepath.Join(testFixtureDir, "fixed.go.mod") @@ -131,17 +140,17 @@ func TestFixGoCty_Unfixed(t *testing.T) { } func TestFixGoCty_InvalidReplacePath(t *testing.T) { - var dryRun bool - testFixer := NewGoCtyFixer() + testFixer := goctyTestFixer() testFixtureDir := filepath.Join("testdata", "invalid") - expectedFn := filepath.Join(testFixtureDir, "go.mod") + expectedFn := filepath.Join(testFixtureDir, modFilename) expected, err := os.ReadFile(expectedFn) if err != nil { t.Fatalf("failed while reading text fixture: %s", err) } outFileDir := copyToTempFile(t, expected) - if err := testFixer.Fix(outFileDir, dryRun); err == nil { - t.Fatalf("expected dryrun check to err but it didn't: %v", err) + outFileFn := filepath.Join(outFileDir, modFilename) + if _, err := testFixer.fix(outFileFn, expected); err == nil { + t.Fatalf("expected fix to err but it didn't: %v", err) } } diff --git a/cmd/packer-sdc/internal/fix/testdata/fixed/many-replace/go.mod b/cmd/packer-sdc/internal/fix/testdata/fixed/many-replace/go.mod index 710a67d77..b011417ab 100644 --- a/cmd/packer-sdc/internal/fix/testdata/fixed/many-replace/go.mod +++ b/cmd/packer-sdc/internal/fix/testdata/fixed/many-replace/go.mod @@ -10,4 +10,4 @@ require ( replace github.com/hashicorp/packer-plugin-sdk => github.com/example/packer-plugin-sdk v0.5.0 -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 +replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/cmd/packer-sdc/internal/fix/testdata/norequire/go.mod b/cmd/packer-sdc/internal/fix/testdata/missing-requires/both/go.mod similarity index 100% rename from cmd/packer-sdc/internal/fix/testdata/norequire/go.mod rename to cmd/packer-sdc/internal/fix/testdata/missing-requires/both/go.mod diff --git a/cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.mod b/cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.mod new file mode 100644 index 000000000..ad38b4bd0 --- /dev/null +++ b/cmd/packer-sdc/internal/fix/testdata/missing-requires/go-cty/go.mod @@ -0,0 +1,19 @@ +module example + +require ( + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d + github.com/google/go-cmp v0.3.0 + github.com/hashicorp/go-cleanhttp v0.5.0 + github.com/hashicorp/go-multierror v1.1.0 + github.com/hashicorp/go-safetemp v1.0.0 + github.com/hashicorp/go-version v1.1.0 + github.com/hashicorp/packer-plugin-sdk v0.4.0 + github.com/klauspost/compress v1.11.2 + github.com/mitchellh/go-homedir v1.0.0 + github.com/mitchellh/go-testing-interface v1.0.0 + github.com/ulikunitz/xz v0.5.8 +) + +require github.com/hashicorp/errwrap v1.0.0 // indirect + +go 1.18 diff --git a/cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.mod b/cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.mod new file mode 100644 index 000000000..aace57136 --- /dev/null +++ b/cmd/packer-sdc/internal/fix/testdata/missing-requires/packer-plugin-sdk/go.mod @@ -0,0 +1,19 @@ +module example + +require ( + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d + github.com/google/go-cmp v0.3.0 + github.com/hashicorp/go-cleanhttp v0.5.0 + github.com/hashicorp/go-multierror v1.1.0 + github.com/hashicorp/go-safetemp v1.0.0 + github.com/hashicorp/go-version v1.1.0 + github.com/klauspost/compress v1.11.2 + github.com/mitchellh/go-homedir v1.0.0 + github.com/mitchellh/go-testing-interface v1.0.0 + github.com/ulikunitz/xz v0.5.8 + github.com/zclconf/go-cty v1.13.1 +) + +require github.com/hashicorp/errwrap v1.0.0 // indirect + +go 1.18 diff --git a/cmd/packer-sdc/internal/fix/testdata/unfixed/basic/fixed.go.mod b/cmd/packer-sdc/internal/fix/testdata/unfixed/basic/fixed.go.mod index 21244afc7..da456395d 100644 --- a/cmd/packer-sdc/internal/fix/testdata/unfixed/basic/fixed.go.mod +++ b/cmd/packer-sdc/internal/fix/testdata/unfixed/basic/fixed.go.mod @@ -8,4 +8,4 @@ require ( github.com/zclconf/go-cty v1.10.0 ) -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 +replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/cmd/packer-sdc/internal/fix/testdata/unfixed/many-replace/fixed.go.mod b/cmd/packer-sdc/internal/fix/testdata/unfixed/many-replace/fixed.go.mod index 710a67d77..b011417ab 100644 --- a/cmd/packer-sdc/internal/fix/testdata/unfixed/many-replace/fixed.go.mod +++ b/cmd/packer-sdc/internal/fix/testdata/unfixed/many-replace/fixed.go.mod @@ -10,4 +10,4 @@ require ( replace github.com/hashicorp/packer-plugin-sdk => github.com/example/packer-plugin-sdk v0.5.0 -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 +replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.12.1 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/cmd/packer-sdc/internal/fix/testdata/unfixed/version/fixed.go.mod b/cmd/packer-sdc/internal/fix/testdata/unfixed/version/fixed.go.mod index 4fec4a8d9..90da23380 100644 --- a/cmd/packer-sdc/internal/fix/testdata/unfixed/version/fixed.go.mod +++ b/cmd/packer-sdc/internal/fix/testdata/unfixed/version/fixed.go.mod @@ -8,4 +8,4 @@ require ( github.com/zclconf/go-cty v1.10.0 ) -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.1 // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 +replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.1 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/cmd/packer-sdc/internal/fix/testdata/unfixed/version/go.mod b/cmd/packer-sdc/internal/fix/testdata/unfixed/version/go.mod index 4fec4a8d9..90da23380 100644 --- a/cmd/packer-sdc/internal/fix/testdata/unfixed/version/go.mod +++ b/cmd/packer-sdc/internal/fix/testdata/unfixed/version/go.mod @@ -8,4 +8,4 @@ require ( github.com/zclconf/go-cty v1.10.0 ) -replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.1 // add by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 +replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.1 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187 diff --git a/go.mod b/go.mod index d42f13c9a..c5c590c63 100644 --- a/go.mod +++ b/go.mod @@ -58,6 +58,7 @@ require ( github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db github.com/pierrec/lz4 v2.6.1+incompatible // indirect + github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e github.com/pkg/errors v0.9.1 github.com/pkg/sftp v1.13.2 github.com/ryanuber/go-glob v1.0.0 diff --git a/go.sum b/go.sum index 1b95da008..1a8fe2887 100644 --- a/go.sum +++ b/go.sum @@ -374,6 +374,8 @@ github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=