Merged
Conversation
6b55f55 to
d973e37
Compare
nywilken
commented
Sep 2, 2021
| // FromMappedData will make its best attempt to convert the input map into map[interface{}]interface{} before | ||
| // calling f(k,v). The func f is responsible for type asserting the expected type for the key and value before | ||
| // trying to create an Image from it. | ||
| func FromMappedData(mappedData interface{}, f func(key, value interface{}) (*Image, error)) ([]*Image, error) { |
Contributor
Author
There was a problem hiding this comment.
As an alternative to this implementation which would allow for a map of any type. I'm considering just supporting a mappedData input of map[string]string, as this seems to be the std. map being used across most plugins that return multi-region artifacts.
It also removes the need for the consumer to do type assertions in the iteration function, which seems a bit complex.
There was a problem hiding this comment.
Any specific reason you didn't go to map[string]string from the beginning?
Contributor
Author
There was a problem hiding this comment.
Flexibility really. I thought maybe it would be useful to others if I didn't define the concrete type.
added 5 commits
September 2, 2021 14:17
In order to assist in the creation of HCP Packer Registry Image metadata for various Artifacts. A new package is being added to assist in the creation of a registryimage.Image from an existing Artifact. The FromArtifact function provides a simple approach of extracting the required bits from an Artifact needed by the HCP Packer registry. The default values, which can be overwritten by the use of a ArtifactOverrideFunc , were selected to provide some standard defaults that are set to be available for most plugins were bundled with Packer prior to v1.7.0. When those defaults are not viable the package provider override funcs that can be used by the consumer for setting the appropriate values. For those plugins that generate more than one registryimage.Image per Artifact one can construct a []registryimage.Image and return that information as the response of Packer core calling artifact.State(registryimage.ArtifactStateURI).
* Move pkg around to remove a bit of the stutter. * Add some example tests for a few of the functions provided by the package.
ae1bb80 to
f86c7cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to assist in the creation of HCP Packer Registry Image metadata
for various Artifacts. A new package is being added to assist in the
creation of a registryimage.Image from an existing Artifact.
The FromArtifact function provides a simple approach of extracting the
required bits from an Artifact needed by the HCP Packer registry. The
default values, which can be overwritten by the use of a
ArtifactOverrideFunc , were selected to provide some standard defaults
that are set to be available for most plugins were bundled
with Packer prior to v1.7.0. When those defaults are not viable the
package provider override funcs that can be used by the consumer for
setting the appropriate values.
For those plugins that generate more than one registryimage.Image per
Artifact one can construct a []registryimage.Image and return that
information as the response of Packer core calling
artifact.State(registryimage.ArtifactStateURI).
When reviewing, I recommend checking out the godoc to see the examples tests in action.