From a5b0e37d7ea17762b0e99bd5fcf5d976cb00be84 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 24 Feb 2021 16:32:27 -0800 Subject: [PATCH 01/10] docker extraction POC --- builder/docker/artifact_export_test.go | 11 - builder/docker/artifact_import_test.go | 58 ----- builder/docker/builder_test.go | 11 - builder/docker/communicator_test.go | 239 ------------------ builder/docker/config_test.go | 147 ----------- builder/docker/driver_docker_test.go | 7 - builder/docker/driver_mock_test.go | 7 - builder/docker/step_commit_test.go | 68 ----- builder/docker/step_export_test.go | 101 -------- builder/docker/step_pull_test.go | 104 -------- builder/docker/step_run_test.go | 97 ------- .../docker/step_set_generated_data_test.go | 51 ---- builder/docker/step_temp_dir_test.go | 52 ---- builder/docker/step_test.go | 21 -- .../docker/test-fixtures/manycakes/chocolate | 1 - .../docker/test-fixtures/manycakes/vanilla | 1 - .../docker/test-fixtures/onecakes/strawberry | 1 - builder/docker/version/version.go | 13 - command/plugin.go | 10 - go.mod | 1 + go.sum | 53 +--- .../docker-import/post-processor_test.go | 11 - .../docker-import/version/version.go | 13 - .../docker-push/post-processor_test.go | 121 --------- post-processor/docker-push/version/version.go | 13 - .../docker-save/post-processor_test.go | 11 - post-processor/docker-save/version/version.go | 13 - .../docker-tag/post-processor_test.go | 196 -------------- post-processor/docker-tag/version/version.go | 13 - provisioner/ansible-local/provisioner_test.go | 2 +- .../builder}/docker/artifact_export.go | 0 .../builder}/docker/artifact_import.go | 0 .../builder}/docker/builder.go | 0 .../builder}/docker/comm.go | 0 .../builder}/docker/communicator.go | 0 .../builder}/docker/config.go | 0 .../builder}/docker/config.hcl2spec.go | 0 .../builder}/docker/driver.go | 0 .../builder}/docker/driver_docker.go | 0 .../builder}/docker/driver_mock.go | 0 .../builder}/docker/ecr_login.go | 69 ++++- .../builder}/docker/exec.go | 0 .../builder}/docker/step_commit.go | 0 .../builder}/docker/step_connect_docker.go | 0 .../builder}/docker/step_export.go | 0 .../builder}/docker/step_pull.go | 0 .../builder}/docker/step_run.go | 0 .../docker/step_set_generated_data.go | 0 .../builder}/docker/step_temp_dir.go | 0 .../docker/windows_container_communicator.go | 0 .../docker-import/post-processor.go | 5 +- .../docker-import/post-processor.hcl2spec.go | 0 .../docker-push/post-processor.go | 6 +- .../docker-push/post-processor.hcl2spec.go | 0 .../docker-save/post-processor.go | 6 +- .../docker-save/post-processor.hcl2spec.go | 0 .../docker-tag/post-processor.go | 4 +- .../docker-tag/post-processor.hcl2spec.go | 0 vendor/modules.txt | 6 + 59 files changed, 79 insertions(+), 1464 deletions(-) delete mode 100644 builder/docker/artifact_export_test.go delete mode 100644 builder/docker/artifact_import_test.go delete mode 100644 builder/docker/builder_test.go delete mode 100644 builder/docker/communicator_test.go delete mode 100644 builder/docker/config_test.go delete mode 100644 builder/docker/driver_docker_test.go delete mode 100644 builder/docker/driver_mock_test.go delete mode 100644 builder/docker/step_commit_test.go delete mode 100644 builder/docker/step_export_test.go delete mode 100644 builder/docker/step_pull_test.go delete mode 100644 builder/docker/step_run_test.go delete mode 100644 builder/docker/step_set_generated_data_test.go delete mode 100644 builder/docker/step_temp_dir_test.go delete mode 100644 builder/docker/step_test.go delete mode 100644 builder/docker/test-fixtures/manycakes/chocolate delete mode 100644 builder/docker/test-fixtures/manycakes/vanilla delete mode 100644 builder/docker/test-fixtures/onecakes/strawberry delete mode 100644 builder/docker/version/version.go delete mode 100644 post-processor/docker-import/post-processor_test.go delete mode 100644 post-processor/docker-import/version/version.go delete mode 100644 post-processor/docker-push/post-processor_test.go delete mode 100644 post-processor/docker-push/version/version.go delete mode 100644 post-processor/docker-save/post-processor_test.go delete mode 100644 post-processor/docker-save/version/version.go delete mode 100644 post-processor/docker-tag/post-processor_test.go delete mode 100644 post-processor/docker-tag/version/version.go rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/artifact_export.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/artifact_import.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/builder.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/comm.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/communicator.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/config.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/config.hcl2spec.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/driver.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/driver_docker.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/driver_mock.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/ecr_login.go (53%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/exec.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_commit.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_connect_docker.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_export.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_pull.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_run.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_set_generated_data.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/step_temp_dir.go (100%) rename {builder => vendor/github.com/hashicorp/packer-plugin-docker/builder}/docker/windows_container_communicator.go (100%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-import/post-processor.go (94%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-import/post-processor.hcl2spec.go (100%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-push/post-processor.go (93%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-push/post-processor.hcl2spec.go (100%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-save/post-processor.go (90%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-save/post-processor.hcl2spec.go (100%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-tag/post-processor.go (95%) rename {post-processor => vendor/github.com/hashicorp/packer-plugin-docker/post-processor}/docker-tag/post-processor.hcl2spec.go (100%) diff --git a/builder/docker/artifact_export_test.go b/builder/docker/artifact_export_test.go deleted file mode 100644 index d8514b9a2..000000000 --- a/builder/docker/artifact_export_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package docker - -import ( - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestExportArtifact_impl(t *testing.T) { - var _ packersdk.Artifact = new(ExportArtifact) -} diff --git a/builder/docker/artifact_import_test.go b/builder/docker/artifact_import_test.go deleted file mode 100644 index 648290262..000000000 --- a/builder/docker/artifact_import_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package docker - -import ( - "errors" - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestImportArtifact_impl(t *testing.T) { - var _ packersdk.Artifact = new(ImportArtifact) -} - -func TestImportArtifactBuilderId(t *testing.T) { - a := &ImportArtifact{BuilderIdValue: "foo"} - if a.BuilderId() != "foo" { - t.Fatalf("bad: %#v", a.BuilderId()) - } -} - -func TestImportArtifactFiles(t *testing.T) { - a := &ImportArtifact{} - if a.Files() != nil { - t.Fatalf("bad: %#v", a.Files()) - } -} - -func TestImportArtifactId(t *testing.T) { - a := &ImportArtifact{IdValue: "foo"} - if a.Id() != "foo" { - t.Fatalf("bad: %#v", a.Id()) - } -} - -func TestImportArtifactDestroy(t *testing.T) { - d := new(MockDriver) - a := &ImportArtifact{ - Driver: d, - IdValue: "foo", - } - - // No error - if err := a.Destroy(); err != nil { - t.Fatalf("err: %s", err) - } - if !d.DeleteImageCalled { - t.Fatal("delete image should be called") - } - if d.DeleteImageId != "foo" { - t.Fatalf("bad: %#v", d.DeleteImageId) - } - - // With an error - d.DeleteImageErr = errors.New("foo") - if err := a.Destroy(); err != d.DeleteImageErr { - t.Fatalf("err: %#v", err) - } -} diff --git a/builder/docker/builder_test.go b/builder/docker/builder_test.go deleted file mode 100644 index 377483148..000000000 --- a/builder/docker/builder_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package docker - -import ( - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestBuilder_implBuilder(t *testing.T) { - var _ packersdk.Builder = new(Builder) -} diff --git a/builder/docker/communicator_test.go b/builder/docker/communicator_test.go deleted file mode 100644 index 275751c0c..000000000 --- a/builder/docker/communicator_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package docker - -import ( - "crypto/sha256" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "os/exec" - "testing" - - builderT "github.com/hashicorp/packer-plugin-sdk/acctest" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -// RenderConfig helps create dynamic packer template configs for parsing by -// builderT without having to write the config to a file. -func RenderConfig(builderConfig map[string]interface{}, provisionerConfig []map[string]interface{}) string { - // set up basic build template - t := map[string][]map[string]interface{}{ - "builders": { - // Setup basic docker config - map[string]interface{}{ - "type": "test", - "image": "ubuntu", - "discard": true, - }, - }, - "provisioners": []map[string]interface{}{}, - } - // apply special builder overrides - for k, v := range builderConfig { - t["builders"][0][k] = v - } - // Apply special provisioner overrides - t["provisioners"] = append(t["provisioners"], provisionerConfig...) - - j, _ := json.Marshal(t) - return string(j) -} - -// TestUploadDownload verifies that basic upload / download functionality works -func TestUploadDownload(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1") - } - - dockerBuilderExtraConfig := map[string]interface{}{ - "run_command": []string{"-d", "-i", "-t", "{{.Image}}", "/bin/sh"}, - } - - dockerProvisionerConfig := []map[string]interface{}{ - { - "type": "file", - "source": "test-fixtures/onecakes/strawberry", - "destination": "/strawberry-cake", - }, - { - "type": "file", - "source": "/strawberry-cake", - "destination": "my-strawberry-cake", - "direction": "download", - }, - } - - configString := RenderConfig(dockerBuilderExtraConfig, dockerProvisionerConfig) - - // this should be a precheck - cmd := exec.Command("docker", "-v") - err := cmd.Run() - if err != nil { - t.Error("docker command not found; please make sure docker is installed") - } - - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - // Verify that the thing we downloaded is the same thing we sent up. - // Complain loudly if it isn't. - inputFile, err := ioutil.ReadFile("test-fixtures/onecakes/strawberry") - if err != nil { - return fmt.Errorf("Unable to read input file: %s", err) - } - outputFile, err := ioutil.ReadFile("my-strawberry-cake") - if err != nil { - return fmt.Errorf("Unable to read output file: %s", err) - } - if sha256.Sum256(inputFile) != sha256.Sum256(outputFile) { - return fmt.Errorf("Input and output files do not match\n"+ - "Input:\n%s\nOutput:\n%s\n", inputFile, outputFile) - } - return nil - }, - Teardown: func() error { - // Cleanup. Honestly I don't know why you would want to get rid - // of my strawberry cake. It's so tasty! Do you not like cake? Are you a - // cake-hater? Or are you keeping all the cake all for yourself? So selfish! - os.Remove("my-strawberry-cake") - return nil - }, - }) -} - -// TestLargeDownload verifies that files are the appropriate size after being -// downloaded. This is to identify and fix the race condition in #2793. You may -// need to use github.com/cbednarski/rerun to verify since this problem occurs -// only intermittently. -func TestLargeDownload(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1") - } - - dockerProvisionerConfig := []map[string]interface{}{ - { - "type": "shell", - "inline": []string{ - "dd if=/dev/urandom of=/tmp/cupcake bs=1M count=2", - "dd if=/dev/urandom of=/tmp/bigcake bs=1M count=100", - "sync", - "md5sum /tmp/cupcake /tmp/bigcake", - }, - }, - { - "type": "file", - "source": "/tmp/cupcake", - "destination": "cupcake", - "direction": "download", - }, - { - "type": "file", - "source": "/tmp/bigcake", - "destination": "bigcake", - "direction": "download", - }, - } - - configString := RenderConfig(map[string]interface{}{}, dockerProvisionerConfig) - - // this should be a precheck - cmd := exec.Command("docker", "-v") - err := cmd.Run() - if err != nil { - t.Error("docker command not found; please make sure docker is installed") - } - - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - Check: func(a []packersdk.Artifact) error { - // Verify that the things we downloaded are the right size. Complain loudly - // if they are not. - // - // cupcake should be 2097152 bytes - // bigcake should be 104857600 bytes - cupcake, err := os.Stat("cupcake") - if err != nil { - t.Fatalf("Unable to stat cupcake file: %s", err) - } - cupcakeExpected := int64(2097152) - if cupcake.Size() != cupcakeExpected { - t.Errorf("Expected cupcake to be %d bytes; found %d", cupcakeExpected, cupcake.Size()) - } - - bigcake, err := os.Stat("bigcake") - if err != nil { - t.Fatalf("Unable to stat bigcake file: %s", err) - } - bigcakeExpected := int64(104857600) - if bigcake.Size() != bigcakeExpected { - t.Errorf("Expected bigcake to be %d bytes; found %d", bigcakeExpected, bigcake.Size()) - } - - // TODO if we can, calculate a sha inside the container and compare to the - // one we get after we pull it down. We will probably have to parse the log - // or ui output to do this because we use /dev/urandom to create the file. - - // if sha256.Sum256(inputFile) != sha256.Sum256(outputFile) { - // t.Fatalf("Input and output files do not match\n"+ - // "Input:\n%s\nOutput:\n%s\n", inputFile, outputFile) - // } - return nil - }, - Teardown: func() error { - os.Remove("cupcake") - os.Remove("bigcake") - return nil - }, - }) - -} - -// TestFixUploadOwner verifies that owner of uploaded files is the user the container is running as. -func TestFixUploadOwner(t *testing.T) { - if os.Getenv("PACKER_ACC") == "" { - t.Skip("This test is only run with PACKER_ACC=1") - } - - cmd := exec.Command("docker", "-v") - err := cmd.Run() - if err != nil { - t.Error("docker command not found; please make sure docker is installed") - } - - dockerBuilderExtraConfig := map[string]interface{}{ - "run_command": []string{"-d", "-i", "-t", "-u", "42", "{{.Image}}", "/bin/sh"}, - } - - testFixUploadOwnerProvisionersTemplate := []map[string]interface{}{ - { - "type": "file", - "source": "test-fixtures/onecakes/strawberry", - "destination": "/tmp/strawberry-cake", - }, - { - "type": "file", - "source": "test-fixtures/manycakes", - "destination": "/tmp/", - }, - { - "type": "shell", - "inline": "touch /tmp/testUploadOwner", - }, - { - "type": "shell", - "inline": []string{ - "[ $(stat -c %u /tmp/strawberry-cake) -eq 42 ] || (echo 'Invalid owner of /tmp/strawberry-cake' && exit 1)", - "[ $(stat -c %u /tmp/testUploadOwner) -eq 42 ] || (echo 'Invalid owner of /tmp/testUploadOwner' && exit 1)", - "find /tmp/manycakes | xargs -n1 -IFILE /bin/sh -c '[ $(stat -c %u FILE) -eq 42 ] || (echo \"Invalid owner of FILE\" && exit 1)'", - }, - }, - } - - configString := RenderConfig(dockerBuilderExtraConfig, testFixUploadOwnerProvisionersTemplate) - builderT.Test(t, builderT.TestCase{ - Builder: &Builder{}, - Template: configString, - }) -} diff --git a/builder/docker/config_test.go b/builder/docker/config_test.go deleted file mode 100644 index cf66e1a7d..000000000 --- a/builder/docker/config_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package docker - -import ( - "io/ioutil" - "os" - "testing" -) - -func testConfig() map[string]interface{} { - return map[string]interface{}{ - "export_path": "foo", - "image": "bar", - } -} - -func testConfigStruct(t *testing.T) *Config { - var c Config - warns, errs := c.Prepare(testConfig()) - if len(warns) > 0 { - t.Fatalf("bad: %#v", len(warns)) - } - if errs != nil { - t.Fatalf("bad: %#v", errs) - } - - return &c -} - -func testConfigErr(t *testing.T, warns []string, err error) { - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err == nil { - t.Fatal("should error") - } -} - -func testConfigOk(t *testing.T, warns []string, err error) { - if len(warns) > 0 { - t.Fatalf("bad: %#v", warns) - } - if err != nil { - t.Fatalf("bad: %s", err) - } -} - -func TestConfigPrepare_exportPath(t *testing.T) { - td, err := ioutil.TempDir("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(td) - - raw := testConfig() - - // No export path. This is invalid. Previously this would not error during - // validation and as a result the failure would happen at build time. - delete(raw, "export_path") - var c Config - warns, errs := c.Prepare(raw) - testConfigErr(t, warns, errs) - - // Good export path - raw["export_path"] = "good" - warns, errs = c.Prepare(raw) - testConfigOk(t, warns, errs) - - // Bad export path (directory) - raw["export_path"] = td - warns, errs = c.Prepare(raw) - testConfigErr(t, warns, errs) -} - -func TestConfigPrepare_exportPathAndCommit(t *testing.T) { - raw := testConfig() - - // Export but no commit (explicit default) - raw["commit"] = false - warns, errs := (&Config{}).Prepare(raw) - testConfigOk(t, warns, errs) - - // Commit AND export specified (invalid) - raw["commit"] = true - warns, errs = (&Config{}).Prepare(raw) - testConfigErr(t, warns, errs) - - // Commit but no export - delete(raw, "export_path") - warns, errs = (&Config{}).Prepare(raw) - testConfigOk(t, warns, errs) -} - -func TestConfigPrepare_exportDiscard(t *testing.T) { - raw := testConfig() - - // Export but no discard (explicit default) - raw["discard"] = false - warns, errs := (&Config{}).Prepare(raw) - testConfigOk(t, warns, errs) - - // Discard AND export (invalid) - raw["discard"] = true - warns, errs = (&Config{}).Prepare(raw) - testConfigErr(t, warns, errs) - - // Discard but no export - raw["discard"] = true - delete(raw, "export_path") - warns, errs = (&Config{}).Prepare(raw) - testConfigOk(t, warns, errs) -} - -func TestConfigPrepare_image(t *testing.T) { - raw := testConfig() - - // No image - delete(raw, "image") - var c Config - warns, errs := c.Prepare(raw) - testConfigErr(t, warns, errs) - - // Good image - raw["image"] = "path" - warns, errs = c.Prepare(raw) - testConfigOk(t, warns, errs) -} - -func TestConfigPrepare_pull(t *testing.T) { - raw := testConfig() - - // No pull set - delete(raw, "pull") - var c Config - warns, errs := c.Prepare(raw) - testConfigOk(t, warns, errs) - if !c.Pull { - t.Fatal("should pull by default") - } - - // Pull set - raw["pull"] = false - warns, errs = c.Prepare(raw) - testConfigOk(t, warns, errs) - if c.Pull { - t.Fatal("should not pull") - } -} diff --git a/builder/docker/driver_docker_test.go b/builder/docker/driver_docker_test.go deleted file mode 100644 index dbc0ebc11..000000000 --- a/builder/docker/driver_docker_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package docker - -import "testing" - -func TestDockerDriver_impl(t *testing.T) { - var _ Driver = new(DockerDriver) -} diff --git a/builder/docker/driver_mock_test.go b/builder/docker/driver_mock_test.go deleted file mode 100644 index b7d144813..000000000 --- a/builder/docker/driver_mock_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package docker - -import "testing" - -func TestMockDriver_impl(t *testing.T) { - var _ Driver = new(MockDriver) -} diff --git a/builder/docker/step_commit_test.go b/builder/docker/step_commit_test.go deleted file mode 100644 index 80030a315..000000000 --- a/builder/docker/step_commit_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package docker - -import ( - "context" - "errors" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func testStepCommitState(t *testing.T) multistep.StateBag { - state := testState(t) - state.Put("container_id", "foo") - return state -} - -func TestStepCommit_impl(t *testing.T) { - var _ multistep.Step = new(StepCommit) -} - -func TestStepCommit(t *testing.T) { - state := testStepCommitState(t) - step := new(StepCommit) - defer step.Cleanup(state) - - driver := state.Get("driver").(*MockDriver) - driver.CommitImageId = "bar" - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we did the right thing - if !driver.CommitCalled { - t.Fatal("should've called") - } - - // verify the ID is saved - idRaw, ok := state.GetOk("image_id") - if !ok { - t.Fatal("should've saved ID") - } - - id := idRaw.(string) - if id != driver.CommitImageId { - t.Fatalf("bad: %#v", id) - } -} - -func TestStepCommit_error(t *testing.T) { - state := testStepCommitState(t) - step := new(StepCommit) - defer step.Cleanup(state) - - driver := state.Get("driver").(*MockDriver) - driver.CommitErr = errors.New("foo") - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - - // verify the ID is not saved - if _, ok := state.GetOk("image_id"); ok { - t.Fatal("shouldn't save image ID") - } -} diff --git a/builder/docker/step_export_test.go b/builder/docker/step_export_test.go deleted file mode 100644 index 30246cc91..000000000 --- a/builder/docker/step_export_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package docker - -import ( - "bytes" - "context" - "errors" - "io/ioutil" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func testStepExportState(t *testing.T) multistep.StateBag { - state := testState(t) - state.Put("container_id", "foo") - return state -} - -func TestStepExport_impl(t *testing.T) { - var _ multistep.Step = new(StepExport) -} - -func TestStepExport(t *testing.T) { - state := testStepExportState(t) - step := new(StepExport) - defer step.Cleanup(state) - - // Create a tempfile for our output path - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - tf.Close() - defer os.Remove(tf.Name()) - - config := state.Get("config").(*Config) - config.ExportPath = tf.Name() - driver := state.Get("driver").(*MockDriver) - driver.ExportReader = bytes.NewReader([]byte("data!")) - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we did the right thing - if !driver.ExportCalled { - t.Fatal("should've exported") - } - if driver.ExportID != "foo" { - t.Fatalf("bad: %#v", driver.ExportID) - } - - // verify the data exported to the file - contents, err := ioutil.ReadFile(tf.Name()) - if err != nil { - t.Fatalf("err: %s", err) - } - - if string(contents) != "data!" { - t.Fatalf("bad: %#v", string(contents)) - } -} - -func TestStepExport_error(t *testing.T) { - state := testStepExportState(t) - step := new(StepExport) - defer step.Cleanup(state) - - // Create a tempfile for our output path - tf, err := ioutil.TempFile("", "packer") - if err != nil { - t.Fatalf("err: %s", err) - } - tf.Close() - - if err := os.Remove(tf.Name()); err != nil { - t.Fatalf("err: %s", err) - } - - config := state.Get("config").(*Config) - config.ExportPath = tf.Name() - driver := state.Get("driver").(*MockDriver) - driver.ExportError = errors.New("foo") - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - - // verify we have an error - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should have error") - } - - // verify we didn't make that file - if _, err := os.Stat(tf.Name()); err == nil { - t.Fatal("export path shouldn't exist") - } -} diff --git a/builder/docker/step_pull_test.go b/builder/docker/step_pull_test.go deleted file mode 100644 index 234058f57..000000000 --- a/builder/docker/step_pull_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package docker - -import ( - "context" - "errors" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepPull_impl(t *testing.T) { - var _ multistep.Step = new(StepPull) -} - -func TestStepPull(t *testing.T) { - state := testState(t) - step := new(StepPull) - defer step.Cleanup(state) - - config := state.Get("config").(*Config) - driver := state.Get("driver").(*MockDriver) - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we did the right thing - if !driver.PullCalled { - t.Fatal("should've pulled") - } - if driver.PullImage != config.Image { - t.Fatalf("bad: %#v", driver.PullImage) - } -} - -func TestStepPull_error(t *testing.T) { - state := testState(t) - step := new(StepPull) - defer step.Cleanup(state) - - driver := state.Get("driver").(*MockDriver) - driver.PullError = errors.New("foo") - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - - // verify we have an error - if _, ok := state.GetOk("error"); !ok { - t.Fatal("should have error") - } -} - -func TestStepPull_login(t *testing.T) { - state := testState(t) - step := new(StepPull) - defer step.Cleanup(state) - - config := state.Get("config").(*Config) - driver := state.Get("driver").(*MockDriver) - - config.Login = true - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we pulled - if !driver.PullCalled { - t.Fatal("should've pulled") - } - - // verify we logged in - if !driver.LoginCalled { - t.Fatal("should've logged in") - } - if !driver.LogoutCalled { - t.Fatal("should've logged out") - } -} - -func TestStepPull_noPull(t *testing.T) { - state := testState(t) - step := new(StepPull) - defer step.Cleanup(state) - - config := state.Get("config").(*Config) - config.Pull = false - - driver := state.Get("driver").(*MockDriver) - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we did the right thing - if driver.PullCalled { - t.Fatal("shouldn't have pulled") - } -} diff --git a/builder/docker/step_run_test.go b/builder/docker/step_run_test.go deleted file mode 100644 index f1d5a065f..000000000 --- a/builder/docker/step_run_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package docker - -import ( - "context" - "errors" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func testStepRunState(t *testing.T) multistep.StateBag { - state := testState(t) - state.Put("temp_dir", "/foo") - return state -} - -func TestStepRun_impl(t *testing.T) { - var _ multistep.Step = new(StepRun) -} - -func TestStepRun(t *testing.T) { - state := testStepRunState(t) - step := new(StepRun) - defer step.Cleanup(state) - - config := state.Get("config").(*Config) - driver := state.Get("driver").(*MockDriver) - driver.StartID = "foo" - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // verify we did the right thing - if !driver.StartCalled { - t.Fatal("should've called") - } - if driver.StartConfig.Image != config.Image { - t.Fatalf("bad: %#v", driver.StartConfig.Image) - } - - // verify the ID is saved - idRaw, ok := state.GetOk("container_id") - if !ok { - t.Fatal("should've saved ID") - } - - id := idRaw.(string) - if id != "foo" { - t.Fatalf("bad: %#v", id) - } - - // Verify we haven't called stop yet - if driver.KillCalled { - t.Fatal("should not have stopped") - } - - // Cleanup - step.Cleanup(state) - if !driver.KillCalled { - t.Fatal("should've stopped") - } - if driver.KillID != id { - t.Fatalf("bad: %#v", driver.StopID) - } -} - -func TestStepRun_error(t *testing.T) { - state := testStepRunState(t) - step := new(StepRun) - defer step.Cleanup(state) - - driver := state.Get("driver").(*MockDriver) - driver.StartError = errors.New("foo") - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionHalt { - t.Fatalf("bad action: %#v", action) - } - - // verify the ID is not saved - if _, ok := state.GetOk("container_id"); ok { - t.Fatal("shouldn't save container ID") - } - - // Verify we haven't called stop yet - if driver.KillCalled { - t.Fatal("should not have stopped") - } - - // Cleanup - step.Cleanup(state) - if driver.KillCalled { - t.Fatal("should not have stopped") - } -} diff --git a/builder/docker/step_set_generated_data_test.go b/builder/docker/step_set_generated_data_test.go deleted file mode 100644 index dc3eec02f..000000000 --- a/builder/docker/step_set_generated_data_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package docker - -import ( - "context" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - "github.com/hashicorp/packer-plugin-sdk/packerbuilderdata" -) - -func TestStepSetGeneratedData_Run(t *testing.T) { - state := testState(t) - step := new(StepSetGeneratedData) - step.GeneratedData = &packerbuilderdata.GeneratedData{State: state} - driver := state.Get("driver").(*MockDriver) - driver.Sha256Result = "80B3BB1B1696E73A9B19DEEF92F664F8979F948DF348088B61F9A3477655AF64" - state.Put("image_id", "12345") - - if action := step.Run(context.TODO(), state); action != multistep.ActionContinue { - t.Fatalf("Should not halt") - } - if !driver.Sha256Called { - t.Fatalf("driver.SHA256 should be called") - } - if driver.Sha256Id != "12345" { - t.Fatalf("driver.SHA256 got wrong image it: %s", driver.Sha256Id) - } - genData := state.Get("generated_data").(map[string]interface{}) - imgSha256 := genData["ImageSha256"].(string) - if imgSha256 != driver.Sha256Result { - t.Fatalf("Expected ImageSha256 to be %s but was %s", driver.Sha256Result, imgSha256) - } - - // Image ID not implement - state = testState(t) - step.GeneratedData = &packerbuilderdata.GeneratedData{State: state} - driver = state.Get("driver").(*MockDriver) - notImplementedMsg := "ERR_IMAGE_SHA256_NOT_FOUND" - - if action := step.Run(context.TODO(), state); action != multistep.ActionContinue { - t.Fatalf("Should not halt") - } - if driver.Sha256Called { - t.Fatalf("driver.SHA256 should not be called") - } - genData = state.Get("generated_data").(map[string]interface{}) - imgSha256 = genData["ImageSha256"].(string) - if imgSha256 != notImplementedMsg { - t.Fatalf("Expected ImageSha256 to be %s but was %s", notImplementedMsg, imgSha256) - } -} diff --git a/builder/docker/step_temp_dir_test.go b/builder/docker/step_temp_dir_test.go deleted file mode 100644 index b6f8afe3c..000000000 --- a/builder/docker/step_temp_dir_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package docker - -import ( - "context" - "os" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" -) - -func TestStepTempDir_impl(t *testing.T) { - var _ multistep.Step = new(StepTempDir) -} - -func testStepTempDir_impl(t *testing.T) string { - state := testState(t) - step := new(StepTempDir) - defer step.Cleanup(state) - - // sanity test - if _, ok := state.GetOk("temp_dir"); ok { - t.Fatalf("temp_dir should not be in state yet") - } - - // run the step - if action := step.Run(context.Background(), state); action != multistep.ActionContinue { - t.Fatalf("bad action: %#v", action) - } - - // Verify that we got the temp dir - dirRaw, ok := state.GetOk("temp_dir") - if !ok { - t.Fatalf("should've made temp_dir") - } - dir := dirRaw.(string) - - if _, err := os.Stat(dir); err != nil { - t.Fatalf("Stat for %s failed: err: %s", err, dir) - } - - // Cleanup - step.Cleanup(state) - if _, err := os.Stat(dir); err == nil { - t.Fatalf("dir should be gone") - } - - return dir -} - -func TestStepTempDir(t *testing.T) { - testStepTempDir_impl(t) -} diff --git a/builder/docker/step_test.go b/builder/docker/step_test.go deleted file mode 100644 index e12b7a6ab..000000000 --- a/builder/docker/step_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package docker - -import ( - "bytes" - "testing" - - "github.com/hashicorp/packer-plugin-sdk/multistep" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func testState(t *testing.T) multistep.StateBag { - state := new(multistep.BasicStateBag) - state.Put("config", testConfigStruct(t)) - state.Put("driver", &MockDriver{}) - state.Put("hook", &packersdk.MockHook{}) - state.Put("ui", &packersdk.BasicUi{ - Reader: new(bytes.Buffer), - Writer: new(bytes.Buffer), - }) - return state -} diff --git a/builder/docker/test-fixtures/manycakes/chocolate b/builder/docker/test-fixtures/manycakes/chocolate deleted file mode 100644 index a2286c928..000000000 --- a/builder/docker/test-fixtures/manycakes/chocolate +++ /dev/null @@ -1 +0,0 @@ -chocolate! diff --git a/builder/docker/test-fixtures/manycakes/vanilla b/builder/docker/test-fixtures/manycakes/vanilla deleted file mode 100644 index 000a45578..000000000 --- a/builder/docker/test-fixtures/manycakes/vanilla +++ /dev/null @@ -1 +0,0 @@ -vanilla! diff --git a/builder/docker/test-fixtures/onecakes/strawberry b/builder/docker/test-fixtures/onecakes/strawberry deleted file mode 100644 index b663de3a9..000000000 --- a/builder/docker/test-fixtures/onecakes/strawberry +++ /dev/null @@ -1 +0,0 @@ -strawberry! diff --git a/builder/docker/version/version.go b/builder/docker/version/version.go deleted file mode 100644 index f71ac2cac..000000000 --- a/builder/docker/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var DigitalOceanPluginVersion *version.PluginVersion - -func init() { - DigitalOceanPluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/command/plugin.go b/command/plugin.go index b5be6a4fa..2e039ed6c 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -24,7 +24,6 @@ import ( azuredtlbuilder "github.com/hashicorp/packer/builder/azure/dtl" cloudstackbuilder "github.com/hashicorp/packer/builder/cloudstack" digitaloceanbuilder "github.com/hashicorp/packer/builder/digitalocean" - dockerbuilder "github.com/hashicorp/packer/builder/docker" filebuilder "github.com/hashicorp/packer/builder/file" googlecomputebuilder "github.com/hashicorp/packer/builder/googlecompute" hcloudbuilder "github.com/hashicorp/packer/builder/hcloud" @@ -73,10 +72,6 @@ import ( checksumpostprocessor "github.com/hashicorp/packer/post-processor/checksum" compresspostprocessor "github.com/hashicorp/packer/post-processor/compress" digitaloceanimportpostprocessor "github.com/hashicorp/packer/post-processor/digitalocean-import" - dockerimportpostprocessor "github.com/hashicorp/packer/post-processor/docker-import" - dockerpushpostprocessor "github.com/hashicorp/packer/post-processor/docker-push" - dockersavepostprocessor "github.com/hashicorp/packer/post-processor/docker-save" - dockertagpostprocessor "github.com/hashicorp/packer/post-processor/docker-tag" exoscaleimportpostprocessor "github.com/hashicorp/packer/post-processor/exoscale-import" googlecomputeexportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-export" googlecomputeimportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-import" @@ -125,7 +120,6 @@ var Builders = map[string]packersdk.Builder{ "azure-dtl": new(azuredtlbuilder.Builder), "cloudstack": new(cloudstackbuilder.Builder), "digitalocean": new(digitaloceanbuilder.Builder), - "docker": new(dockerbuilder.Builder), "file": new(filebuilder.Builder), "googlecompute": new(googlecomputebuilder.Builder), "hcloud": new(hcloudbuilder.Builder), @@ -196,10 +190,6 @@ var PostProcessors = map[string]packersdk.PostProcessor{ "checksum": new(checksumpostprocessor.PostProcessor), "compress": new(compresspostprocessor.PostProcessor), "digitalocean-import": new(digitaloceanimportpostprocessor.PostProcessor), - "docker-import": new(dockerimportpostprocessor.PostProcessor), - "docker-push": new(dockerpushpostprocessor.PostProcessor), - "docker-save": new(dockersavepostprocessor.PostProcessor), - "docker-tag": new(dockertagpostprocessor.PostProcessor), "exoscale-import": new(exoscaleimportpostprocessor.PostProcessor), "googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor), "googlecompute-import": new(googlecomputeimportpostprocessor.PostProcessor), diff --git a/go.mod b/go.mod index 000b31cfa..17e938235 100644 --- a/go.mod +++ b/go.mod @@ -50,6 +50,7 @@ require ( github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/hcl/v2 v2.8.0 + github.com/hashicorp/packer-plugin-docker v0.0.2 github.com/hashicorp/packer-plugin-sdk v0.0.14 github.com/hashicorp/vault/api v1.0.4 github.com/hetznercloud/hcloud-go v1.15.1 diff --git a/go.sum b/go.sum index 070e3f889..fecf30140 100644 --- a/go.sum +++ b/go.sum @@ -62,7 +62,6 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtO github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= github.com/Azure/go-autorest/autorest/to v0.3.0 h1:zebkZaadz7+wIQYgC7GXaz3Wb28yKYfVkkBKwc38VF8= github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= -github.com/Azure/go-autorest/autorest/validation v0.2.0 h1:15vMO4y76dehZSq7pAaOLQxC6dZYsSrj2GQpflyM/L4= github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= @@ -70,7 +69,6 @@ github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1Gn github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4 h1:pSm8mp0T2OH2CPmPDPtwHPr3VAQaOwVF/JbllOPP4xA= github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/Azure/go-ntlmssp v0.0.0-20191115201650-bad6df29494a h1:3FwiePtHk5YJrooV799oo5jIfsgRdES25VdngJM03dU= github.com/Azure/go-ntlmssp v0.0.0-20191115201650-bad6df29494a/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= @@ -93,11 +91,9 @@ github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e h1:/8w github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f h1:jI4DIE5Vf4oRaHfthB0oRhU+yuYuoOTurDzwAlskP00= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= -github.com/antchfx/xpath v0.0.0-20170728053731-b5c552e1acbd h1:S3Fr6QnkpW9VRjiEY4psQHhhbbahASuNVj52YIce7lI= github.com/antchfx/xpath v0.0.0-20170728053731-b5c552e1acbd/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= github.com/antchfx/xpath v1.1.11 h1:WOFtK8TVAjLm3lbgqeP0arlHpvCEeTANeWZ/csPpJkQ= github.com/antchfx/xpath v1.1.11/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= -github.com/antchfx/xquery v0.0.0-20170730121040-eb8c3c172607 h1:BFFG6KP8ASFBg2ptWsJn8p8RDufBjBDKIxLU7BTYGOM= github.com/antchfx/xquery v0.0.0-20170730121040-eb8c3c172607/go.mod h1:LzD22aAzDP8/dyiCKFp31He4m2GPjl0AFyzDtZzUu9M= github.com/antchfx/xquery v0.0.0-20180515051857-ad5b8c7a47b0 h1:JaCC8jz0zdMLk2m+qCCVLLLM/PL93p84w4pK3aJWj60= github.com/antchfx/xquery v0.0.0-20180515051857-ad5b8c7a47b0/go.mod h1:LzD22aAzDP8/dyiCKFp31He4m2GPjl0AFyzDtZzUu9M= @@ -114,11 +110,9 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE github.com/approvals/go-approval-tests v0.0.0-20160714161514-ad96e53bea43 h1:ePCAQPf5tUc5IMcUvu6euhSGna7jzs7eiXtJXHig6Zc= github.com/approvals/go-approval-tests v0.0.0-20160714161514-ad96e53bea43/go.mod h1:S6puKjZ9ZeqUPBv2hEBnMZGcM2J6mOsDRQcmxkMAND0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -127,7 +121,6 @@ github.com/aws/aws-sdk-go v1.26.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.30.8/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.36.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.36.5 h1:SouM2ar1A8f+3DYWW622sDdqkkZAO3ha4j8GQjiPLFg= github.com/aws/aws-sdk-go v1.36.5/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.37.15 h1:W7l7gLLMcYRlg6a+uvf3Zz4jYwdqYzhe5ymqwWoOhp4= github.com/aws/aws-sdk-go v1.37.15/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= @@ -161,15 +154,11 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/digitalocean/go-libvirt v0.0.0-20190626172931-4d226dd6c437 h1:phR13shVFOIpa1pnLBmewI9p16NEladLPvVylLPeexo= github.com/digitalocean/go-libvirt v0.0.0-20190626172931-4d226dd6c437/go.mod h1:PRcPVAAma6zcLpFd4GZrjR/MRpood3TamjKI2m/z/Uw= -github.com/digitalocean/go-libvirt v0.0.0-20201209184759-e2a69bcd5bd1 h1:j6vGflaQ2T7yOWqVgPdiRF73j/U2Zmpbbzab8nyDCRQ= github.com/digitalocean/go-libvirt v0.0.0-20201209184759-e2a69bcd5bd1/go.mod h1:QS1XzqZLcDniNYrN7EZefq3wIyb/M2WmJbql4ZKoc1Q= -github.com/digitalocean/go-libvirt v0.0.0-20210108193637-3a8ae49ba8cd h1:+96Lbk3f8glkOcsRdy3Nubga8pE40kor2OgxDzVGNZM= github.com/digitalocean/go-libvirt v0.0.0-20210108193637-3a8ae49ba8cd/go.mod h1:gtar3MgGsIO64GgphCHw1cbyxSI6qEuTIm9+izMmlfk= github.com/digitalocean/go-libvirt v0.0.0-20210112203132-25518eb2c840 h1:F3RVNV8SLLNhkNFcbDTgD3wAPMcrMJW6xjjI0JXy9z8= github.com/digitalocean/go-libvirt v0.0.0-20210112203132-25518eb2c840/go.mod h1:gtar3MgGsIO64GgphCHw1cbyxSI6qEuTIm9+izMmlfk= -github.com/digitalocean/go-qemu v0.0.0-20181112162955-dd7bb9c771b8 h1:N7nH2py78LcMqYY3rZjjrsX6N7uCN7sjvaosgpXN9Ow= github.com/digitalocean/go-qemu v0.0.0-20181112162955-dd7bb9c771b8/go.mod h1:/YnlngP1PARC0SKAZx6kaAEMOp8bNTQGqS+Ka3MctNI= github.com/digitalocean/go-qemu v0.0.0-20201211181942-d361e7b4965f h1:BYkBJhHxUJJn27mhqfqWycWaEOWv9JQqLgQ2pOFJMqE= github.com/digitalocean/go-qemu v0.0.0-20201211181942-d361e7b4965f/go.mod h1:y4Eq3ZfZQFWQwVyW0qvgo5seXUIq2C7BlHsdE+xtXL4= @@ -191,7 +180,6 @@ github.com/exoscale/egoscale v0.18.1 h1:1FNZVk8jHUx0AvWhOZxLEDNlacTU0chMXUUNkm9E github.com/exoscale/egoscale v0.18.1/go.mod h1:Z7OOdzzTOz1Q1PjQXumlz9Wn/CddH0zSYdCF3rnBKXE= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= @@ -206,7 +194,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-ini/ini v1.25.4 h1:Mujh4R/dH6YL8bxuISne3xX2+qcQ9p0IxKAP6ExWoUo= github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -300,7 +287,6 @@ github.com/gophercloud/gophercloud v0.12.0 h1:mZrie07npp6ODiwHZolTicr5jV8Ogn43Av github.com/gophercloud/gophercloud v0.12.0/go.mod h1:gmC5oQqMDOMO1t1gq5DquX/yAU808e/4mzjjDA76+Ss= github.com/gophercloud/utils v0.0.0-20200508015959-b0167b94122c h1:iawx2ojEQA7c+GmkaVO5sN+k8YONibXyDO8RlsC+1bs= github.com/gophercloud/utils v0.0.0-20200508015959-b0167b94122c/go.mod h1:ehWUbLQJPqS0Ep+CxeD559hsm9pthPXadJNKwZkp43w= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -336,11 +322,9 @@ github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9 github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.1.0 h1:vN9wG1D6KG6YHRTWr8512cxGOVgTMEfgEdSj/hr8MPc= github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= @@ -353,7 +337,6 @@ github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.5.4 h1:1BZvpawXoJCWX6pNtow9+rpEj+3itIlutiqnntI6jOE= github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.1 h1:DMo4fmknnz0E0evoNYnV48RjWndOsmd6OW+09R3cEP8= github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= @@ -373,7 +356,6 @@ github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+d github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= @@ -385,7 +367,6 @@ github.com/hashicorp/hcl/v2 v2.8.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yI github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/memberlist v0.1.3 h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.2.2 h1:5+RffWKwqJ71YPu9mWsF7ZOscZmwfasdA8kbdC7AO2g= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= @@ -397,23 +378,18 @@ github.com/hashicorp/packer v1.6.7-0.20210125170305-539638b0f951/go.mod h1:Z3eun github.com/hashicorp/packer v1.6.7-0.20210126105722-aef4ced967ec/go.mod h1:2+Vo/c/fA+TD9yFc/h9jQMFm4yG+IymQIr0OdJJOPiE= github.com/hashicorp/packer v1.6.7-0.20210208125835-f616955ebcb6/go.mod h1:7f5ZpTTRG53rQ58BcTADuTnpiBcB3wapuxl4sF2sGMM= github.com/hashicorp/packer v1.6.7-0.20210217093213-201869d627bf/go.mod h1:+EWPPcqee4h8S/y913Dnta1eJkgiqsGXBQgB75A2qV0= -github.com/hashicorp/packer-plugin-sdk v0.0.6 h1:BN2G4APXSMvDURFdnk+6DspwsU83pZeMsbEur7NmGsA= +github.com/hashicorp/packer-plugin-docker v0.0.2 h1:j/hQTogaN2pZfZohlZTRu5YvNZg2/qtYYHkxPBxv2Oo= +github.com/hashicorp/packer-plugin-docker v0.0.2/go.mod h1:A2p9qztS4n88KsNF+qBM7BWw2HndW636GpFIjNSvbKM= github.com/hashicorp/packer-plugin-sdk v0.0.6/go.mod h1:Nvh28f+Jmpp2rcaN79bULTouNkGNDRfHckhHKTAXtyU= github.com/hashicorp/packer-plugin-sdk v0.0.6/go.mod h1:Nvh28f+Jmpp2rcaN79bULTouNkGNDRfHckhHKTAXtyU= github.com/hashicorp/packer-plugin-sdk v0.0.7-0.20210111224258-fd30ebb797f0/go.mod h1:YdWTt5w6cYfaQG7IOi5iorL+3SXnz8hI0gJCi8Db/LI= -github.com/hashicorp/packer-plugin-sdk v0.0.7-0.20210120105339-f6fd68d2570a h1:QbS+UBmK9DZuEDPodi1pCiS66dLYI3rmUX/cowNopsk= github.com/hashicorp/packer-plugin-sdk v0.0.7-0.20210120105339-f6fd68d2570a/go.mod h1:exN0C+Pe+3zu18l4nxueNjX5cfmslxUX/m/xk4IVmZQ= -github.com/hashicorp/packer-plugin-sdk v0.0.7-0.20210122130548-45a6ca0a9365 h1:u7DeYY9ukhSZpLE11qCFU8pxnO+YM2/85wwVXHJZdRE= github.com/hashicorp/packer-plugin-sdk v0.0.7-0.20210122130548-45a6ca0a9365/go.mod h1:K7VsU0lfJBDyiUrSNnS/j+zMxSRwwH9WC9QvHv32KsU= -github.com/hashicorp/packer-plugin-sdk v0.0.10-0.20210126105622-8e1648006d93 h1:3wFACjFiBkF5sZrai0zvcWv2fHIgLa4g6ZXxbqngBhs= github.com/hashicorp/packer-plugin-sdk v0.0.10-0.20210126105622-8e1648006d93/go.mod h1:AtWQLNfpn7cgH2SmZ1PTedwqNOhiPvzcuKfH5sDvIQ0= -github.com/hashicorp/packer-plugin-sdk v0.0.11 h1:nUurEGaJtpVDyg94bKC2xOXWf1TqQ+++GovFUnP5REI= github.com/hashicorp/packer-plugin-sdk v0.0.11/go.mod h1:GNb0WNs7zibb8vzUZce1As64z2AW0FEMwhe2J7/NW5I= -github.com/hashicorp/packer-plugin-sdk v0.0.12 h1:eagxsrborfhc0E8zvDVCiRE9pQkjBw/6jm23jp0D8RU= github.com/hashicorp/packer-plugin-sdk v0.0.12/go.mod h1:hs82OYeufirGG6KRENMpjBWomnIlte99X6wXAPThJ5I= github.com/hashicorp/packer-plugin-sdk v0.0.14 h1:42WOZLmIbAYYC1WXxtlrQZN+fFdysVvTmj3jtoI6gOU= github.com/hashicorp/packer-plugin-sdk v0.0.14/go.mod h1:tNb3XzJPnjMl3QuUdKmF47B5ImerdTakalHzUAvW0aw= -github.com/hashicorp/serf v0.8.2 h1:YZ7UKsJv+hKjqGVUUbtE3HNj79Eln2oQ75tniF6iPt0= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.2 h1:yJoyfZXo4Pk2p/M/viW+YLibBFiIbKoP79gu7kDAFP0= github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= @@ -442,28 +418,22 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62 h1:JHCT6xuyPUrbbgAPE/3dqlvUKzRHMNuTBKKUb6OeR/k= github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v0.0.0-20160131094358-f86d2e6d8a77 h1:rJnR80lkojFgjdg/oQPhbZoY8t8uM51XMz8DrJrjabk= github.com/klauspost/compress v0.0.0-20160131094358-f86d2e6d8a77/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.6 h1:EgWPCW6O3n1D5n99Zq3xXBt9uCwRGvpwGOusOLNBRSQ= github.com/klauspost/compress v1.11.6/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7 h1:0hzRabrMN4tSTvMfnL3SCv1ZGeAP23ynzodBgaHeMeg= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/cpuid v0.0.0-20160106104451-349c67577817 h1:/7pPahIC+GoCm/euDCi2Pm29bAj9tc6TcK4Zcc8D3WI= github.com/klauspost/cpuid v0.0.0-20160106104451-349c67577817/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/crc32 v0.0.0-20160114101742-999f3125931f h1:UD9YLTi2aBhdOOThzatodQ/pGd9nd5255swS+UzHZj4= github.com/klauspost/crc32 v0.0.0-20160114101742-999f3125931f/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/crc32 v1.2.0 h1:0VuyqOCruD33/lJ/ojXNvzVyl8Zr5zdTmj9l9qLZ86I= github.com/klauspost/crc32 v1.2.0/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= @@ -471,11 +441,9 @@ github.com/klauspost/pgzip v0.0.0-20151221113845-47f36e165cec h1:PYqF3Tiz2W2Ag0e github.com/klauspost/pgzip v0.0.0-20151221113845-47f36e165cec/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.0.0-20131111012553-2788f0dbd169 h1:YUrU1/jxRqnt0PSrKj1Uj/wEjk/fjnE80QFfi2Zlj7Q= github.com/kr/fs v0.0.0-20131111012553-2788f0dbd169/go.mod h1:glhvuHOU9Hy7/8PwwdtnarXqLagOX0b/TbZx2zLMqEg= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -486,20 +454,16 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3v github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/linode/linodego v0.14.0 h1:0APKMjiVGyry2TTUVDiok72H6cWpFNMMrFWBFn14aFU= github.com/linode/linodego v0.14.0/go.mod h1:2ce3S00NrDqJfp4i55ZuSlT0U3cKNELNYACWBPI8Tnw= -github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9 h1:SmVbOZFWAlyQshuMfOkiAx1f5oUTsOGG5IXplAEYeeM= github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg= github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc= github.com/masterzen/winrm v0.0.0-20200615185753-c42b5136ff88/go.mod h1:a2HXwefeat3evJHxFXSayvRHpYEPJYtErl4uIzfaUqY= github.com/masterzen/winrm v0.0.0-20201030141608-56ca5c5f2380 h1:uKhPH5dYpx3Z8ZAnaTGfGZUiHOWa5p5mdG8wZlh+tLo= github.com/masterzen/winrm v0.0.0-20201030141608-56ca5c5f2380/go.mod h1:a2HXwefeat3evJHxFXSayvRHpYEPJYtErl4uIzfaUqY= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -507,14 +471,12 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-tty v0.0.0-20191112051231-74040eebce08 h1:8YAWbq7rJqfbc6IaAvA2eCQuOQvf6Bs4vHKcOyWw//E= github.com/mattn/go-tty v0.0.0-20191112051231-74040eebce08/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26 h1:gPxPSwALAeHJSjarOs00QjVdV9QoBvc1D2ujQUr5BzU= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= @@ -528,7 +490,6 @@ github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk 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 v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.3 h1:gqwbsGvc0jbhAPW/26WfEoSiPANAVlR49AAVdvaTjI4= github.com/mitchellh/go-testing-interface v1.0.3/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -538,7 +499,6 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= @@ -553,11 +513,9 @@ github.com/mitchellh/prefixedio v0.0.0-20151214002211-6e6954073784 h1:+DAetXqxv/ github.com/mitchellh/prefixedio v0.0.0-20151214002211-6e6954073784/go.mod h1:kB1naBgV9ORnkiTVeyJOI1DavaJkG4oNIq0Af6ZVKUo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -567,7 +525,6 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/olekukonko/tablewriter v0.0.0-20180105111133-96aac992fc8b h1:LGItPaClbzopugAomw5VFKnG3h1dUr9QW5KOU+m8gu0= github.com/olekukonko/tablewriter v0.0.0-20180105111133-96aac992fc8b/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/oracle/oci-go-sdk v18.0.0+incompatible h1:FLV4KixsVfF3rwyVTMI6Ryp/Q+OSb9sR5TawbfjFLN4= github.com/oracle/oci-go-sdk v18.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/oracle/oci-go-sdk v24.3.0+incompatible h1:x4mcfb4agelf1O4/1/auGlZ1lr97jXRSSN5MxTgG/zU= github.com/oracle/oci-go-sdk v24.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= @@ -624,14 +581,12 @@ github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w= github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -648,7 +603,6 @@ github.com/ucloud/ucloud-sdk-go v0.16.3 h1:DCh4A5vSxFr3EvtvJL+g0Ehy4hSlEkMpQmEvx github.com/ucloud/ucloud-sdk-go v0.16.3/go.mod h1:dyLmFHmUfgb4RZKYQP9IArlvQ2pxzFthfhwxRzOEPIw= github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6 h1:FAWNiqocJ04wC4Znj7Ax4PGWstZijayO6ifuHHvb+vI= github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6/go.mod h1:R5FMQxkQ+QK/9Vz+jfnJP4rZIktYrRcWmuAnbOSkROI= -github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1 h1:U6ufy3mLDgg9RYupntOvAF7xCmNNquyKaYaaVHo1Nnk= github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= github.com/ugorji/go v1.2.4 h1:cTciPbZ/VSOzCLKclmssnfQ/jyoVyOcJ3aoJyUV1Urc= github.com/ugorji/go v1.2.4/go.mod h1:EuaSCk8iZMdIspsu6HXH7X2UGKw1ezO4wCfGszGmmo4= @@ -972,7 +926,6 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200831141814-d751682dd103/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200914193844-75d14daec038 h1:SnvTpXhVDJGFxzZiHbMUZTh3VjU2Vx2feJ7Zfl5+OIY= google.golang.org/genproto v0.0.0-20200914193844-75d14daec038/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200918140846-d0d605568037 h1:ujwz1DPMeHwCvo36rK5shXhAzc4GMRecrqQFaMZJBKQ= google.golang.org/genproto v0.0.0-20200918140846-d0d605568037/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1012,7 +965,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/cheggaaa/pb.v1 v1.0.27 h1:kJdccidYzt3CaHD1crCFTS1hxyhSi059NhOFUf03YFo= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1024,7 +976,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/post-processor/docker-import/post-processor_test.go b/post-processor/docker-import/post-processor_test.go deleted file mode 100644 index d83b9e3a4..000000000 --- a/post-processor/docker-import/post-processor_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package dockerimport - -import ( - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packersdk.PostProcessor = new(PostProcessor) -} diff --git a/post-processor/docker-import/version/version.go b/post-processor/docker-import/version/version.go deleted file mode 100644 index cd350064b..000000000 --- a/post-processor/docker-import/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var DockerImportPluginVersion *version.PluginVersion - -func init() { - DockerImportPluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/post-processor/docker-push/post-processor_test.go b/post-processor/docker-push/post-processor_test.go deleted file mode 100644 index 5f85c3d41..000000000 --- a/post-processor/docker-push/post-processor_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package dockerpush - -import ( - "bytes" - "context" - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer/builder/docker" - dockerimport "github.com/hashicorp/packer/post-processor/docker-import" -) - -func testUi() *packersdk.BasicUi { - return &packersdk.BasicUi{ - Reader: new(bytes.Buffer), - Writer: new(bytes.Buffer), - } -} - -func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packersdk.PostProcessor = new(PostProcessor) -} - -func TestPostProcessor_PostProcess(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - artifact := &packersdk.MockArtifact{ - BuilderIdValue: dockerimport.BuilderId, - IdValue: "foo/bar", - } - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if forceOverride { - t.Fatal("Should default to keep, but not override user wishes") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if !driver.PushCalled { - t.Fatal("should call push") - } - if driver.PushName != "foo/bar" { - t.Fatal("bad name") - } - if result.Id() != "foo/bar" { - t.Fatal("bad image id") - } -} - -func TestPostProcessor_PostProcess_portInName(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - artifact := &packersdk.MockArtifact{ - BuilderIdValue: dockerimport.BuilderId, - IdValue: "localhost:5000/foo/bar", - } - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if forceOverride { - t.Fatal("Should default to keep, but not override user wishes") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if !driver.PushCalled { - t.Fatal("should call push") - } - if driver.PushName != "localhost:5000/foo/bar" { - t.Fatal("bad name") - } - if result.Id() != "localhost:5000/foo/bar" { - t.Fatal("bad image id") - } -} - -func TestPostProcessor_PostProcess_tags(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - artifact := &packersdk.MockArtifact{ - BuilderIdValue: dockerimport.BuilderId, - IdValue: "hashicorp/ubuntu:precise", - } - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if forceOverride { - t.Fatal("Should default to keep, but not override user wishes") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if !driver.PushCalled { - t.Fatal("should call push") - } - if driver.PushName != "hashicorp/ubuntu:precise" { - t.Fatalf("bad name: %s", driver.PushName) - } - if result.Id() != "hashicorp/ubuntu:precise" { - t.Fatal("bad image id") - } -} diff --git a/post-processor/docker-push/version/version.go b/post-processor/docker-push/version/version.go deleted file mode 100644 index 4771f65cc..000000000 --- a/post-processor/docker-push/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var DockerPushPluginVersion *version.PluginVersion - -func init() { - DockerPushPluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/post-processor/docker-save/post-processor_test.go b/post-processor/docker-save/post-processor_test.go deleted file mode 100644 index 7a7ffbe90..000000000 --- a/post-processor/docker-save/post-processor_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package dockersave - -import ( - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" -) - -func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packersdk.PostProcessor = new(PostProcessor) -} diff --git a/post-processor/docker-save/version/version.go b/post-processor/docker-save/version/version.go deleted file mode 100644 index b561d49ee..000000000 --- a/post-processor/docker-save/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var DockerSavePluginVersion *version.PluginVersion - -func init() { - DockerSavePluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/post-processor/docker-tag/post-processor_test.go b/post-processor/docker-tag/post-processor_test.go deleted file mode 100644 index f9fe4aa74..000000000 --- a/post-processor/docker-tag/post-processor_test.go +++ /dev/null @@ -1,196 +0,0 @@ -package dockertag - -import ( - "bytes" - "context" - "testing" - - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer/builder/docker" - dockerimport "github.com/hashicorp/packer/post-processor/docker-import" - "github.com/stretchr/testify/assert" -) - -func testConfig() map[string]interface{} { - return map[string]interface{}{ - "repository": "foo", - "tag": "bar,buzz", - } -} - -func testPP(t *testing.T) *PostProcessor { - var p PostProcessor - if err := p.Configure(testConfig()); err != nil { - t.Fatalf("err: %s", err) - } - - return &p -} - -func testUi() *packersdk.BasicUi { - return &packersdk.BasicUi{ - Reader: new(bytes.Buffer), - Writer: new(bytes.Buffer), - } -} - -func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { - var _ packersdk.PostProcessor = new(PostProcessor) -} - -func TestPostProcessor_PostProcess(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - if err := p.Configure(testConfig()); err != nil { - t.Fatalf("err: %s", err) - } - - artifact := &packersdk.MockArtifact{ - BuilderIdValue: dockerimport.BuilderId, - IdValue: "1234567890abcdef", - } - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if !forceOverride { - t.Fatal("Should force keep no matter what user sets.") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if driver.TagImageCalled != 2 { - t.Fatal("should call TagImage") - } - if driver.TagImageImageId != "1234567890abcdef" { - t.Fatal("bad image id") - } - - if driver.TagImageRepo[0] != "foo:bar" { - t.Fatal("bad repo") - } - - if driver.TagImageRepo[1] != "foo:buzz" { - t.Fatal("bad repo") - } - - if driver.TagImageForce { - t.Fatal("bad force. force=false in default") - } -} - -func TestPostProcessor_PostProcess_Force(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - c := testConfig() - c["force"] = true - if err := p.Configure(c); err != nil { - t.Fatalf("err: %s", err) - } - - artifact := &packersdk.MockArtifact{ - BuilderIdValue: dockerimport.BuilderId, - IdValue: "1234567890abcdef", - } - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if !forceOverride { - t.Fatal("Should force keep no matter what user sets.") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if driver.TagImageCalled != 2 { - t.Fatal("should call TagImage") - } - if driver.TagImageImageId != "1234567890abcdef" { - t.Fatal("bad image id") - } - if driver.TagImageRepo[0] != "foo:bar" { - t.Fatal("bad repo") - } - if driver.TagImageRepo[1] != "foo:buzz" { - t.Fatal("bad repo") - } - if !driver.TagImageForce { - t.Fatal("bad force") - } -} - -func TestPostProcessor_PostProcess_NoTag(t *testing.T) { - driver := &docker.MockDriver{} - p := &PostProcessor{Driver: driver} - c := testConfig() - delete(c, "tag") - if err := p.Configure(c); err != nil { - t.Fatalf("err %s", err) - } - - artifact := &packersdk.MockArtifact{BuilderIdValue: dockerimport.BuilderId, IdValue: "1234567890abcdef"} - - result, keep, forceOverride, err := p.PostProcess(context.Background(), testUi(), artifact) - if _, ok := result.(packersdk.Artifact); !ok { - t.Fatal("should be instance of Artifact") - } - if !keep { - t.Fatal("should keep") - } - if !forceOverride { - t.Fatal("Should force keep no matter what user sets.") - } - if err != nil { - t.Fatalf("err: %s", err) - } - - if driver.TagImageCalled != 1 { - t.Fatal("should call TagImage") - } - if driver.TagImageImageId != "1234567890abcdef" { - t.Fatal("bad image id") - } - if driver.TagImageRepo[0] != "foo" { - t.Fatal("bad repo") - } - if driver.TagImageForce { - t.Fatal("bad force") - } -} - -func TestPostProcessor_PostProcess_Tag_vs_Tags(t *testing.T) { - testCases := []map[string]interface{}{ - { - "tag": "bar,buzz", - "tags": []string{"bang"}, - }, - { - "tag": []string{"bar", "buzz"}, - "tags": []string{"bang"}, - }, - { - "tag": []string{"bar"}, - "tags": []string{"buzz", "bang"}, - }, - } - - for _, tc := range testCases { - var p PostProcessor - if err := p.Configure(tc); err != nil { - t.Fatalf("err: %s", err) - } - assert.ElementsMatchf(t, p.config.Tags, []string{"bar", "buzz", "bang"}, - "tag and tags fields should be combined into tags fields. Recieved: %#v", - p.config.Tags) - } -} diff --git a/post-processor/docker-tag/version/version.go b/post-processor/docker-tag/version/version.go deleted file mode 100644 index c7506f136..000000000 --- a/post-processor/docker-tag/version/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package version - -import ( - "github.com/hashicorp/packer-plugin-sdk/version" - packerVersion "github.com/hashicorp/packer/version" -) - -var DockerTagPluginVersion *version.PluginVersion - -func init() { - DockerTagPluginVersion = version.InitializePluginVersion( - packerVersion.Version, packerVersion.VersionPrerelease) -} diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 0fdf81bfa..1dde309d2 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -11,9 +11,9 @@ import ( "fmt" "os/exec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" builderT "github.com/hashicorp/packer-plugin-sdk/acctest" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/provisioner/file" ) diff --git a/builder/docker/artifact_export.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/artifact_export.go similarity index 100% rename from builder/docker/artifact_export.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/artifact_export.go diff --git a/builder/docker/artifact_import.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/artifact_import.go similarity index 100% rename from builder/docker/artifact_import.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/artifact_import.go diff --git a/builder/docker/builder.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/builder.go similarity index 100% rename from builder/docker/builder.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/builder.go diff --git a/builder/docker/comm.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/comm.go similarity index 100% rename from builder/docker/comm.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/comm.go diff --git a/builder/docker/communicator.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/communicator.go similarity index 100% rename from builder/docker/communicator.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/communicator.go diff --git a/builder/docker/config.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/config.go similarity index 100% rename from builder/docker/config.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/config.go diff --git a/builder/docker/config.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/config.hcl2spec.go similarity index 100% rename from builder/docker/config.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/config.hcl2spec.go diff --git a/builder/docker/driver.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver.go similarity index 100% rename from builder/docker/driver.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver.go diff --git a/builder/docker/driver_docker.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver_docker.go similarity index 100% rename from builder/docker/driver_docker.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver_docker.go diff --git a/builder/docker/driver_mock.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver_mock.go similarity index 100% rename from builder/docker/driver_mock.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/driver_mock.go diff --git a/builder/docker/ecr_login.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/ecr_login.go similarity index 53% rename from builder/docker/ecr_login.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/ecr_login.go index f553d6021..9ea40b158 100644 --- a/builder/docker/ecr_login.go +++ b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/ecr_login.go @@ -6,12 +6,16 @@ import ( "encoding/base64" "fmt" "log" + "net/http" "regexp" "strings" "github.com/aws/aws-sdk-go/aws" + awsCredentials "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" - "github.com/hashicorp/packer/builder/amazon/common" + awsbase "github.com/hashicorp/aws-sdk-go-base" + "github.com/hashicorp/go-cleanhttp" ) type AwsAccessConfig struct { @@ -32,7 +36,7 @@ type AwsAccessConfig struct { // communicate with AWS. Learn how to set // this. Profile string `mapstructure:"aws_profile" required:"false"` - cfg *common.AccessConfig + cfg *awsbase.Config } // Get a login token for Amazon AWS ECR. Returns username and password @@ -49,21 +53,49 @@ func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error) { log.Println(fmt.Sprintf("Getting ECR token for account: %s in %s..", accountId, region)) - c.cfg = &common.AccessConfig{ - AccessKey: c.AccessKey, - ProfileName: c.Profile, - RawRegion: region, - SecretKey: c.SecretKey, - Token: c.Token, + // Create new AWS config + config := aws.NewConfig().WithCredentialsChainVerboseErrors(true) + config = config.WithRegion(region) + + config = config.WithHTTPClient(cleanhttp.DefaultClient()) + transport := config.HTTPClient.Transport.(*http.Transport) + transport.Proxy = http.ProxyFromEnvironment + + // Figure out which possible credential providers are valid; test that we + // can get credentials via the selected providers, and set the providers in + // the config. + creds, err := c.GetCredentials(config) + if err != nil { + return "", "", fmt.Errorf(err.Error()) + } + config.WithCredentials(creds) + + // Create session options based on our AWS config + opts := session.Options{ + SharedConfigState: session.SharedConfigEnable, + Config: *config, } - session, err := c.cfg.Session() + if c.Profile != "" { + opts.Profile = c.Profile + } + + sess, err := session.NewSessionWithOptions(opts) + if err != nil { + return "", "", err + } + log.Printf("Found region %s", *sess.Config.Region) + session := sess + + cp, err := session.Config.Credentials.Get() + if err != nil { return "", "", fmt.Errorf("failed to create session: %s", err) } - service := ecr.New(session) + log.Printf("[INFO] AWS authentication used: %q", cp.ProviderName) + service := ecr.New(session) params := &ecr.GetAuthorizationTokenInput{ RegistryIds: []*string{ aws.String(accountId), @@ -84,3 +116,20 @@ func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error) { return authParts[0], authParts[1], nil } + +// GetCredentials gets credentials from the environment, shared credentials, +// the session (which may include a credential process), or ECS/EC2 metadata +// endpoints. GetCredentials also validates the credentials and the ability to +// assume a role or will return an error if unsuccessful. +func (c *AwsAccessConfig) GetCredentials(config *aws.Config) (*awsCredentials.Credentials, error) { + // Reload values into the config used by the Packer-Terraform shared SDK + awsbaseConfig := &awsbase.Config{ + AccessKey: c.AccessKey, + DebugLogging: false, + Profile: c.Profile, + SecretKey: c.SecretKey, + Token: c.Token, + } + + return awsbase.GetCredentials(awsbaseConfig) +} diff --git a/builder/docker/exec.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/exec.go similarity index 100% rename from builder/docker/exec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/exec.go diff --git a/builder/docker/step_commit.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_commit.go similarity index 100% rename from builder/docker/step_commit.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_commit.go diff --git a/builder/docker/step_connect_docker.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_connect_docker.go similarity index 100% rename from builder/docker/step_connect_docker.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_connect_docker.go diff --git a/builder/docker/step_export.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_export.go similarity index 100% rename from builder/docker/step_export.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_export.go diff --git a/builder/docker/step_pull.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_pull.go similarity index 100% rename from builder/docker/step_pull.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_pull.go diff --git a/builder/docker/step_run.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_run.go similarity index 100% rename from builder/docker/step_run.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_run.go diff --git a/builder/docker/step_set_generated_data.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_set_generated_data.go similarity index 100% rename from builder/docker/step_set_generated_data.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_set_generated_data.go diff --git a/builder/docker/step_temp_dir.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_temp_dir.go similarity index 100% rename from builder/docker/step_temp_dir.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/step_temp_dir.go diff --git a/builder/docker/windows_container_communicator.go b/vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/windows_container_communicator.go similarity index 100% rename from builder/docker/windows_container_communicator.go rename to vendor/github.com/hashicorp/packer-plugin-docker/builder/docker/windows_container_communicator.go diff --git a/post-processor/docker-import/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go similarity index 94% rename from post-processor/docker-import/post-processor.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go index c5fe3d496..16fcd161a 100644 --- a/post-processor/docker-import/post-processor.go +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go @@ -7,12 +7,11 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" "github.com/hashicorp/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/hashicorp/packer/builder/docker" - "github.com/hashicorp/packer/post-processor/artifice" ) const BuilderId = "packer.post-processor.docker-import" @@ -52,7 +51,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { switch artifact.BuilderId() { - case docker.BuilderId, artifice.BuilderId: + case docker.BuilderId, "packer.post-processor.artifice": break default: err := fmt.Errorf( diff --git a/post-processor/docker-import/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go similarity index 100% rename from post-processor/docker-import/post-processor.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go diff --git a/post-processor/docker-push/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go similarity index 93% rename from post-processor/docker-push/post-processor.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go index 8bb0763f3..fee6db49e 100644 --- a/post-processor/docker-push/post-processor.go +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go @@ -7,13 +7,13 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" "github.com/hashicorp/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/hashicorp/packer/builder/docker" - dockerimport "github.com/hashicorp/packer/post-processor/docker-import" - dockertag "github.com/hashicorp/packer/post-processor/docker-tag" ) const BuilderIdImport = "packer.post-processor.docker-import" diff --git a/post-processor/docker-push/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go similarity index 100% rename from post-processor/docker-push/post-processor.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go diff --git a/post-processor/docker-save/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go similarity index 90% rename from post-processor/docker-save/post-processor.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go index f1a1b49e9..a540f4d96 100644 --- a/post-processor/docker-save/post-processor.go +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go @@ -8,13 +8,13 @@ import ( "os" "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" "github.com/hashicorp/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/hashicorp/packer/builder/docker" - dockerimport "github.com/hashicorp/packer/post-processor/docker-import" - dockertag "github.com/hashicorp/packer/post-processor/docker-tag" ) const BuilderId = "packer.post-processor.docker-save" diff --git a/post-processor/docker-save/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go similarity index 100% rename from post-processor/docker-save/post-processor.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go diff --git a/post-processor/docker-tag/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go similarity index 95% rename from post-processor/docker-tag/post-processor.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go index d29769d56..14f1d5683 100644 --- a/post-processor/docker-tag/post-processor.go +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go @@ -7,12 +7,12 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" "github.com/hashicorp/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/hashicorp/packer/builder/docker" - dockerimport "github.com/hashicorp/packer/post-processor/docker-import" ) const BuilderId = "packer.post-processor.docker-tag" diff --git a/post-processor/docker-tag/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go similarity index 100% rename from post-processor/docker-tag/post-processor.hcl2spec.go rename to vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 3824c03df..4065c44a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -413,6 +413,12 @@ github.com/hashicorp/hcl/v2/hclparse github.com/hashicorp/hcl/v2/hclsyntax github.com/hashicorp/hcl/v2/hclwrite github.com/hashicorp/hcl/v2/json +# github.com/hashicorp/packer-plugin-docker v0.0.2 +github.com/hashicorp/packer-plugin-docker/builder/docker +github.com/hashicorp/packer-plugin-docker/post-processor/docker-import +github.com/hashicorp/packer-plugin-docker/post-processor/docker-push +github.com/hashicorp/packer-plugin-docker/post-processor/docker-save +github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag # github.com/hashicorp/packer-plugin-sdk v0.0.14 ## explicit github.com/hashicorp/packer-plugin-sdk/acctest From 9331afcf80420336d8225f9ab9a6ff128c80cc24 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 24 Feb 2021 16:39:56 -0800 Subject: [PATCH 02/10] revendor --- .../docker-import/post-processor.go | 91 ------------ .../docker-import/post-processor.hcl2spec.go | 51 ------- .../docker-push/post-processor.go | 138 ------------------ .../docker-push/post-processor.hcl2spec.go | 63 -------- .../docker-save/post-processor.go | 92 ------------ .../docker-save/post-processor.hcl2spec.go | 47 ------ .../docker-tag/post-processor.go | 122 ---------------- .../docker-tag/post-processor.hcl2spec.go | 53 ------- vendor/modules.txt | 4 - 9 files changed, 661 deletions(-) delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go delete mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go deleted file mode 100644 index 16fcd161a..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go +++ /dev/null @@ -1,91 +0,0 @@ -//go:generate mapstructure-to-hcl2 -type Config - -package dockerimport - -import ( - "context" - "fmt" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-docker/builder/docker" - "github.com/hashicorp/packer-plugin-sdk/common" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -const BuilderId = "packer.post-processor.docker-import" - -type Config struct { - common.PackerConfig `mapstructure:",squash"` - - Repository string `mapstructure:"repository"` - Tag string `mapstructure:"tag"` - Changes []string `mapstructure:"changes"` - - ctx interpolate.Context -} - -type PostProcessor struct { - config Config -} - -func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } - -func (p *PostProcessor) Configure(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: BuilderId, - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - - return nil - -} - -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { - switch artifact.BuilderId() { - case docker.BuilderId, "packer.post-processor.artifice": - break - default: - err := fmt.Errorf( - "Unknown artifact type: %s\nCan only import from Docker builder "+ - "and Artifice post-processor artifacts. If you are getting this "+ - "error after having run the docker builder, it may be because you "+ - "set commit: true in your Docker builder, so the image is "+ - "already imported. ", - artifact.BuilderId()) - return nil, false, false, err - } - - importRepo := p.config.Repository - if p.config.Tag != "" { - importRepo += ":" + p.config.Tag - } - - driver := &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} - - ui.Message("Importing image: " + artifact.Id()) - ui.Message("Repository: " + importRepo) - id, err := driver.Import(artifact.Files()[0], p.config.Changes, importRepo) - if err != nil { - return nil, false, false, err - } - - ui.Message("Imported ID: " + id) - - // Build the artifact - artifact = &docker.ImportArtifact{ - BuilderIdValue: BuilderId, - Driver: driver, - IdValue: importRepo, - } - - return artifact, false, false, nil -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go deleted file mode 100644 index 02d0f0e13..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go +++ /dev/null @@ -1,51 +0,0 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. - -package dockerimport - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` - PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` - PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` - PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` - PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` - PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` - PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` - PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` - Repository *string `mapstructure:"repository" cty:"repository" hcl:"repository"` - Tag *string `mapstructure:"tag" cty:"tag" hcl:"tag"` - Changes []string `mapstructure:"changes" cty:"changes" hcl:"changes"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, - "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, - "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, - "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, - "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, - "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, - "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, - "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, - "repository": &hcldec.AttrSpec{Name: "repository", Type: cty.String, Required: false}, - "tag": &hcldec.AttrSpec{Name: "tag", Type: cty.String, Required: false}, - "changes": &hcldec.AttrSpec{Name: "changes", Type: cty.List(cty.String), Required: false}, - } - return s -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go deleted file mode 100644 index fee6db49e..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go +++ /dev/null @@ -1,138 +0,0 @@ -//go:generate mapstructure-to-hcl2 -type Config - -package dockerpush - -import ( - "context" - "fmt" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-docker/builder/docker" - dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" - dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" - "github.com/hashicorp/packer-plugin-sdk/common" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -const BuilderIdImport = "packer.post-processor.docker-import" - -type Config struct { - common.PackerConfig `mapstructure:",squash"` - - Login bool - LoginUsername string `mapstructure:"login_username"` - LoginPassword string `mapstructure:"login_password"` - LoginServer string `mapstructure:"login_server"` - EcrLogin bool `mapstructure:"ecr_login"` - docker.AwsAccessConfig `mapstructure:",squash"` - - ctx interpolate.Context -} - -type PostProcessor struct { - Driver docker.Driver - - config Config -} - -func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } - -func (p *PostProcessor) Configure(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: BuilderIdImport, - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - - if p.config.EcrLogin && p.config.LoginServer == "" { - return fmt.Errorf("ECR login requires login server to be provided.") - } - return nil -} - -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { - if artifact.BuilderId() != dockerimport.BuilderId && - artifact.BuilderId() != dockertag.BuilderId { - err := fmt.Errorf( - "Unknown artifact type: %s\nCan only import from docker-import and docker-tag artifacts.", - artifact.BuilderId()) - return nil, false, false, err - } - - driver := p.Driver - if driver == nil { - // If no driver is set, then we use the real driver - driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} - } - - if p.config.EcrLogin { - ui.Message("Fetching ECR credentials...") - - username, password, err := p.config.EcrGetLogin(p.config.LoginServer) - if err != nil { - return nil, false, false, err - } - - p.config.LoginUsername = username - p.config.LoginPassword = password - } - - if p.config.Login || p.config.EcrLogin { - ui.Message("Logging in...") - err := driver.Login( - p.config.LoginServer, - p.config.LoginUsername, - p.config.LoginPassword) - if err != nil { - return nil, false, false, fmt.Errorf( - "Error logging in to Docker: %s", err) - } - - defer func() { - ui.Message("Logging out...") - if err := driver.Logout(p.config.LoginServer); err != nil { - ui.Error(fmt.Sprintf("Error logging out: %s", err)) - } - }() - } - - var tags []string - switch t := artifact.State("docker_tags").(type) { - case []string: - tags = t - case []interface{}: - for _, name := range t { - if n, ok := name.(string); ok { - tags = append(tags, n) - } - } - } - - names := []string{artifact.Id()} - names = append(names, tags...) - - // Get the name. - for _, name := range names { - ui.Message("Pushing: " + name) - if err := driver.Push(name); err != nil { - return nil, false, false, err - } - } - - artifact = &docker.ImportArtifact{ - BuilderIdValue: BuilderIdImport, - Driver: driver, - IdValue: names[0], - StateData: map[string]interface{}{"docker_tags": tags}, - } - - return artifact, true, false, nil -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go deleted file mode 100644 index 9ff9fd0c3..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. - -package dockerpush - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` - PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` - PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` - PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` - PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` - PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` - PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` - PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` - Login *bool `cty:"login" hcl:"login"` - LoginUsername *string `mapstructure:"login_username" cty:"login_username" hcl:"login_username"` - LoginPassword *string `mapstructure:"login_password" cty:"login_password" hcl:"login_password"` - LoginServer *string `mapstructure:"login_server" cty:"login_server" hcl:"login_server"` - EcrLogin *bool `mapstructure:"ecr_login" cty:"ecr_login" hcl:"ecr_login"` - AccessKey *string `mapstructure:"aws_access_key" required:"false" cty:"aws_access_key" hcl:"aws_access_key"` - SecretKey *string `mapstructure:"aws_secret_key" required:"false" cty:"aws_secret_key" hcl:"aws_secret_key"` - Token *string `mapstructure:"aws_token" required:"false" cty:"aws_token" hcl:"aws_token"` - Profile *string `mapstructure:"aws_profile" required:"false" cty:"aws_profile" hcl:"aws_profile"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, - "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, - "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, - "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, - "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, - "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, - "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, - "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, - "login": &hcldec.AttrSpec{Name: "login", Type: cty.Bool, Required: false}, - "login_username": &hcldec.AttrSpec{Name: "login_username", Type: cty.String, Required: false}, - "login_password": &hcldec.AttrSpec{Name: "login_password", Type: cty.String, Required: false}, - "login_server": &hcldec.AttrSpec{Name: "login_server", Type: cty.String, Required: false}, - "ecr_login": &hcldec.AttrSpec{Name: "ecr_login", Type: cty.Bool, Required: false}, - "aws_access_key": &hcldec.AttrSpec{Name: "aws_access_key", Type: cty.String, Required: false}, - "aws_secret_key": &hcldec.AttrSpec{Name: "aws_secret_key", Type: cty.String, Required: false}, - "aws_token": &hcldec.AttrSpec{Name: "aws_token", Type: cty.String, Required: false}, - "aws_profile": &hcldec.AttrSpec{Name: "aws_profile", Type: cty.String, Required: false}, - } - return s -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go deleted file mode 100644 index a540f4d96..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go +++ /dev/null @@ -1,92 +0,0 @@ -//go:generate mapstructure-to-hcl2 -type Config - -package dockersave - -import ( - "context" - "fmt" - "os" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-docker/builder/docker" - dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" - dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" - "github.com/hashicorp/packer-plugin-sdk/common" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -const BuilderId = "packer.post-processor.docker-save" - -type Config struct { - common.PackerConfig `mapstructure:",squash"` - - Path string `mapstructure:"path"` - - ctx interpolate.Context -} - -type PostProcessor struct { - Driver docker.Driver - - config Config -} - -func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } - -func (p *PostProcessor) Configure(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: BuilderId, - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - - return nil - -} - -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { - if artifact.BuilderId() != dockerimport.BuilderId && - artifact.BuilderId() != dockertag.BuilderId { - err := fmt.Errorf( - "Unknown artifact type: %s\nCan only save Docker builder artifacts.", - artifact.BuilderId()) - return nil, false, false, err - } - - path := p.config.Path - - // Open the file that we're going to write to - f, err := os.Create(path) - if err != nil { - err := fmt.Errorf("Error creating output file: %s", err) - return nil, false, false, err - } - - driver := p.Driver - if driver == nil { - // If no driver is set, then we use the real driver - driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} - } - - ui.Message("Saving image: " + artifact.Id()) - - if err := driver.SaveImage(artifact.Id(), f); err != nil { - f.Close() - os.Remove(f.Name()) - - return nil, false, false, err - } - - f.Close() - ui.Message("Saved to: " + path) - - return artifact, true, false, nil -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go deleted file mode 100644 index 5abf3e78c..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. - -package dockersave - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` - PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` - PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` - PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` - PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` - PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` - PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` - PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` - Path *string `mapstructure:"path" cty:"path" hcl:"path"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, - "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, - "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, - "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, - "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, - "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, - "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, - "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, - "path": &hcldec.AttrSpec{Name: "path", Type: cty.String, Required: false}, - } - return s -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go deleted file mode 100644 index 14f1d5683..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go +++ /dev/null @@ -1,122 +0,0 @@ -//go:generate mapstructure-to-hcl2 -type Config - -package dockertag - -import ( - "context" - "fmt" - - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer-plugin-docker/builder/docker" - dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" - "github.com/hashicorp/packer-plugin-sdk/common" - packersdk "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/hashicorp/packer-plugin-sdk/template/config" - "github.com/hashicorp/packer-plugin-sdk/template/interpolate" -) - -const BuilderId = "packer.post-processor.docker-tag" - -type Config struct { - common.PackerConfig `mapstructure:",squash"` - - Repository string `mapstructure:"repository"` - // Kept for backwards compatability - Tag []string `mapstructure:"tag"` - Tags []string `mapstructure:"tags"` - Force bool - - ctx interpolate.Context -} - -type PostProcessor struct { - Driver docker.Driver - - config Config -} - -func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } - -func (p *PostProcessor) Configure(raws ...interface{}) error { - err := config.Decode(&p.config, &config.DecodeOpts{ - PluginType: BuilderId, - Interpolate: true, - InterpolateContext: &p.config.ctx, - InterpolateFilter: &interpolate.RenderFilter{ - Exclude: []string{}, - }, - }, raws...) - if err != nil { - return err - } - - // combine Tag and Tags fields - allTags := p.config.Tags - allTags = append(allTags, p.config.Tag...) - - p.config.Tags = allTags - - return nil - -} - -func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { - if len(p.config.Tag) > 0 { - ui.Say("Deprecation warning: \"tag\" option has been replaced with " + - "\"tags\". In future versions of Packer, this configuration may " + - "not work. Please call `packer fix` on your template to update.") - } - - if artifact.BuilderId() != BuilderId && - artifact.BuilderId() != dockerimport.BuilderId { - err := fmt.Errorf( - "Unknown artifact type: %s\nCan only tag from Docker builder artifacts.", - artifact.BuilderId()) - return nil, false, true, err - } - - driver := p.Driver - if driver == nil { - // If no driver is set, then we use the real driver - driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} - } - - importRepo := p.config.Repository - var lastTaggedRepo = importRepo - RepoTags := []string{} - - if len(p.config.Tags) > 0 { - for _, tag := range p.config.Tags { - local := importRepo + ":" + tag - ui.Message("Tagging image: " + artifact.Id()) - ui.Message("Repository: " + local) - - err := driver.TagImage(artifact.Id(), local, p.config.Force) - if err != nil { - return nil, false, true, err - } - - RepoTags = append(RepoTags, local) - lastTaggedRepo = local - } - } else { - ui.Message("Tagging image: " + artifact.Id()) - ui.Message("Repository: " + importRepo) - err := driver.TagImage(artifact.Id(), importRepo, p.config.Force) - if err != nil { - return nil, false, true, err - } - } - - // Build the artifact - artifact = &docker.ImportArtifact{ - BuilderIdValue: BuilderId, - Driver: driver, - IdValue: lastTaggedRepo, - StateData: map[string]interface{}{"docker_tags": RepoTags}, - } - - // If we tag an image and then delete it, there was no point in creating the - // tag. Override users to force us to always keep the input artifact. - return artifact, true, true, nil -} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go deleted file mode 100644 index 3f2a092be..000000000 --- a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. - -package dockertag - -import ( - "github.com/hashicorp/hcl/v2/hcldec" - "github.com/zclconf/go-cty/cty" -) - -// FlatConfig is an auto-generated flat version of Config. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatConfig struct { - PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` - PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` - PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` - PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` - PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` - PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` - PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` - PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` - Repository *string `mapstructure:"repository" cty:"repository" hcl:"repository"` - Tag []string `mapstructure:"tag" cty:"tag" hcl:"tag"` - Tags []string `mapstructure:"tags" cty:"tags" hcl:"tags"` - Force *bool `cty:"force" hcl:"force"` -} - -// FlatMapstructure returns a new FlatConfig. -// FlatConfig is an auto-generated flat version of Config. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatConfig) -} - -// HCL2Spec returns the hcl spec of a Config. -// This spec is used by HCL to read the fields of Config. -// The decoded values from this spec will then be applied to a FlatConfig. -func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, - "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, - "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, - "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, - "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, - "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, - "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, - "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, - "repository": &hcldec.AttrSpec{Name: "repository", Type: cty.String, Required: false}, - "tag": &hcldec.AttrSpec{Name: "tag", Type: cty.List(cty.String), Required: false}, - "tags": &hcldec.AttrSpec{Name: "tags", Type: cty.List(cty.String), Required: false}, - "force": &hcldec.AttrSpec{Name: "force", Type: cty.Bool, Required: false}, - } - return s -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4065c44a5..e3d447884 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -415,10 +415,6 @@ github.com/hashicorp/hcl/v2/hclwrite github.com/hashicorp/hcl/v2/json # github.com/hashicorp/packer-plugin-docker v0.0.2 github.com/hashicorp/packer-plugin-docker/builder/docker -github.com/hashicorp/packer-plugin-docker/post-processor/docker-import -github.com/hashicorp/packer-plugin-docker/post-processor/docker-push -github.com/hashicorp/packer-plugin-docker/post-processor/docker-save -github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag # github.com/hashicorp/packer-plugin-sdk v0.0.14 ## explicit github.com/hashicorp/packer-plugin-sdk/acctest From 1c3c1f17d95b2c0743993c30b8431c4a64439cc7 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 25 Feb 2021 12:45:39 -0800 Subject: [PATCH 03/10] stop generating plugins file to make it possible to vendor plugins --- command/plugin.go | 19 +++++++++++++++---- main.go | 1 - 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/command/plugin.go b/command/plugin.go index 2e039ed6c..cb378dec3 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -1,7 +1,3 @@ -// -// This file is automatically generated by scripts/generate-plugins.go -- Do not edit! -// - package command import ( @@ -13,6 +9,16 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/plugin" + // Previously core-bundled components, split into their own plugins but + // still vendored with Packer for now. Importing as library instead of + // forcing use of packer init, until packer v1.8.0 + dockerbuilder "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimportpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockerpushpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-push" + dockersavepostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-save" + dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" + + // These components are still built into the packer core repo alicloudecsbuilder "github.com/hashicorp/packer/builder/alicloud/ecs" amazonchrootbuilder "github.com/hashicorp/packer/builder/amazon/chroot" amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs" @@ -120,6 +126,7 @@ var Builders = map[string]packersdk.Builder{ "azure-dtl": new(azuredtlbuilder.Builder), "cloudstack": new(cloudstackbuilder.Builder), "digitalocean": new(digitaloceanbuilder.Builder), + "docker": new(dockerbuilder.Builder), "file": new(filebuilder.Builder), "googlecompute": new(googlecomputebuilder.Builder), "hcloud": new(hcloudbuilder.Builder), @@ -190,6 +197,10 @@ var PostProcessors = map[string]packersdk.PostProcessor{ "checksum": new(checksumpostprocessor.PostProcessor), "compress": new(compresspostprocessor.PostProcessor), "digitalocean-import": new(digitaloceanimportpostprocessor.PostProcessor), + "docker-import": new(dockerimportpostprocessor.PostProcessor), + "docker-push": new(dockerpushpostprocessor.PostProcessor), + "docker-save": new(dockersavepostprocessor.PostProcessor), + "docker-tag": new(dockertagpostprocessor.PostProcessor), "exoscale-import": new(exoscaleimportpostprocessor.PostProcessor), "googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor), "googlecompute-import": new(googlecomputeimportpostprocessor.PostProcessor), diff --git a/main.go b/main.go index f7806b0bc..f358c2f05 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,5 @@ // This is the main package for the `packer` application. -//go:generate go run ./scripts/generate-plugins.go package main import ( From 04cbcd7ae91bdb2e1522a340a264e07dc07e98c9 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 25 Feb 2021 12:57:27 -0800 Subject: [PATCH 04/10] add docker vendoring to modules.txt --- vendor/modules.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/modules.txt b/vendor/modules.txt index e3d447884..4065c44a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -415,6 +415,10 @@ github.com/hashicorp/hcl/v2/hclwrite github.com/hashicorp/hcl/v2/json # github.com/hashicorp/packer-plugin-docker v0.0.2 github.com/hashicorp/packer-plugin-docker/builder/docker +github.com/hashicorp/packer-plugin-docker/post-processor/docker-import +github.com/hashicorp/packer-plugin-docker/post-processor/docker-push +github.com/hashicorp/packer-plugin-docker/post-processor/docker-save +github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag # github.com/hashicorp/packer-plugin-sdk v0.0.14 ## explicit github.com/hashicorp/packer-plugin-sdk/acctest From c3e48ebb71f3030014a90a1ac923c39f03c3d099 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 25 Feb 2021 12:57:47 -0800 Subject: [PATCH 05/10] add vendored files --- .../docker-import/post-processor.go | 91 ++++++++++++ .../docker-import/post-processor.hcl2spec.go | 51 +++++++ .../docker-push/post-processor.go | 138 ++++++++++++++++++ .../docker-push/post-processor.hcl2spec.go | 63 ++++++++ .../docker-save/post-processor.go | 92 ++++++++++++ .../docker-save/post-processor.hcl2spec.go | 47 ++++++ .../docker-tag/post-processor.go | 122 ++++++++++++++++ .../docker-tag/post-processor.hcl2spec.go | 53 +++++++ 8 files changed, 657 insertions(+) create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go create mode 100644 vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go new file mode 100644 index 000000000..16fcd161a --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.go @@ -0,0 +1,91 @@ +//go:generate mapstructure-to-hcl2 -type Config + +package dockerimport + +import ( + "context" + "fmt" + + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + "github.com/hashicorp/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer-plugin-sdk/packer" + "github.com/hashicorp/packer-plugin-sdk/template/config" + "github.com/hashicorp/packer-plugin-sdk/template/interpolate" +) + +const BuilderId = "packer.post-processor.docker-import" + +type Config struct { + common.PackerConfig `mapstructure:",squash"` + + Repository string `mapstructure:"repository"` + Tag string `mapstructure:"tag"` + Changes []string `mapstructure:"changes"` + + ctx interpolate.Context +} + +type PostProcessor struct { + config Config +} + +func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } + +func (p *PostProcessor) Configure(raws ...interface{}) error { + err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, + Interpolate: true, + InterpolateContext: &p.config.ctx, + InterpolateFilter: &interpolate.RenderFilter{ + Exclude: []string{}, + }, + }, raws...) + if err != nil { + return err + } + + return nil + +} + +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { + switch artifact.BuilderId() { + case docker.BuilderId, "packer.post-processor.artifice": + break + default: + err := fmt.Errorf( + "Unknown artifact type: %s\nCan only import from Docker builder "+ + "and Artifice post-processor artifacts. If you are getting this "+ + "error after having run the docker builder, it may be because you "+ + "set commit: true in your Docker builder, so the image is "+ + "already imported. ", + artifact.BuilderId()) + return nil, false, false, err + } + + importRepo := p.config.Repository + if p.config.Tag != "" { + importRepo += ":" + p.config.Tag + } + + driver := &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} + + ui.Message("Importing image: " + artifact.Id()) + ui.Message("Repository: " + importRepo) + id, err := driver.Import(artifact.Files()[0], p.config.Changes, importRepo) + if err != nil { + return nil, false, false, err + } + + ui.Message("Imported ID: " + id) + + // Build the artifact + artifact = &docker.ImportArtifact{ + BuilderIdValue: BuilderId, + Driver: driver, + IdValue: importRepo, + } + + return artifact, false, false, nil +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go new file mode 100644 index 000000000..02d0f0e13 --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-import/post-processor.hcl2spec.go @@ -0,0 +1,51 @@ +// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. + +package dockerimport + +import ( + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/zclconf/go-cty/cty" +) + +// FlatConfig is an auto-generated flat version of Config. +// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. +type FlatConfig struct { + PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` + PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` + PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` + PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` + PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` + PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` + PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` + PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` + Repository *string `mapstructure:"repository" cty:"repository" hcl:"repository"` + Tag *string `mapstructure:"tag" cty:"tag" hcl:"tag"` + Changes []string `mapstructure:"changes" cty:"changes" hcl:"changes"` +} + +// FlatMapstructure returns a new FlatConfig. +// FlatConfig is an auto-generated flat version of Config. +// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. +func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { + return new(FlatConfig) +} + +// HCL2Spec returns the hcl spec of a Config. +// This spec is used by HCL to read the fields of Config. +// The decoded values from this spec will then be applied to a FlatConfig. +func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { + s := map[string]hcldec.Spec{ + "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, + "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, + "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, + "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, + "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, + "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, + "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, + "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, + "repository": &hcldec.AttrSpec{Name: "repository", Type: cty.String, Required: false}, + "tag": &hcldec.AttrSpec{Name: "tag", Type: cty.String, Required: false}, + "changes": &hcldec.AttrSpec{Name: "changes", Type: cty.List(cty.String), Required: false}, + } + return s +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go new file mode 100644 index 000000000..fee6db49e --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.go @@ -0,0 +1,138 @@ +//go:generate mapstructure-to-hcl2 -type Config + +package dockerpush + +import ( + "context" + "fmt" + + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" + "github.com/hashicorp/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer-plugin-sdk/packer" + "github.com/hashicorp/packer-plugin-sdk/template/config" + "github.com/hashicorp/packer-plugin-sdk/template/interpolate" +) + +const BuilderIdImport = "packer.post-processor.docker-import" + +type Config struct { + common.PackerConfig `mapstructure:",squash"` + + Login bool + LoginUsername string `mapstructure:"login_username"` + LoginPassword string `mapstructure:"login_password"` + LoginServer string `mapstructure:"login_server"` + EcrLogin bool `mapstructure:"ecr_login"` + docker.AwsAccessConfig `mapstructure:",squash"` + + ctx interpolate.Context +} + +type PostProcessor struct { + Driver docker.Driver + + config Config +} + +func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } + +func (p *PostProcessor) Configure(raws ...interface{}) error { + err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderIdImport, + Interpolate: true, + InterpolateContext: &p.config.ctx, + InterpolateFilter: &interpolate.RenderFilter{ + Exclude: []string{}, + }, + }, raws...) + if err != nil { + return err + } + + if p.config.EcrLogin && p.config.LoginServer == "" { + return fmt.Errorf("ECR login requires login server to be provided.") + } + return nil +} + +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { + if artifact.BuilderId() != dockerimport.BuilderId && + artifact.BuilderId() != dockertag.BuilderId { + err := fmt.Errorf( + "Unknown artifact type: %s\nCan only import from docker-import and docker-tag artifacts.", + artifact.BuilderId()) + return nil, false, false, err + } + + driver := p.Driver + if driver == nil { + // If no driver is set, then we use the real driver + driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} + } + + if p.config.EcrLogin { + ui.Message("Fetching ECR credentials...") + + username, password, err := p.config.EcrGetLogin(p.config.LoginServer) + if err != nil { + return nil, false, false, err + } + + p.config.LoginUsername = username + p.config.LoginPassword = password + } + + if p.config.Login || p.config.EcrLogin { + ui.Message("Logging in...") + err := driver.Login( + p.config.LoginServer, + p.config.LoginUsername, + p.config.LoginPassword) + if err != nil { + return nil, false, false, fmt.Errorf( + "Error logging in to Docker: %s", err) + } + + defer func() { + ui.Message("Logging out...") + if err := driver.Logout(p.config.LoginServer); err != nil { + ui.Error(fmt.Sprintf("Error logging out: %s", err)) + } + }() + } + + var tags []string + switch t := artifact.State("docker_tags").(type) { + case []string: + tags = t + case []interface{}: + for _, name := range t { + if n, ok := name.(string); ok { + tags = append(tags, n) + } + } + } + + names := []string{artifact.Id()} + names = append(names, tags...) + + // Get the name. + for _, name := range names { + ui.Message("Pushing: " + name) + if err := driver.Push(name); err != nil { + return nil, false, false, err + } + } + + artifact = &docker.ImportArtifact{ + BuilderIdValue: BuilderIdImport, + Driver: driver, + IdValue: names[0], + StateData: map[string]interface{}{"docker_tags": tags}, + } + + return artifact, true, false, nil +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go new file mode 100644 index 000000000..9ff9fd0c3 --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-push/post-processor.hcl2spec.go @@ -0,0 +1,63 @@ +// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. + +package dockerpush + +import ( + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/zclconf/go-cty/cty" +) + +// FlatConfig is an auto-generated flat version of Config. +// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. +type FlatConfig struct { + PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` + PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` + PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` + PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` + PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` + PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` + PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` + PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` + Login *bool `cty:"login" hcl:"login"` + LoginUsername *string `mapstructure:"login_username" cty:"login_username" hcl:"login_username"` + LoginPassword *string `mapstructure:"login_password" cty:"login_password" hcl:"login_password"` + LoginServer *string `mapstructure:"login_server" cty:"login_server" hcl:"login_server"` + EcrLogin *bool `mapstructure:"ecr_login" cty:"ecr_login" hcl:"ecr_login"` + AccessKey *string `mapstructure:"aws_access_key" required:"false" cty:"aws_access_key" hcl:"aws_access_key"` + SecretKey *string `mapstructure:"aws_secret_key" required:"false" cty:"aws_secret_key" hcl:"aws_secret_key"` + Token *string `mapstructure:"aws_token" required:"false" cty:"aws_token" hcl:"aws_token"` + Profile *string `mapstructure:"aws_profile" required:"false" cty:"aws_profile" hcl:"aws_profile"` +} + +// FlatMapstructure returns a new FlatConfig. +// FlatConfig is an auto-generated flat version of Config. +// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. +func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { + return new(FlatConfig) +} + +// HCL2Spec returns the hcl spec of a Config. +// This spec is used by HCL to read the fields of Config. +// The decoded values from this spec will then be applied to a FlatConfig. +func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { + s := map[string]hcldec.Spec{ + "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, + "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, + "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, + "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, + "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, + "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, + "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, + "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, + "login": &hcldec.AttrSpec{Name: "login", Type: cty.Bool, Required: false}, + "login_username": &hcldec.AttrSpec{Name: "login_username", Type: cty.String, Required: false}, + "login_password": &hcldec.AttrSpec{Name: "login_password", Type: cty.String, Required: false}, + "login_server": &hcldec.AttrSpec{Name: "login_server", Type: cty.String, Required: false}, + "ecr_login": &hcldec.AttrSpec{Name: "ecr_login", Type: cty.Bool, Required: false}, + "aws_access_key": &hcldec.AttrSpec{Name: "aws_access_key", Type: cty.String, Required: false}, + "aws_secret_key": &hcldec.AttrSpec{Name: "aws_secret_key", Type: cty.String, Required: false}, + "aws_token": &hcldec.AttrSpec{Name: "aws_token", Type: cty.String, Required: false}, + "aws_profile": &hcldec.AttrSpec{Name: "aws_profile", Type: cty.String, Required: false}, + } + return s +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go new file mode 100644 index 000000000..a540f4d96 --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.go @@ -0,0 +1,92 @@ +//go:generate mapstructure-to-hcl2 -type Config + +package dockersave + +import ( + "context" + "fmt" + "os" + + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockertag "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" + "github.com/hashicorp/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer-plugin-sdk/packer" + "github.com/hashicorp/packer-plugin-sdk/template/config" + "github.com/hashicorp/packer-plugin-sdk/template/interpolate" +) + +const BuilderId = "packer.post-processor.docker-save" + +type Config struct { + common.PackerConfig `mapstructure:",squash"` + + Path string `mapstructure:"path"` + + ctx interpolate.Context +} + +type PostProcessor struct { + Driver docker.Driver + + config Config +} + +func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } + +func (p *PostProcessor) Configure(raws ...interface{}) error { + err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, + Interpolate: true, + InterpolateContext: &p.config.ctx, + InterpolateFilter: &interpolate.RenderFilter{ + Exclude: []string{}, + }, + }, raws...) + if err != nil { + return err + } + + return nil + +} + +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { + if artifact.BuilderId() != dockerimport.BuilderId && + artifact.BuilderId() != dockertag.BuilderId { + err := fmt.Errorf( + "Unknown artifact type: %s\nCan only save Docker builder artifacts.", + artifact.BuilderId()) + return nil, false, false, err + } + + path := p.config.Path + + // Open the file that we're going to write to + f, err := os.Create(path) + if err != nil { + err := fmt.Errorf("Error creating output file: %s", err) + return nil, false, false, err + } + + driver := p.Driver + if driver == nil { + // If no driver is set, then we use the real driver + driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} + } + + ui.Message("Saving image: " + artifact.Id()) + + if err := driver.SaveImage(artifact.Id(), f); err != nil { + f.Close() + os.Remove(f.Name()) + + return nil, false, false, err + } + + f.Close() + ui.Message("Saved to: " + path) + + return artifact, true, false, nil +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go new file mode 100644 index 000000000..5abf3e78c --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-save/post-processor.hcl2spec.go @@ -0,0 +1,47 @@ +// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. + +package dockersave + +import ( + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/zclconf/go-cty/cty" +) + +// FlatConfig is an auto-generated flat version of Config. +// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. +type FlatConfig struct { + PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` + PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` + PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` + PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` + PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` + PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` + PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` + PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` + Path *string `mapstructure:"path" cty:"path" hcl:"path"` +} + +// FlatMapstructure returns a new FlatConfig. +// FlatConfig is an auto-generated flat version of Config. +// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. +func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { + return new(FlatConfig) +} + +// HCL2Spec returns the hcl spec of a Config. +// This spec is used by HCL to read the fields of Config. +// The decoded values from this spec will then be applied to a FlatConfig. +func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { + s := map[string]hcldec.Spec{ + "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, + "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, + "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, + "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, + "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, + "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, + "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, + "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, + "path": &hcldec.AttrSpec{Name: "path", Type: cty.String, Required: false}, + } + return s +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go new file mode 100644 index 000000000..14f1d5683 --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.go @@ -0,0 +1,122 @@ +//go:generate mapstructure-to-hcl2 -type Config + +package dockertag + +import ( + "context" + "fmt" + + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimport "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + "github.com/hashicorp/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer-plugin-sdk/packer" + "github.com/hashicorp/packer-plugin-sdk/template/config" + "github.com/hashicorp/packer-plugin-sdk/template/interpolate" +) + +const BuilderId = "packer.post-processor.docker-tag" + +type Config struct { + common.PackerConfig `mapstructure:",squash"` + + Repository string `mapstructure:"repository"` + // Kept for backwards compatability + Tag []string `mapstructure:"tag"` + Tags []string `mapstructure:"tags"` + Force bool + + ctx interpolate.Context +} + +type PostProcessor struct { + Driver docker.Driver + + config Config +} + +func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } + +func (p *PostProcessor) Configure(raws ...interface{}) error { + err := config.Decode(&p.config, &config.DecodeOpts{ + PluginType: BuilderId, + Interpolate: true, + InterpolateContext: &p.config.ctx, + InterpolateFilter: &interpolate.RenderFilter{ + Exclude: []string{}, + }, + }, raws...) + if err != nil { + return err + } + + // combine Tag and Tags fields + allTags := p.config.Tags + allTags = append(allTags, p.config.Tag...) + + p.config.Tags = allTags + + return nil + +} + +func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifact packersdk.Artifact) (packersdk.Artifact, bool, bool, error) { + if len(p.config.Tag) > 0 { + ui.Say("Deprecation warning: \"tag\" option has been replaced with " + + "\"tags\". In future versions of Packer, this configuration may " + + "not work. Please call `packer fix` on your template to update.") + } + + if artifact.BuilderId() != BuilderId && + artifact.BuilderId() != dockerimport.BuilderId { + err := fmt.Errorf( + "Unknown artifact type: %s\nCan only tag from Docker builder artifacts.", + artifact.BuilderId()) + return nil, false, true, err + } + + driver := p.Driver + if driver == nil { + // If no driver is set, then we use the real driver + driver = &docker.DockerDriver{Ctx: &p.config.ctx, Ui: ui} + } + + importRepo := p.config.Repository + var lastTaggedRepo = importRepo + RepoTags := []string{} + + if len(p.config.Tags) > 0 { + for _, tag := range p.config.Tags { + local := importRepo + ":" + tag + ui.Message("Tagging image: " + artifact.Id()) + ui.Message("Repository: " + local) + + err := driver.TagImage(artifact.Id(), local, p.config.Force) + if err != nil { + return nil, false, true, err + } + + RepoTags = append(RepoTags, local) + lastTaggedRepo = local + } + } else { + ui.Message("Tagging image: " + artifact.Id()) + ui.Message("Repository: " + importRepo) + err := driver.TagImage(artifact.Id(), importRepo, p.config.Force) + if err != nil { + return nil, false, true, err + } + } + + // Build the artifact + artifact = &docker.ImportArtifact{ + BuilderIdValue: BuilderId, + Driver: driver, + IdValue: lastTaggedRepo, + StateData: map[string]interface{}{"docker_tags": RepoTags}, + } + + // If we tag an image and then delete it, there was no point in creating the + // tag. Override users to force us to always keep the input artifact. + return artifact, true, true, nil +} diff --git a/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go new file mode 100644 index 000000000..3f2a092be --- /dev/null +++ b/vendor/github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag/post-processor.hcl2spec.go @@ -0,0 +1,53 @@ +// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. + +package dockertag + +import ( + "github.com/hashicorp/hcl/v2/hcldec" + "github.com/zclconf/go-cty/cty" +) + +// FlatConfig is an auto-generated flat version of Config. +// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. +type FlatConfig struct { + PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` + PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` + PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` + PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` + PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` + PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` + PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"` + PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"` + Repository *string `mapstructure:"repository" cty:"repository" hcl:"repository"` + Tag []string `mapstructure:"tag" cty:"tag" hcl:"tag"` + Tags []string `mapstructure:"tags" cty:"tags" hcl:"tags"` + Force *bool `cty:"force" hcl:"force"` +} + +// FlatMapstructure returns a new FlatConfig. +// FlatConfig is an auto-generated flat version of Config. +// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. +func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { + return new(FlatConfig) +} + +// HCL2Spec returns the hcl spec of a Config. +// This spec is used by HCL to read the fields of Config. +// The decoded values from this spec will then be applied to a FlatConfig. +func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { + s := map[string]hcldec.Spec{ + "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, + "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, + "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, + "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, + "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, + "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, + "packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false}, + "packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false}, + "repository": &hcldec.AttrSpec{Name: "repository", Type: cty.String, Required: false}, + "tag": &hcldec.AttrSpec{Name: "tag", Type: cty.List(cty.String), Required: false}, + "tags": &hcldec.AttrSpec{Name: "tags", Type: cty.List(cty.String), Required: false}, + "force": &hcldec.AttrSpec{Name: "force", Type: cty.Bool, Required: false}, + } + return s +} From 10e157393009e3f8f825a0430415b7bf65103f37 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 26 Feb 2021 17:26:51 -0500 Subject: [PATCH 06/10] Remove docker documentation from website --- website/content/docs/builders/docker.mdx | 529 ------------------ .../docs/post-processors/docker-import.mdx | 217 ------- .../docs/post-processors/docker-push.mdx | 69 --- .../docs/post-processors/docker-save.mdx | 66 --- .../docs/post-processors/docker-tag.mdx | 83 --- .../docker/AwsAccessConfig-not-required.mdx | 18 - .../builder/docker/Config-not-required.mdx | 74 --- .../builder/docker/Config-required.mdx | 14 - 8 files changed, 1070 deletions(-) delete mode 100644 website/content/docs/builders/docker.mdx delete mode 100644 website/content/docs/post-processors/docker-import.mdx delete mode 100644 website/content/docs/post-processors/docker-push.mdx delete mode 100644 website/content/docs/post-processors/docker-save.mdx delete mode 100644 website/content/docs/post-processors/docker-tag.mdx delete mode 100644 website/content/partials/builder/docker/AwsAccessConfig-not-required.mdx delete mode 100644 website/content/partials/builder/docker/Config-not-required.mdx delete mode 100644 website/content/partials/builder/docker/Config-required.mdx diff --git a/website/content/docs/builders/docker.mdx b/website/content/docs/builders/docker.mdx deleted file mode 100644 index 7172857c6..000000000 --- a/website/content/docs/builders/docker.mdx +++ /dev/null @@ -1,529 +0,0 @@ ---- -description: > - The docker Packer builder builds Docker images using Docker. The builder - starts - - a Docker container, runs provisioners within this container, then exports the - - container for reuse or commits the image. -page_title: Docker - Builders -sidebar_title: Docker ---- - -# Docker Builder - -Type: `docker` -Artifact BuilderId: `packer.docker` - -The `docker` Packer builder builds [Docker](https://www.docker.io) images using -Docker. The builder starts a Docker container, runs provisioners within this -container, then exports the container for reuse or commits the image. - -Packer builds Docker containers _without_ the use of -[Dockerfiles](https://docs.docker.com/engine/reference/builder/). By not using -`Dockerfiles`, Packer is able to provision containers with portable scripts or -configuration management systems that are not tied to Docker in any way. It -also has a simple mental model: you provision containers much the same way you -provision a normal virtualized or dedicated server. For more information, read -the section on [Dockerfiles](#dockerfiles). - -The Docker builder must run on a machine that has Docker Engine installed. -Therefore the builder only works on machines that support Docker and _does not -support running on a Docker remote host_. You can learn about what [platforms -Docker supports and how to install onto -them](https://docs.docker.com/engine/installation/) in the Docker -documentation. - -## Basic Example: Export - -Below is a fully functioning example. It doesn't do anything useful, since no -provisioners are defined, but it will effectively repackage an image. - - - - -```json -{ - "type": "docker", - "image": "ubuntu", - "export_path": "image.tar" -} -``` - - - - -```hcl -source "docker" "example" { - image = "ubuntu" - export_path = "image.tar" -} - -build { - sources = ["source.docker.example"] -} -``` - - - - -## Basic Example: Commit - -Below is another example, the same as above but instead of exporting the -running container, this one commits the container to an image. The image can -then be more easily tagged, pushed, etc. - - - - -```json -{ - "type": "docker", - "image": "ubuntu", - "commit": true -} -``` - - - - -```hcl -source "docker" "example" { - image = "ubuntu" - commit = true -} - -build { - sources = ["source.docker.example"] -} -``` - - - - -## Basic Example: Changes to Metadata - -Below is an example using the changes argument of the builder. This feature -allows the source images metadata to be changed when committed back into the -Docker environment. It is derived from the `docker commit --change` command -line [option to -Docker](https://docs.docker.com/engine/reference/commandline/commit/). - -Example uses of all of the options, assuming one is building an NGINX image -from ubuntu as an simple example: - - - - -```json -{ - "type": "docker", - "image": "ubuntu", - "commit": true, - "changes": [ - "USER www-data", - "WORKDIR /var/www", - "ENV HOSTNAME www.example.com", - "VOLUME /test1 /test2", - "EXPOSE 80 443", - "LABEL version=1.0", - "ONBUILD RUN date", - "CMD [\"nginx\", \"-g\", \"daemon off;\"]", - "ENTRYPOINT /var/www/start.sh" - ] -} -``` - - - - -```hcl -source "docker" "example" { - image = "ubuntu" - commit = true - changes = [ - "USER www-data", - "WORKDIR /var/www", - "ENV HOSTNAME www.example.com", - "VOLUME /test1 /test2", - "EXPOSE 80 443", - "LABEL version=1.0", - "ONBUILD RUN date", - "CMD [\"nginx\", \"-g\", \"daemon off;\"]", - "ENTRYPOINT /var/www/start.sh" - ] -} -``` - - - - -Allowed metadata fields that can be changed are: - -- CMD - - String, supports both array (escaped) and string form - - EX: `"CMD [\"nginx\", \"-g\", \"daemon off;\"]"` corresponds to Docker exec form - - EX: `"CMD nginx -g daemon off;"` corresponds to Docker shell form, invokes a command shell first -- ENTRYPOINT - - String, supports both array (escaped) and string form - - EX: `"ENTRYPOINT [\"/bin/sh\", \"-c\", \"/var/www/start.sh\"]"` corresponds to Docker exec form - - EX: `"ENTRYPOINT /var/www/start.sh"` corresponds to Docker shell form, invokes a command shell first -- ENV - - String, note there is no equal sign: - - EX: `"ENV HOSTNAME www.example.com"` not - `"ENV HOSTNAME=www.example.com"` -- EXPOSE - - String, space separated ports - - EX: `"EXPOSE 80 443"` -- LABEL - - String, space separated key=value pairs - - EX: `"LABEL version=1.0"` -- ONBUILD - - String - - EX: `"ONBUILD RUN date"` -- MAINTAINER - - String, deprecated in Docker version 1.13.0 - - EX: `"MAINTAINER NAME"` -- USER - - String - - EX: `"USER USERNAME"` -- VOLUME - - String - - EX: `"VOLUME FROM TO"` -- WORKDIR - - String - - EX: `"WORKDIR PATH"` - -## Configuration Reference - -Configuration options are organized below into two categories: required and -optional. Within each category, the available options are alphabetized and -described. - -The Docker builder uses a special Docker communicator _and will not use_ the -standard [communicators](/docs/templates/legacy_json_templates/communicator). - -### Required: - -You must specify (only) one of `commit`, `discard`, or `export_path`. - -@include 'builder/docker/Config-required.mdx' - -### Optional: - -@include 'builder/docker/AwsAccessConfig-not-required.mdx' - -@include 'builder/docker/Config-not-required.mdx' - -## Build Shared Information Variables - -This build shares generated data with provisioners and post-processors via [template engines](/docs/templates/legacy_json_templates/engine) -for JSON and [contextual variables](/docs/templates/hcl_templates/contextual-variables) for HCL2. - -The generated variable available for this builder is: - -- `ImageSha256` - When committing a container to an image, this will give the image SHA256. Because the image is not available at the provision step, - this variable is only available for post-processors. - -## Using the Artifact: Export - -Once the tar artifact has been generated, you will likely want to import, tag, -and push it to a container repository. Packer can do this for you automatically -with the [docker-import](/docs/post-processors/docker-import) and -[docker-push](/docs/post-processors/docker-push) post-processors. - -**Note:** This section is covering how to use an artifact that has been -_exported_. More specifically, if you set `export_path` in your configuration. -If you set `commit`, see the next section. - -The example below shows a full configuration that would import and push the -created image. This is accomplished using a sequence definition (a collection -of post-processors that are treated as as single pipeline, see -[Post-Processors](/docs/templates/legacy_json_templates/post-processors) for more information): - - - - -```json -{ - "post-processors": [ - [ - { - "type": "docker-import", - "repository": "myrepo/myimage", - "tag": "0.7" - }, - { - "type": "docker-push" - } - ] - ] -} -``` - - - - -```hcl - post-processors { - post-processor "docker-import" { - repository = "myrepo/myimage" - tag = ["0.7"] - } - post-processor "docker-push" {} - } -} -``` - - - - -In the above example, the result of each builder is passed through the defined -sequence of post-processors starting first with the `docker-import` -post-processor which will import the artifact as a docker image. The resulting -docker image is then passed on to the `docker-push` post-processor which -handles pushing the image to a container repository. - -If you want to do this manually, however, perhaps from a script, you can import -the image using the process below: - -```shell-session -$ docker import - registry.mydomain.com/mycontainer:latest < artifact.tar -``` - -You can then add additional tags and push the image as usual with `docker tag` -and `docker push`, respectively. - -## Using the Artifact: Committed - -If you committed your container to an image, you probably want to tag, save, -push, etc. Packer can do this automatically for you. An example is shown below -which tags and pushes an image. This is accomplished using a sequence -definition (a collection of post-processors that are treated as as single -pipeline, see [Post-Processors](/docs/templates/legacy_json_templates/post-processors) for more -information): - - - - -```json -{ - "post-processors": [ - [ - { - "type": "docker-tag", - "repository": "myrepo/myimage", - "tag": "0.7" - }, - { - "type": "docker-push" - } - ] - ] -} -``` - - - - -```hcl - post-processors { - post-processor "docker-tag" { - repository = "myrepo/myimage" - tag = ["0.7"] - } - post-processor "docker-push" {} - } -} -``` - - - - -In the above example, the result of each builder is passed through the defined -sequence of post-processors starting first with the `docker-tag` post-processor -which tags the committed image with the supplied repository and tag -information. Once tagged, the resulting artifact is then passed on to the -`docker-push` post-processor which handles pushing the image to a container -repository. - -Going a step further, if you wanted to tag and push an image to multiple -container repositories, this could be accomplished by defining two, -nearly-identical sequence definitions, as demonstrated by the example below: - - - - -```json -{ - "post-processors": [ - [ - { - "type": "docker-tag", - "repository": "myrepo/myimage1", - "tag": "0.7" - }, - "docker-push" - ], - [ - { - "type": "docker-tag", - "repository": "myrepo/myimage2", - "tag": "0.7" - }, - "docker-push" - ] - ] -} -``` - - - - -```hcl - post-processors { - post-processor "docker-tag" { - repository = "myrepo/myimage1" - tag = ["0.7"] - } - post-processor "docker-push" {} - } - post-processors { - post-processor "docker-tag" { - repository = "myrepo/myimage2" - tag = ["0.7"] - } - post-processor "docker-push" {} - } -} -``` - - - - - - -## Docker For Windows - -You should be able to run docker builds against both linux and Windows -containers. Windows containers use a different communicator than linux -containers, because Windows containers cannot use `docker cp`. - -If you are building a Windows container, you must set the template option -`"windows_container": true`. Please note that docker cannot export Windows -containers, so you must either commit or discard them. - -The following is a fully functional template for building a Windows -container. - - - - -```json -{ - "builders": [ - { - "type": "docker", - "image": "microsoft/windowsservercore:1709", - "container_dir": "c:/app", - "windows_container": true, - "commit": true - } - ] -} -``` - - - - -```hcl -source "docker" "windows" { - image = "ubuntu" - container_dir = "c:/app" - windows_container = true - commit = true -} - -build { - sources = ["source.docker.example"] -} -``` - - - - -## Amazon EC2 Container Registry - -Packer can tag and push images for use in [Amazon EC2 Container -Registry](https://aws.amazon.com/ecr/). The post processors work as described -above and example configuration properties are shown below: - - - - -```json -{ - "post-processors": [ - [ - { - "type": "docker-tag", - "repository": "12345.dkr.ecr.us-east-1.amazonaws.com/packer", - "tag": "0.7" - }, - { - "type": "docker-push", - "ecr_login": true, - "aws_access_key": "YOUR KEY HERE", - "aws_secret_key": "YOUR SECRET KEY HERE", - "login_server": "https://12345.dkr.ecr.us-east-1.amazonaws.com/" - } - ] - ] -} -``` - - - - -```hcl -post-processors { - post-processor "docker-tag" { - repository = "12345.dkr.ecr.us-east-1.amazonaws.com/packer" - tag = ["0.7"] - } - post-processor "docker-push" { - ecr_login = true - aws_access_key = "YOUR KEY HERE" - aws_secret_key = "YOUR SECRET KEY HERE" - login_server = "https://12345.dkr.ecr.us-east-1.amazonaws.com/" - } -} -``` - - - - -[Learn how to set Amazon AWS -credentials.](/docs/builders/amazon#specifying-amazon-credentials) - -## Dockerfiles - -This builder allows you to build Docker images _without_ Dockerfiles. - -With this builder, you can repeatedly create Docker images without the use of a -Dockerfile. You don't need to know the syntax or semantics of Dockerfiles. -Instead, you can just provide shell scripts, Chef recipes, Puppet manifests, -etc. to provision your Docker container just like you would a regular -virtualized or dedicated machine. - -While Docker has many features, Packer views Docker simply as a container -runner. To that end, Packer is able to repeatedly build these containers using -portable provisioning scripts. - -## Overriding the host directory - -By default, Packer creates a temporary folder under your home directory, and -uses that to stage files for uploading into the container. If you would like to -change the path to this temporary folder, you can set the `PACKER_TMP_DIR`. -This can be useful, for example, if you have your home directory permissions -set up to disallow access from the docker daemon. diff --git a/website/content/docs/post-processors/docker-import.mdx b/website/content/docs/post-processors/docker-import.mdx deleted file mode 100644 index 78ed0358e..000000000 --- a/website/content/docs/post-processors/docker-import.mdx +++ /dev/null @@ -1,217 +0,0 @@ ---- -description: | - The Packer Docker import post-processor takes an artifact from the docker - builder and imports it with Docker locally. This allows you to apply a - repository and tag to the image and lets you use the other Docker - post-processors such as docker-push to push the image to a registry. -page_title: Docker Import - Post-Processors -sidebar_title: Docker Import ---- - -# Docker Import Post-Processor - -Type: `docker-import` -Artifact BuilderId: `packer.post-processor.docker-import` - -The Packer Docker import post-processor takes an artifact from the [docker -builder](/docs/builders/docker) and imports it with Docker locally. This -allows you to apply a repository and tag to the image and lets you use the -other Docker post-processors such as -[docker-push](/docs/post-processors/docker-push) to push the image to a -registry. - -## Basic Example - - - - -```json -{ - "builders": [ - { - "type": "docker", - "image": "ubuntu:18.04", - "export_path": "party_parrot.tar" - } - ], - "post-processors": [ - { - "type": "docker-import", - "repository": "local/ubuntu", - "tag": "latest" - } - ] -} -``` - - - - -```hcl -source "docker" "example" { - image = "ubuntu:18.04" - export_path = "party_parrot.tar" -} - -build { - sources = [ - "source.docker.example" - ] - - post-processor "docker-import" { - repository = "local/ubuntu" - tag = "latest" - } -} -``` - - - - -## Configuration - -The configuration for this post-processor only requires a `repository`, a `tag` -is optional. - -### Required: - -- `repository` (string) - The repository of the imported image. - -### Optional: - -- `tag` (string) - The tag for the imported image. By default this is not - set. - -- `changes` (array of strings) - Dockerfile instructions to add to the - commit. Example of instructions are `CMD`, `ENTRYPOINT`, `ENV`, and - `EXPOSE`. Example: `[ "USER ubuntu", "WORKDIR /app", "EXPOSE 8080" ]` - -- `keep_input_artifact` (boolean) - if true, do not delete the source tar - after importing it to docker. Defaults to false. - -## Example - -An example is shown below, showing only the post-processor configuration: - - - - -```json -{ - "type": "docker-import", - "repository": "hashicorp/packer", - "tag": "0.7" -} -``` - - - - -```hcl -post-processor "docker-import" { - repository = "hashicorp/packer" - tag = "0.7" -} -``` - - - - -This example would take the image created by the Docker builder and import it -into the local Docker process with a name of `hashicorp/packer:0.7`. - -Following this, you can use the -[docker-push](/docs/post-processors/docker-push) post-processor to push it -to a registry, if you want. - -## Changing Metadata - -Below is an example using the changes argument of the post-processor. This -feature allows the tarball metadata to be changed when imported into the Docker -environment. It is derived from the `docker import --change` command line -[option to -Docker](https://docs.docker.com/engine/reference/commandline/import/). - -Example uses of all of the options, assuming one is building an NGINX image -from ubuntu as an simple example: - - - - -```json -{ - "type": "docker-import", - "repository": "local/centos6", - "tag": "latest", - "changes": [ - "USER www-data", - "WORKDIR /var/www", - "ENV HOSTNAME www.example.com", - "VOLUME /test1 /test2", - "EXPOSE 80 443", - "LABEL version=1.0", - "ONBUILD RUN date", - "CMD [\"nginx\", \"-g\", \"daemon off;\"]", - "ENTRYPOINT /var/www/start.sh" - ] -} -``` - - - - -```hcl -post-processor "docker-import" { - repository = "local/centos6" - tag = "latest" - changes = [ - "USER www-data", - "WORKDIR /var/www", - "ENV HOSTNAME www.example.com", - "VOLUME /test1 /test2", - "EXPOSE 80 443", - "LABEL version=1.0", - "ONBUILD RUN date", - "CMD [\"nginx\", \"-g\", \"daemon off;\"]", - "ENTRYPOINT /var/www/start.sh", - ] -} -``` - - - - -Allowed metadata fields that can be changed are: - -- CMD - - String, supports both array (escaped) and string form - - EX: `"CMD [\"nginx\", \"-g\", \"daemon off;\"]"` - - EX: `"CMD nginx -g daemon off;"` -- ENTRYPOINT - - String - - EX: `"ENTRYPOINT /var/www/start.sh"` -- ENV - - String, note there is no equal sign: - - EX: `"ENV HOSTNAME www.example.com"` not - `"ENV HOSTNAME=www.example.com"` -- EXPOSE - - String, space separated ports - - EX: `"EXPOSE 80 443"` -- LABEL - - String, space separated key=value pairs - - EX: `"LABEL version=1.0"` -- ONBUILD - - String - - EX: `"ONBUILD RUN date"` -- MAINTAINER - - String, deprecated in Docker version 1.13.0 - - EX: `"MAINTAINER NAME"` -- USER - - String - - EX: `"USER USERNAME"` -- VOLUME - - String - - EX: `"VOLUME FROM TO"` -- WORKDIR - - String - - EX: `"WORKDIR PATH"` diff --git a/website/content/docs/post-processors/docker-push.mdx b/website/content/docs/post-processors/docker-push.mdx deleted file mode 100644 index 43305f09c..000000000 --- a/website/content/docs/post-processors/docker-push.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -description: | - The Packer Docker push post-processor takes an artifact from the docker-import - post-processor and pushes it to a Docker registry. -page_title: Docker Push - Post-Processors -sidebar_title: Docker Push ---- - -# Docker Push Post-Processor - -Type: `docker-push` -Artifact BuilderId: `packer.post-processor.docker-import` - -The Packer Docker push post-processor takes an artifact from the -[docker-import](/docs/post-processors/docker-import) post-processor and -pushes it to a Docker registry. - -## Configuration - -This post-processor has only optional configuration: - -- `aws_access_key` (string) - The AWS access key used to communicate with - AWS. [Learn how to set - this.](/docs/builders/amazon#specifying-amazon-credentials) - -- `aws_secret_key` (string) - The AWS secret key used to communicate with - AWS. [Learn how to set - this.](/docs/builders/amazon#specifying-amazon-credentials) - -- `aws_token` (string) - The AWS access token to use. This is different from - the access key and secret key. If you're not sure what this is, then you - probably don't need it. This will also be read from the `AWS_SESSION_TOKEN` - environmental variable. - -- `aws_profile` (string) - The AWS shared credentials profile used to - communicate with AWS. [Learn how to set - this.](/docs/builders/amazon#specifying-amazon-credentials) - -- `ecr_login` (boolean) - Defaults to false. If true, the post-processor will - login in order to push the image to [Amazon EC2 Container Registry - (ECR)](https://aws.amazon.com/ecr/). The post-processor only logs in for - the duration of the push. If true `login_server` is required and `login`, - `login_username`, and `login_password` will be ignored. - -- `keep_input_artifact` (boolean) - if true, do not delete the docker image - after pushing it to the cloud. Defaults to true, but can be set to false if - you do not need to save your local copy of the docker container. - -- `login` (boolean) - Defaults to false. If true, the post-processor will - login prior to pushing. For log into ECR see `ecr_login`. - -- `login_username` (string) - The username to use to authenticate to login. - -- `login_password` (string) - The password to use to authenticate to login. - -- `login_server` (string) - The server address to login to. - --> **Note:** When using _Docker Hub_ or _Quay_ registry servers, `login` -must to be set to `true` and `login_username`, **and** `login_password` must to -be set to your registry credentials. When using Docker Hub, `login_server` can -be omitted. - --> **Note:** If you login using the credentials above, the post-processor -will automatically log you out afterwards (just the server specified). - -## Example - -For an example of using docker-push, see the section on using generated -artifacts from the [docker builder](/docs/builders/docker). diff --git a/website/content/docs/post-processors/docker-save.mdx b/website/content/docs/post-processors/docker-save.mdx deleted file mode 100644 index 3f4fbdfca..000000000 --- a/website/content/docs/post-processors/docker-save.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -description: > - The Packer Docker Save post-processor takes an artifact from the docker - builder - - that was committed and saves it to a file. This is similar to exporting the - - Docker image directly from the builder, except that it preserves the hierarchy - - of images and metadata. -page_title: Docker Save - Post-Processors -sidebar_title: Docker Save ---- - -# Docker Save Post-Processor - -Type: `docker-save` -Artifact BuilderId: `packer.post-processor.docker-save` - -The Packer Docker Save post-processor takes an artifact from the [docker -builder](/docs/builders/docker) that was committed and saves it to a file. -This is similar to exporting the Docker image directly from the builder, except -that it preserves the hierarchy of images and metadata. - -We understand the terminology can be a bit confusing, but we've adopted the -terminology from Docker, so if you're familiar with that, then you'll be -familiar with this and vice versa. - -## Configuration - -### Required - -The configuration for this post-processor only requires one option. - -- `path` (string) - The path to save the image. - -### Optional - -- `keep_input_artifact` (boolean) - if true, do not delete the docker - container, and only save the .tar created by docker save. Defaults to true. - -## Example - -An example is shown below, showing only the post-processor configuration: - - - - -```json -{ - "type": "docker-save", - "path": "foo.tar" -} -``` - - - - -```hcl -post-processors "docker-save" { - path = "foo.tar" -} -``` - - - diff --git a/website/content/docs/post-processors/docker-tag.mdx b/website/content/docs/post-processors/docker-tag.mdx deleted file mode 100644 index 1536e56f1..000000000 --- a/website/content/docs/post-processors/docker-tag.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -description: | - The Packer Docker Tag post-processor takes an artifact from the docker builder - that was committed and tags it into a repository. This allows you to use the - other Docker post-processors such as docker-push to push the image to a - registry. -page_title: Docker Tag - Post-Processors -sidebar_title: Docker Tag ---- - -# Docker Tag Post-Processor - -Type: `docker-tag` -Artifact BuilderId: `packer.post-processor.docker-tag` - -The Packer Docker Tag post-processor takes an artifact from the [docker -builder](/docs/builders/docker) that was committed and tags it into a -repository. This allows you to use the other Docker post-processors such as -[docker-push](/docs/post-processors/docker-push) to push the image to a -registry. - -This is very similar to the -[docker-import](/docs/post-processors/docker-import) post-processor except -that this works with committed resources, rather than exported. - -## Configuration - -The configuration for this post-processor requires `repository`, all other -settings are optional. - -- `repository` (string) - The repository of the image. - -- `tags` (array of strings) - A list of tags for the image. By default this is - not set. Valid examples include: `"tags": "mytag"` or - `"tags": ["mytag-1", "mytag-2"]` - -- `force` (boolean) - If true, this post-processor forcibly tag the image - even if tag name is collided. Default to `false`. But it will be ignored if - Docker >= 1.12.0 was detected, since the `force` option was removed - after 1.12.0. - [reference](https://docs.docker.com/engine/deprecated/#/f-flag-on-docker-tag) - -- `keep_input_artifact` (boolean) - Unlike most other post-processors, the - keep_input_artifact option will have no effect for the docker-tag - post-processor. We will always retain the input artifact for docker-tag, - since deleting the image we just tagged is not a behavior anyone should ever - expect. `keep_input_artifact will` therefore always be evaluated as true, - regardless of the value you enter into this field. - -## Example - -An example is shown below, showing only the post-processor configuration: - - - - -```json -{ - "type": "docker-tag", - "repository": "hashicorp/packer", - "tag": "0.7,anothertag" -} -``` - - - - -```hcl -post-processors "docker-tag" { - repository = "hashicorp/packer" - tag = "0.7,anothertag" -} -``` - - - - -This example would take the image created by the Docker builder and tag it into -the local Docker process with a name of `hashicorp/packer:0.7`. - -Following this, you can use the -[docker-push](/docs/post-processors/docker-push) post-processor to push it -to a registry, if you want. diff --git a/website/content/partials/builder/docker/AwsAccessConfig-not-required.mdx b/website/content/partials/builder/docker/AwsAccessConfig-not-required.mdx deleted file mode 100644 index db9a8bfa3..000000000 --- a/website/content/partials/builder/docker/AwsAccessConfig-not-required.mdx +++ /dev/null @@ -1,18 +0,0 @@ - - -- `aws_access_key` (string) - The AWS access key used to communicate with - AWS. Learn how to set - this. - -- `aws_secret_key` (string) - The AWS secret key used to communicate with - AWS. Learn how to set - this. - -- `aws_token` (string) - The AWS access token to use. This is different from - the access key and secret key. If you're not sure what this is, then you - probably don't need it. This will also be read from the AWS_SESSION_TOKEN - environmental variable. - -- `aws_profile` (string) - The AWS shared credentials profile used to - communicate with AWS. Learn how to set - this. diff --git a/website/content/partials/builder/docker/Config-not-required.mdx b/website/content/partials/builder/docker/Config-not-required.mdx deleted file mode 100644 index e56587dc5..000000000 --- a/website/content/partials/builder/docker/Config-not-required.mdx +++ /dev/null @@ -1,74 +0,0 @@ - - -- `author` (string) - Set the author (e-mail) of a commit. - -- `changes` ([]string) - Dockerfile instructions to add to the commit. Example of instructions - are CMD, ENTRYPOINT, ENV, and EXPOSE. Example: [ "USER ubuntu", "WORKDIR - /app", "EXPOSE 8080" ] - -- `container_dir` (string) - The directory inside container to mount temp directory from host server - for work [file provisioner](/docs/provisioners/file). This defaults - to c:/packer-files on windows and /packer-files on other systems. - -- `device` ([]string) - An array of devices which will be accessible in container when it's run - without `--privileged` flag. - -- `cap_add` ([]string) - An array of additional [Linux - capabilities](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) - to grant to the container. - -- `cap_drop` ([]string) - An array of [Linux - capabilities](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) - to drop from the container. - -- `exec_user` (string) - Username (UID) to run remote commands with. You can also set the group - name/ID if you want: (UID or UID:GID). You may need this if you get - permission errors trying to run the shell or other provisioners. - -- `privileged` (bool) - If true, run the docker container with the `--privileged` flag. This - defaults to false if not set. - -- `pull` (bool) - If true, the configured image will be pulled using `docker pull` prior - to use. Otherwise, it is assumed the image already exists and can be - used. This defaults to true if not set. - -- `run_command` ([]string) - An array of arguments to pass to docker run in order to run the - container. By default this is set to `["-d", "-i", "-t", - "--entrypoint=/bin/sh", "--", "{{.Image}}"]` if you are using a linux - container, and `["-d", "-i", "-t", "--entrypoint=powershell", "--", - "{{.Image}}"]` if you are running a windows container. `{{.Image}}` is a - template variable that corresponds to the image template option. Passing - the entrypoint option this way will make it the default entrypoint of - the resulting image, so running docker run -it --rm will start the - docker image from the /bin/sh shell interpreter; you could run a script - or another shell by running docker run -it --rm -c /bin/bash. If your - docker image embeds a binary intended to be run often, you should - consider changing the default entrypoint to point to it. - -- `tmpfs` ([]string) - An array of additional tmpfs volumes to mount into this container. - -- `volumes` (map[string]string) - A mapping of additional volumes to mount into this container. The key of - the object is the host path, the value is the container path. - -- `fix_upload_owner` (bool) - If true, files uploaded to the container will be owned by the user the - container is running as. If false, the owner will depend on the version - of docker installed in the system. Defaults to true. - -- `windows_container` (bool) - If "true", tells Packer that you are building a Windows container - running on a windows host. This is necessary for building Windows - containers, because our normal docker bindings do not work for them. - -- `login` (bool) - This is used to login to dockerhub to pull a private base container. For - pushing to dockerhub, see the docker post-processors - -- `login_password` (string) - The password to use to authenticate to login. - -- `login_server` (string) - The server address to login to. - -- `login_username` (string) - The username to use to authenticate to login. - -- `ecr_login` (bool) - Defaults to false. If true, the builder will login in order to pull the - image from Amazon EC2 Container Registry (ECR). The builder only logs in - for the duration of the pull. If true login_server is required and - login, login_username, and login_password will be ignored. For more - information see the section on ECR. diff --git a/website/content/partials/builder/docker/Config-required.mdx b/website/content/partials/builder/docker/Config-required.mdx deleted file mode 100644 index 0ce9b639a..000000000 --- a/website/content/partials/builder/docker/Config-required.mdx +++ /dev/null @@ -1,14 +0,0 @@ - - -- `commit` (bool) - If true, the container will be committed to an image rather than exported. - -- `discard` (bool) - Throw away the container when the build is complete. This is useful for - the [artifice - post-processor](/docs/post-processors/artifice). - -- `export_path` (string) - The path where the final container will be exported as a tar file. - -- `image` (string) - The base image for the Docker container that will be started. This image - will be pulled from the Docker registry if it doesn't already exist. - -- `message` (string) - Set a message for the commit. From 3058c437a360a905a8240b407a19eee7d5432ef9 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 26 Feb 2021 17:34:30 -0500 Subject: [PATCH 07/10] Register remote plugins docs with https://packer.io --- website/data/docs-nav-data.json | 20 -------------------- website/data/docs-remote-plugins.json | 8 +++++++- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/website/data/docs-nav-data.json b/website/data/docs-nav-data.json index d416fc8f1..1f93cc5a8 100644 --- a/website/data/docs-nav-data.json +++ b/website/data/docs-nav-data.json @@ -725,10 +725,6 @@ "title": "DigitalOcean", "path": "builders/digitalocean" }, - { - "title": "Docker", - "path": "builders/docker" - }, { "title": "File", "path": "builders/file" @@ -1096,22 +1092,6 @@ "title": "DigitalOcean Import", "path": "post-processors/digitalocean-import" }, - { - "title": "Docker Import", - "path": "post-processors/docker-import" - }, - { - "title": "Docker Push", - "path": "post-processors/docker-push" - }, - { - "title": "Docker Save", - "path": "post-processors/docker-save" - }, - { - "title": "Docker Tag", - "path": "post-processors/docker-tag" - }, { "title": "Exoscale Import", "path": "post-processors/exoscale-import" diff --git a/website/data/docs-remote-plugins.json b/website/data/docs-remote-plugins.json index fe51488c7..8c247cfab 100644 --- a/website/data/docs-remote-plugins.json +++ b/website/data/docs-remote-plugins.json @@ -1 +1,7 @@ -[] +[ + { + "title": "Docker", + "path": "docker", + "repo": "hashicorp/packer-plugin-docker" + } +] From a101d465890ac3955c81baacea9538351451e888 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Wed, 3 Mar 2021 10:21:35 -0500 Subject: [PATCH 08/10] update modules.txt --- vendor/modules.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/modules.txt b/vendor/modules.txt index 4065c44a5..2150e74c8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -414,6 +414,7 @@ github.com/hashicorp/hcl/v2/hclsyntax github.com/hashicorp/hcl/v2/hclwrite github.com/hashicorp/hcl/v2/json # github.com/hashicorp/packer-plugin-docker v0.0.2 +## explicit github.com/hashicorp/packer-plugin-docker/builder/docker github.com/hashicorp/packer-plugin-docker/post-processor/docker-import github.com/hashicorp/packer-plugin-docker/post-processor/docker-push From 79481ed7ecb085a66600e06fd75f9cd3b800bd48 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 5 Mar 2021 15:44:04 -0500 Subject: [PATCH 09/10] Add vendored components map as opposed to removing code generation for command/plugin.go --- command/plugin.go | 19 +++---------- command/vendored_plugins.go | 55 +++++++++++++++++++++++++++++++++++++ go.mod | 1 - go.sum | 2 -- main.go | 1 + vendor/modules.txt | 2 -- 6 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 command/vendored_plugins.go diff --git a/command/plugin.go b/command/plugin.go index cb378dec3..2e039ed6c 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -1,3 +1,7 @@ +// +// This file is automatically generated by scripts/generate-plugins.go -- Do not edit! +// + package command import ( @@ -9,16 +13,6 @@ import ( packersdk "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/plugin" - // Previously core-bundled components, split into their own plugins but - // still vendored with Packer for now. Importing as library instead of - // forcing use of packer init, until packer v1.8.0 - dockerbuilder "github.com/hashicorp/packer-plugin-docker/builder/docker" - dockerimportpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" - dockerpushpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-push" - dockersavepostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-save" - dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" - - // These components are still built into the packer core repo alicloudecsbuilder "github.com/hashicorp/packer/builder/alicloud/ecs" amazonchrootbuilder "github.com/hashicorp/packer/builder/amazon/chroot" amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs" @@ -126,7 +120,6 @@ var Builders = map[string]packersdk.Builder{ "azure-dtl": new(azuredtlbuilder.Builder), "cloudstack": new(cloudstackbuilder.Builder), "digitalocean": new(digitaloceanbuilder.Builder), - "docker": new(dockerbuilder.Builder), "file": new(filebuilder.Builder), "googlecompute": new(googlecomputebuilder.Builder), "hcloud": new(hcloudbuilder.Builder), @@ -197,10 +190,6 @@ var PostProcessors = map[string]packersdk.PostProcessor{ "checksum": new(checksumpostprocessor.PostProcessor), "compress": new(compresspostprocessor.PostProcessor), "digitalocean-import": new(digitaloceanimportpostprocessor.PostProcessor), - "docker-import": new(dockerimportpostprocessor.PostProcessor), - "docker-push": new(dockerpushpostprocessor.PostProcessor), - "docker-save": new(dockersavepostprocessor.PostProcessor), - "docker-tag": new(dockertagpostprocessor.PostProcessor), "exoscale-import": new(exoscaleimportpostprocessor.PostProcessor), "googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor), "googlecompute-import": new(googlecomputeimportpostprocessor.PostProcessor), diff --git a/command/vendored_plugins.go b/command/vendored_plugins.go new file mode 100644 index 000000000..57427ba81 --- /dev/null +++ b/command/vendored_plugins.go @@ -0,0 +1,55 @@ +package command + +import ( + packersdk "github.com/hashicorp/packer-plugin-sdk/packer" + + // Previously core-bundled components, split into their own plugins but + // still vendored with Packer for now. Importing as library instead of + // forcing use of packer init, until packer v1.8.0 + dockerbuilder "github.com/hashicorp/packer-plugin-docker/builder/docker" + dockerimportpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-import" + dockerpushpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-push" + dockersavepostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-save" + dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" +) + +// VendoredBuilders are builder components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredBuilders = map[string]packersdk.Builder{ + "docker": new(dockerbuilder.Builder), +} + +// VendoredProvisioners are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredProvisioners = map[string]packersdk.Provisioner{} + +// VendoredPostProcessors are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +var VendoredPostProcessors = map[string]packersdk.PostProcessor{ + "docker-import": new(dockerimportpostprocessor.PostProcessor), + "docker-push": new(dockerpushpostprocessor.PostProcessor), + "docker-save": new(dockersavepostprocessor.PostProcessor), + "docker-tag": new(dockertagpostprocessor.PostProcessor), +} + +// Upon init lets load up any plugins that were vendored manually into the default +// set of plugins. +func init() { + for k, v := range VendoredBuilders { + if _, ok := Builders[k]; ok { + continue + } + Builders[k] = v + } + + for k, v := range VendoredProvisioners { + if _, ok := Provisioners[k]; ok { + continue + } + Provisioners[k] = v + } + + for k, v := range VendoredPostProcessors { + if _, ok := PostProcessors[k]; ok { + continue + } + PostProcessors[k] = v + } +} diff --git a/go.mod b/go.mod index 17e938235..858ad2f70 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,6 @@ require ( github.com/mitchellh/cli v1.1.0 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed - github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/mapstructure v1.4.0 github.com/mitchellh/panicwrap v1.0.0 github.com/mitchellh/prefixedio v0.0.0-20151214002211-6e6954073784 diff --git a/go.sum b/go.sum index fecf30140..ca566554a 100644 --- a/go.sum +++ b/go.sum @@ -570,11 +570,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUt github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.1+incompatible h1:2LwXWdbjXwyDgq26Yy/OT4xozlpmssQfy/rtfhWb0bY= github.com/shirou/gopsutil v3.21.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= diff --git a/main.go b/main.go index f358c2f05..f7806b0bc 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,6 @@ // This is the main package for the `packer` application. +//go:generate go run ./scripts/generate-plugins.go package main import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 2150e74c8..1f1316bf4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -559,8 +559,6 @@ github.com/mitchellh/go-testing-interface github.com/mitchellh/go-vnc # github.com/mitchellh/go-wordwrap v1.0.0 github.com/mitchellh/go-wordwrap -# github.com/mitchellh/gox v1.0.1 -## explicit # github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/iochan # github.com/mitchellh/mapstructure v1.4.0 From 71b815a5fd6d319647e238b32d9d3a2fd9dee3ee Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 5 Mar 2021 16:07:32 -0800 Subject: [PATCH 10/10] reword commits --- command/vendored_plugins.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/command/vendored_plugins.go b/command/vendored_plugins.go index 57427ba81..19762365a 100644 --- a/command/vendored_plugins.go +++ b/command/vendored_plugins.go @@ -13,15 +13,18 @@ import ( dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag" ) -// VendoredBuilders are builder components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +// VendoredBuilders are builder components that were once bundled with the +// Packer core, but are now being imported from their counterpart plugin repos var VendoredBuilders = map[string]packersdk.Builder{ "docker": new(dockerbuilder.Builder), } -// VendoredProvisioners are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +// VendoredProvisioners are provisioner components that were once bundled with the +// Packer core, but are now being imported from their counterpart plugin repos var VendoredProvisioners = map[string]packersdk.Provisioner{} -// VendoredPostProcessors are components that were once bundle with Packer core, but are now being shim with there multi-component counterparts. +// VendoredPostProcessors are post-processor components that were once bundled with the +// Packer core, but are now being imported from their counterpart plugin repos var VendoredPostProcessors = map[string]packersdk.PostProcessor{ "docker-import": new(dockerimportpostprocessor.PostProcessor), "docker-push": new(dockerpushpostprocessor.PostProcessor), @@ -29,8 +32,8 @@ var VendoredPostProcessors = map[string]packersdk.PostProcessor{ "docker-tag": new(dockertagpostprocessor.PostProcessor), } -// Upon init lets load up any plugins that were vendored manually into the default -// set of plugins. +// Upon init lets us load up any plugins that were vendored manually into the +// default set of plugins. func init() { for k, v := range VendoredBuilders { if _, ok := Builders[k]; ok {