-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add registry image pkg #76
Conversation
6b55f55
to
d973e37
Compare
// 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason you didn't go to map[string]string
from the beginning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flexibility really. I thought maybe it would be useful to others if I didn't define the concrete type.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 this looks great!
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.