This adds the new `required_plugins` block to be nested under the packer block. Example: ```hcl packer { required_plugins { aws = { version = ">= 2.7.0" source = "azr/aws" } azure = ">= 2.7.0" } } ``` For example on darwin_amd64 Packer will install those under : * "${PACKER_HOME_DIR}/plugin/github.com/azr/amazon/packer-plugin-amazon_2.7.0_x5.0_darwin_amd64" * "${PACKER_HOME_DIR}/plugin/github.com/hashicorp/azure/packer-plugin-azure_2.7.0_x5.0_darwin_amd64_x5" + docs + tests
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package command
|
|
|
|
import (
|
|
"bytes"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
|
"github.com/hashicorp/packer/builder/file"
|
|
"github.com/hashicorp/packer/packer"
|
|
shell_local "github.com/hashicorp/packer/provisioner/shell-local"
|
|
"github.com/hashicorp/packer/provisioner/sleep"
|
|
)
|
|
|
|
// testCoreConfigBuilder creates a packer CoreConfig that has a file builder
|
|
// available. This allows us to test a builder that writes files to disk.
|
|
func testCoreConfigSleepBuilder(t *testing.T) *packer.CoreConfig {
|
|
components := packer.ComponentFinder{
|
|
PluginConfig: &packer.PluginConfig{
|
|
Builders: packer.MapOfBuilder{
|
|
"file": func() (packersdk.Builder, error) { return &file.Builder{}, nil },
|
|
},
|
|
Provisioners: packer.MapOfProvisioner{
|
|
"sleep": func() (packersdk.Provisioner, error) { return &sleep.Provisioner{}, nil },
|
|
"shell-local": func() (packersdk.Provisioner, error) { return &shell_local.Provisioner{}, nil },
|
|
},
|
|
},
|
|
}
|
|
return &packer.CoreConfig{
|
|
Components: components,
|
|
}
|
|
}
|
|
|
|
// testMetaFile creates a Meta object that includes a file builder
|
|
func testMetaSleepFile(t *testing.T) Meta {
|
|
var out, err bytes.Buffer
|
|
return Meta{
|
|
CoreConfig: testCoreConfigSleepBuilder(t),
|
|
Ui: &packersdk.BasicUi{
|
|
Writer: &out,
|
|
ErrorWriter: &err,
|
|
},
|
|
}
|
|
}
|
|
|
|
func TestBuildSleepTimeout(t *testing.T) {
|
|
defer cleanup()
|
|
|
|
c := &BuildCommand{
|
|
Meta: testMetaSleepFile(t),
|
|
}
|
|
|
|
args := []string{
|
|
filepath.Join(testFixture("timeout"), "template.json"),
|
|
}
|
|
|
|
defer cleanup()
|
|
|
|
if code := c.Run(args); code == 0 {
|
|
fatalCommand(t, c.Meta)
|
|
}
|
|
|
|
for _, f := range []string{"roses.txt", "fuchsias.txt", "lilas.txt"} {
|
|
if !fileExists(f) {
|
|
t.Errorf("Expected to find %s", f)
|
|
}
|
|
}
|
|
|
|
for _, f := range []string{"campanules.txt"} {
|
|
if fileExists(f) {
|
|
t.Errorf("Expected to not find %s", f)
|
|
}
|
|
}
|
|
}
|