From 87acbc181b082aa96f68a807881d632fd3f60cb4 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 29 May 2024 14:52:24 +0000 Subject: [PATCH] backport of commit 164f091f1069688002b43c323c9ce62b14fd1780 --- packer_test/loading_test.go | 28 ++++++++++++++++++++++++++++ packer_test/sample_config.json | 7 +++++++ 2 files changed, 35 insertions(+) create mode 100644 packer_test/sample_config.json diff --git a/packer_test/loading_test.go b/packer_test/loading_test.go index 59126a053..1f1d8ceee 100644 --- a/packer_test/loading_test.go +++ b/packer_test/loading_test.go @@ -209,3 +209,31 @@ func (ts *PackerTestSuite) TestLoadWithOnlyReleaseFlag() { }) } } + +func (ts *PackerTestSuite) TestWithLegacyConfigAndComponents() { + pluginDir, cleanup := ts.MakePluginDir("1.0.0") + defer cleanup() + + workdir, cleanup := TempWorkdir(ts.T(), "./sample_config.json", "./templates/simple.json", "./templates/simple.pkr.hcl") + defer cleanup() + + for _, cmd := range []string{"validate", "build"} { + ts.Run(fmt.Sprintf("%s simple JSON template with config.json and components defined", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginDir).SetWD(workdir). + SetArgs(cmd, "simple.json"). + AddEnv("PACKER_CONFIG", filepath.Join(workdir, "sample_config.json")). + Assert(MustFail(), + Grep("Your configuration file describes some legacy components", grepStderr), + Grep("packer-provisioner-super-shell", grepStderr)) + }) + + ts.Run(fmt.Sprintf("%s simple HCL2 template with config.json and components defined", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginDir).SetWD(workdir). + SetArgs(cmd, "simple.pkr.hcl"). + AddEnv("PACKER_CONFIG", filepath.Join(workdir, "sample_config.json")). + Assert(MustFail(), + Grep("Your configuration file describes some legacy components", grepStderr), + Grep("packer-provisioner-super-shell", grepStderr)) + }) + } +} diff --git a/packer_test/sample_config.json b/packer_test/sample_config.json new file mode 100644 index 000000000..80f755813 --- /dev/null +++ b/packer_test/sample_config.json @@ -0,0 +1,7 @@ +{ + "disable_checkpoint": true, + "disable_checkpoint_signature": true, + "provisioners": { + "super-shell": "packer-provisioner-super-shell" + } +}