From 2b57f47bb8758f3e00ba31105449b34a72b554fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 16:27:27 +0000 Subject: [PATCH] Bump github.com/hashicorp/packer-plugin-sdk from 0.2.6 to 0.2.7 Bumps [github.com/hashicorp/packer-plugin-sdk](https://github.com/hashicorp/packer-plugin-sdk) from 0.2.6 to 0.2.7. - [Release notes](https://github.com/hashicorp/packer-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/packer-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/packer-plugin-sdk/compare/v0.2.6...v0.2.7) --- updated-dependencies: - dependency-name: github.com/hashicorp/packer-plugin-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../multistep/commonsteps/floppy_config.go | 19 +++++++- .../commonsteps/step_create_floppy.go | 48 ++++++++++++++++++- .../multistep/commonsteps/step_download.go | 2 + vendor/modules.txt | 2 +- 6 files changed, 71 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 750502d4..b3863a85 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/hashicorp/hcl/v2 v2.10.1 - github.com/hashicorp/packer-plugin-sdk v0.2.6 + github.com/hashicorp/packer-plugin-sdk v0.2.7 github.com/vultr/govultr/v2 v2.9.0 github.com/zclconf/go-cty v1.9.1 golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 diff --git a/go.sum b/go.sum index ac1c5a83..d85d8bf7 100644 --- a/go.sum +++ b/go.sum @@ -349,8 +349,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/memberlist v0.2.2 h1:5+RffWKwqJ71YPu9mWsF7ZOscZmwfasdA8kbdC7AO2g= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/packer-plugin-sdk v0.2.6 h1:/v6NODvwDC5XKbF/A6/WQrRmUoPLy70Uu+IGSSklfOc= -github.com/hashicorp/packer-plugin-sdk v0.2.6/go.mod h1:ii9ub5UNAp30RGod3i3W8qj7wA+H7kpURnD+Jt7oDkQ= +github.com/hashicorp/packer-plugin-sdk v0.2.7 h1:L7mfLg+gGnqN3z8vEG4YojVsbhYJrNcimvOSIuCN6qA= +github.com/hashicorp/packer-plugin-sdk v0.2.7/go.mod h1:ii9ub5UNAp30RGod3i3W8qj7wA+H7kpURnD+Jt7oDkQ= github.com/hashicorp/serf v0.9.5 h1:EBWvyu9tcRszt3Bxp3KNssBMP1KuHWyO51lz9+786iM= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE= diff --git a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/floppy_config.go b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/floppy_config.go index 27ba6d68..2eb81de6 100644 --- a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/floppy_config.go +++ b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/floppy_config.go @@ -33,7 +33,24 @@ type FloppyConfig struct { // characters (\\*, ?, and \[\]) are allowed. The maximum summary size of // all files in the listed directories are the same as in `floppy_files`. FloppyDirectories []string `mapstructure:"floppy_dirs"` - FloppyLabel string `mapstructure:"floppy_label"` + // Key/Values to add to the floppy disk. The keys represent the paths, and + // the values contents. It can be used alongside `floppy_files` or + // `floppy_dirs`, which is useful to add large files without loading them + // into memory. If any paths are specified by both, the contents in + // `floppy_content` will take precedence. + // + // Usage example (HCL): + // + // ```hcl + // floppy_files = ["vendor-data"] + // floppy_content = { + // "meta-data" = jsonencode(local.instance_data) + // "user-data" = templatefile("user-data", { packages = ["nginx"] }) + // } + // floppy_label = "cidata" + // ``` + FloppyContent map[string]string `mapstructure:"floppy_content"` + FloppyLabel string `mapstructure:"floppy_label"` } func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error { diff --git a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go index 8c4b0e56..8097aaf7 100644 --- a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go +++ b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_create_floppy.go @@ -21,6 +21,7 @@ import ( type StepCreateFloppy struct { Files []string Directories []string + Content map[string]string Label string floppyPath string @@ -29,7 +30,7 @@ type StepCreateFloppy struct { } func (s *StepCreateFloppy) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - if len(s.Files) == 0 && len(s.Directories) == 0 { + if len(s.Files) == 0 && len(s.Directories) == 0 && len(s.Content) == 0 { log.Println("No floppy files specified. Floppy disk will not be made.") return multistep.ActionContinue } @@ -215,6 +216,18 @@ func (s *StepCreateFloppy) Run(ctx context.Context, state multistep.StateBag) mu } ui.Message("Done copying paths from floppy_dirs") + // Collect files from floppy_content + ui.Message("Copying files from floppy_content") + for path, content := range s.Content { + err = s.AddContent(cache, path, content) + if err != nil { + state.Put("error", + fmt.Errorf("Error creating file for floppy: %s", err)) + return multistep.ActionHalt + } + } + ui.Message("Done copying files from floppy_content") + // Set the path to the floppy so it can be used later state.Put("floppy_path", s.floppyPath) @@ -305,6 +318,39 @@ func (s *StepCreateFloppy) Add(dircache directoryCache, src string) error { return filepath.Walk(src, visit) } +func (s *StepCreateFloppy) AddContent(dircache directoryCache, path, content string) error { + basedirectory := filepath.Join(path, "..") + directory, filename := filepath.Split(filepath.ToSlash(path)) + + base, err := removeBase(basedirectory, filepath.FromSlash(directory)) + if err != nil { + return err + } + + wd, err := dircache(filepath.ToSlash(base)) + if err != nil { + return err + } + + entry, err := wd.AddFile(filename) + if err != nil { + return err + } + + fatFile, err := entry.File() + if err != nil { + return err + } + + _, err = io.WriteString(fatFile, content) + if err != nil { + return fmt.Errorf("Error writing file %s on floppy: %s", path, err) + } + s.FilesAdded[path] = true + + return nil +} + func (s *StepCreateFloppy) Cleanup(multistep.StateBag) { if s.floppyPath != "" { log.Printf("Deleting floppy disk: %s", s.floppyPath) diff --git a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_download.go b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_download.go index f1196855..ae802a9c 100644 --- a/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_download.go +++ b/vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_download.go @@ -96,6 +96,8 @@ func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multis } if err == nil { state.Put(s.ResultKey, dst) + // Track the URL you actually used for the download. + state.Put("SourceImageURL", source) return multistep.ActionContinue } // may be another url will work diff --git a/vendor/modules.txt b/vendor/modules.txt index bccae1c1..f50f43b0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -203,7 +203,7 @@ github.com/hashicorp/hcl/json/token github.com/hashicorp/hcl/v2 github.com/hashicorp/hcl/v2/ext/customdecode github.com/hashicorp/hcl/v2/hcldec -# github.com/hashicorp/packer-plugin-sdk v0.2.6 +# github.com/hashicorp/packer-plugin-sdk v0.2.7 ## explicit; go 1.17 github.com/hashicorp/packer-plugin-sdk/acctest github.com/hashicorp/packer-plugin-sdk/common