Skip to content
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

Adds support for discarding an item before restoring it #9

Merged
merged 1 commit into from
Mar 29, 2019

Conversation

sseago
Copy link

@sseago sseago commented Mar 29, 2019

Within a RestoreItemAction, if the Execute function sets abandonItem
to true on the UpdatedItem before running it, then restoreResource
skips any remaining actions on this item, skips restoring this item
to the cluster, and continues on to the next item.

In the plugin Execute function, the following line would trigger
skipping, assuming input.Item is the object passed into
NewRestoreItemActionExecuteOutput on return:

unstructured.SetNestedField(input.Item.UnstructuredContent(),
                            true,
                            "abandonItem")

Within a RestoreItemAction, if the Execute function sets abandonItem
to true on the UpdatedItem before running it, then restoreResource
skips any remaining actions on this item, skips restoring this item
to the cluster, and continues on to the next item.

In the plugin Execute function, the following line would trigger
skipping, assuming input.Item is the object passed into
NewRestoreItemActionExecuteOutput on return:

	unstructured.SetNestedField(input.Item.UnstructuredContent(),
	                            true,
   	                            "abandonItem")
@@ -700,6 +700,7 @@ func (ctx *context) restoreResource(resource, namespace, resourcePath string) (a
applicableActions = append(applicableActions, action)
}

fileLoop:
Copy link
Member

Choose a reason for hiding this comment

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

Is this supposed to be here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. I have to break out of two levels of loop, and using a named label is the only way of doing it in go. The only other way of doing it would be a significant refactoring of this (long) function.

@dymurray dymurray merged commit 17ce13f into openshift:fusor-dev Mar 29, 2019
@sseago
Copy link
Author

sseago commented Mar 29, 2019

I think I'm going to submit an cleaner implementation that adds a new field to the output struct rather than embedding a coded message in the item itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants