Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Deleting floppy images on teardown #159

Merged
merged 5 commits into from
Oct 18, 2018
Merged

Deleting floppy images on teardown #159

merged 5 commits into from
Oct 18, 2018

Conversation

pragmaspark
Copy link
Contributor

@pragmaspark pragmaspark commented Oct 11, 2018

fixes #137

state.Put("error", err)
}

deletePath := fmt.Sprintf("%v/packer-tmp-created-floppy.flp", vmDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the filename from the state instead of hardcoding it?
https://github.com/jetbrains-infra/packer-builder-vsphere/blob/master/iso/step_remove_floppy.go#L33

Copy link
Contributor Author

@pragmaspark pragmaspark Oct 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Because we could be faced with a situation: when the file uploaded, but the state not have information about uploadPath.

uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.flp", vmDir)
if err := ds.UploadFile(floppyPath.(string), uploadPath); err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
state.Put("uploaded_floppy_path", uploadPath)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then that's not our business. If govmomi returns an error during uploading, it should handle cleanup by itself.

@pragmaspark pragmaspark changed the title add solution for #137 Deleting floppy images on teardown Oct 15, 2018
ui := state.Get("ui").(packer.Ui)

std := state.Get("driver")
if std == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this check

state.Put("error", err)
}

if err := ds.Delete(UploadedFloppyPath.(string)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two styles

ds, err := d.FindDatastore(s.Datastore, s.Host)
if err != nil {

and

if err := ds.Delete(UploadedFloppyPath.(string)); err != nil {

we mostly use the 1st.

@pragmaspark pragmaspark merged commit af6db0f into master Oct 18, 2018
@pragmaspark pragmaspark deleted the new_features branch October 19, 2018 17:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Floppy images not deleted on teardown, VM folders remain
2 participants