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

Ensure that an unchanged image is not in update result #144

Merged
merged 3 commits into from Apr 6, 2021

Conversation

squaremo
Copy link
Member

@squaremo squaremo commented Apr 5, 2021

The first commit adapts the update->result test so that it checks an additional case: that a field with an update marker that does correspond to a policy, but doesn't get changed, is not included in the results.

The rest of the PR reimplements the setter filter, so that it will record exactly what changes are made. I have adapted it from kyaml, and stripped out a lot of generic code that is unnecessary here.

Fixes #133.

With reference to

    #133

this commit adapts the update->result test so that it checks an
additional case: that a field with an update marker that _does_
correspond to a policy, but _doesn't_ get changed, is not included in
the results.

This test fails at present, because the method for determining the
result is to count which setters are referenced, rather than which
fields were changed.

Signed-off-by: Michael Bridgen <michael@weave.works>
The update procedure is obliged to return a Result struct with all the
objects that were changed, for filling in the commit template. At
present, the result is collated by running each setter on each object
and seeing if the setter is used. This uses the `Set` from kyaml, with
a small amount of glue.

It doesn't quite work, however, because a setter may be used for a
field without changing the value. The result gets an entry for each
policy _mentioned_, whether or not it had a new value. There is no way
to see whether a setter actually changed a field from the outside,
other than by comparing a copy of the object before using the setter
with the object after (which yaml.v3 does not make easy).

A better approach is to get the setter to record whether it changed
anything, since it is there doing the changing. This means
reimplementing kyaml's `Set`. I have stripped it down to the parts
needed for image updates -- so e.g., only field values are examined.

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit removes an unnecessary indirection through a closure.

Signed-off-by: Michael Bridgen <michael@weave.works>
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @squaremo

@squaremo squaremo merged commit 2a48f6d into main Apr 6, 2021
@squaremo squaremo deleted the images-in-templates branch April 6, 2021 11:18
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.

commit-template also include non-updated images
2 participants