-
Notifications
You must be signed in to change notification settings - Fork 13
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
Namespace created by Filter(...).Apply() can not be delete automatic #75
Comments
Forgive me, but I'm having a little trouble understanding the problem. The deep-copy is definitely intentional, in order to maintain the manifest's immutable semantics. Would it be possible for you to create a failing unit test demonstrating the problem? |
@jcrossley3
|
but we add |
Ok, I see what you're saying now. Chaining the |
@jcrossley3 Line 27 in 3577f8e
|
Well, we could do something like the following, but it would break some tests, since we currently allow the modified filter.go
@@ -24,8 +24,8 @@ func (m Manifest) Filter(preds ...Predicate) Manifest {
result := m
result.resources = []unstructured.Unstructured{}
pred := All(preds...)
- for _, spec := range m.Resources() {
- if !pred(&spec) {
+ for _, spec := range m.resources {
+ if !pred(spec.DeepCopy()) {
continue
}
result.resources = append(result.resources, spec) I'm not saying we shouldn't do it, but it would be a fairly significant, breaking change. |
The more I think about it, the more I like it. It's probably not great that a |
@jcrossley3 |
Yeah, and |
Fixes #75 The ability to chain `Apply` calls to the result of `Filter` made it necessary to return the actual manifest resources instead of deep copies. So now the Predicates are passed deep copies, making it impossible to alter resources by filtering. Only the Transform method can alter resources, and its multi-value return prevents the chaining of `Apply` calls.
Fixes #75 The ability to chain `Apply` calls to the result of `Filter` made it necessary to return the actual manifest resources instead of deep copies. So now the Predicates are passed deep copies, making it impossible to alter resources by filtering. Only the Transform method can alter resources, and its multi-value return prevents the chaining of `Apply` calls.
@vincent-pli if you could |
@jcrossley3 |
I found
Namespace
created byFilter(...).Apply()
can not be delete automatic.Base on the implements, when delete cluster level resource, we will check if it has the Annotation:
manifestival: new
,The resource is come from
m.resources
whenDelete()
.When adopt
Filter(...).Apply()
, theFilter()
will make new instance deep copy fromm.resources
, that's means the Annotation mark on the new instance rather thanm.resources
.Check here:
manifestival/filter.go
Line 27 in 3577f8e
I have no idea if the deep-copy is on purpose or not, but I found we has UT test, so it must be on purpose, can anyone clarify it, thanks.
The text was updated successfully, but these errors were encountered: