Skip to content

feature: diffing between different releases #131

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

Merged
merged 1 commit into from
Apr 7, 2019

Conversation

codenio
Copy link
Contributor

@codenio codenio commented Apr 2, 2019

Hi,

This PR resolves #130 and it contains the following changes

  • add diff release subcommand to compare different releases
  • update subcommand usage in README.md
  • adds go report card badge and license badge to the README.md

suggestions and comments..?

@sstarcher
Copy link
Contributor

Looking greatly improved. I tested it against 2 releases I have that are very complicated.
customer1-qc
customer2-qc

It looks to be working normally except for one instance. I have a single file in my helm chart called networkpolicy.yaml. This single file always contains 2 yaml docs that are 2 NetworkPolicy docs. They both should differ and show up in the diff, but I see the first doc being diffed with the second customers doc.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: {{ template "apps.fullname" . }}-cluster
  labels:
    {{- include "labels" . | indent 4 }}
spec:
  podSelector: {}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: {{ template "apps.fullname" . }}-all
  labels:
{{ include "labels" . | indent 4 }}
spec:
  podSelector: {}
  policyTypes:
  - Egress

Diff

app/templates/network-policy.yaml has changed:
  # Source: app/templates/network-policy.yaml
  apiVersion: networking.k8s.io/v1
  kind: NetworkPolicy
  metadata:
-   name: customer1-qc-app-cluster
-   labels:
+   name: customer2-qc-app-all
+   labels:
+
      app: app
      heritage: Tiller
-     release: customer1-qc
+     release: customer2-qc
      environment: qc
-     customer: customer1
+     customer: customer2
  spec:
    podSelector: {}
    policyTypes:
    - Egress

I should be seeing 2 network policy diffs

where customer1-cluster is being diffed against customer2-cluster, but instead I see a single one for customer1-cluster being diffed against customer2-all.

@sstarcher
Copy link
Contributor

I did a few more diffs and so for everything else except for that issue with 2 yaml docs in a single helm chart file looks good.

@codenio
Copy link
Contributor Author

codenio commented Apr 2, 2019

I guess helm templates are rendered and applied as a whole and kubernetes takes care of creating multiple objects from same yaml file.
Will check further about this.
Have you ever did a helm diff upgrade with the file you have mentioned above, does it show as two individual network policy files..?

@sstarcher
Copy link
Contributor

It shows them both at 2 separate parts in the diff output they are not together and are separated by multiple other diffs.
customer, customer-apps-all, NetworkPolicy (networking.k8s.io) has changed:
customer, customer-cluster, NetworkPolicy (networking.k8s.io) has changed:

@codenio codenio force-pushed the feature/release-diff branch from 3a650cd to 5d2197e Compare April 2, 2019 16:25
@codenio
Copy link
Contributor Author

codenio commented Apr 2, 2019

@sstarcher resolved the above mentioned issue. now we get the diff for object files separately.
do let me know for further enhancements or changes required.

@sstarcher
Copy link
Contributor

LGTM, the issue is fixed and I am not seeing anything that's having a issue.

@codenio
Copy link
Contributor Author

codenio commented Apr 2, 2019

Thanks @sstarcher , for the prompt feedback 👍

now comes the bigger task 😆
Getting it reviewed and merged .

@codenio
Copy link
Contributor Author

codenio commented Apr 3, 2019

diff release on completely independent releases (based on two different charts) would be meaningless.
hence we need to impose restriction based on chart names. i.e releases installed using the same chart can only be compared.

$ helm diff release app-1 foo
Error : Incomparable Releases 
 Unable to compare releases from two different charts "demo", "ibm-nginx-dev". 
 try helm diff release --help to know more

adding these changes.

this commit
 - add diff release subcommand to compare different releases
 - adds go report card badge and lisence badge to readme
@codenio codenio force-pushed the feature/release-diff branch from 5d2197e to a3fe078 Compare April 3, 2019 04:02
@sstarcher
Copy link
Contributor

@aananthraj I have one consideration for that are you blocking it just on the chart name or the repo/chart name? Just to confirm it's only the chart name correct? I have a usecase for having a beta/chart and a stable/chart.

@sstarcher
Copy link
Contributor

@databus23 Could we get a look and get this merged and released pretty please.

@codenio
Copy link
Contributor Author

codenio commented Apr 3, 2019

Just to confirm it's only the chart name correct?

Yes @sstarcher, just based on chart names.

@codenio
Copy link
Contributor Author

codenio commented Apr 5, 2019

@databus23 , @mumoshu any update on this..?

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.

LGTM. Thanks a lot for your contribution ☺️

@@ -137,3 +145,34 @@ func calculateDistances(diffs []difflib.DiffRecord) map[int]int {

return distances
}

// reIndexForRelease based on template names
func reIndexForRelease(index map[string]*manifest.MappingResult) map[string]*manifest.MappingResult {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very very nit but I think it's fine to say reindex rather than reIndex 😃

@mumoshu mumoshu merged commit c20f260 into databus23:master Apr 7, 2019
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.

Allow diffing between 2 different releases
3 participants