Add pre-validate step to check if the image name has already been used#106
Add pre-validate step to check if the image name has already been used#106shengxpa wants to merge 1 commit intohashicorp:mainfrom
Conversation
|
Anyone can help have a review? |
|
@nywilken Could you help have a review? |
nywilken
left a comment
There was a problem hiding this comment.
Thanks for opening up this change. Our focus has been on a few plugin changes so I do apologize for the delayed review.
I took a quick look at the OpenStack glance image creation API to see why this wasn't implemented previously. I found that the API allows for this and OpenStack itself does not consider it an issue because the ids are unique. This leaves me to think that adding this change, while logical, may break expectation for users.
In addition to the prevalidation step the use of -force generally implies to force a build when artifacts from a previous build prevent a build from running. This is not really the case here seeing as OpenStack does allow images to have the same name.
Have you considered using a timestamp when generating the image name?
The use of the timestamp function with Packer templates is a common practice for avoiding duplicate image names. It is a little tricky seeing as OpenStack does allow it. If you think this feature would benefit users over setting a timestamp then I would suggest adding an optional attribute to change the default behavior of the glance API such as
prevent_duplicate_image_name (boolean) - Set to true to check that no existing image has the same image name. If the image name is already in use the builder will exit with an error. Defaults to false
Please let me know what you think?
|
Closing since there have been no updates to the issue. If you believe this is still an issue please or should be a feature please open an issue first so that other users can vote on and provide insight into the usage. Thanks! |
For the packer image build on the Openstack platform, there is a lack of a pre-validate step for the image name like in the packer-plugin-amazon plugin, resulting in the name of the built image often being repeated like this:

It always causes some confusion when using image.
In this PR, a pre-validate step has been added to check if the image name has already been used. If the image name has already been used, an error will be output. "packer_force" parameter can be used to skip the pre-validate step when it is set to 'true' like the logic of packer-plugin-amazon plugin.