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

fix: HOOKS section should also be parsed when HELM_DIFF_USE_UPGRADE_DRY_RUN=true #364

Merged
merged 5 commits into from
Feb 13, 2022

Conversation

carlosrmendes
Copy link
Contributor

@carlosrmendes carlosrmendes commented Jan 25, 2022

resolves #363

cmd/helm3.go Outdated
@@ -175,14 +175,25 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
return s
}

i := bytes.Index(s, []byte("MANIFEST:"))
i := bytes.Index(s, []byte("HOOKS:"))
s = s[i:]
i = bytes.Index(s, []byte("---"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@carlosrmendes Hey! Sorry for the delay. I was reviewing this change carefully and this seems not working as expected when your chart doesn't have hooks at all.

See this dry-run output from a clean install of stable/envoy chart:

NAME: my1
LAST DEPLOYED: Sun Feb 13 01:04:52 2022
NAMESPACE: default
STATUS: pending-upgrade
REVISION: 2
TEST SUITE: None
HOOKS:
MANIFEST:
---
# Source: envoy/templates/poddisruptionbudget.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:

This bytes.Index call at 180 would return the index of --- in

MANIFEST:
---

which isn't correct, and perhaps that's why you had to add complex nested-if statements in L183-L191, right?

Probably a better way for us would be to treat --- for HOOKS section as optional, instead of that for MANIFEST.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also noticed that we had to add support for --no-hooks (and --include-tests), and it ended up with 3d4ced1. I hope you like it 😄

Copy link
Collaborator

@mumoshu mumoshu left a comment

Choose a reason for hiding this comment

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

This seems good to go!

Although I added some changes, the whole work for this wasn't possible with your contribution! 99% credit goes to you- Thank you so much for your contribution @carlosrmendes ☺️

@mumoshu mumoshu changed the title HOOKS section should also be parsed when HELM_DIFF_USE_UPGRADE_DRY_RUN=true fix: HOOKS section should also be parsed when HELM_DIFF_USE_UPGRADE_DRY_RUN=true Feb 13, 2022
@mumoshu mumoshu merged commit 060d100 into databus23:master Feb 13, 2022
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.

with HELM_DIFF_USE_UPGRADE_DRY_RUN=true helm-diff only parses MANIFEST section missing the HOOKS
2 participants