Skip to content

Add support for custom output formats #221

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 2 commits into from
Jul 20, 2020

Conversation

semoac
Copy link
Contributor

@semoac semoac commented Jun 30, 2020

Hi!

I was using these changes to format the output of helm-diff and I think it may be useful to someone else.

I use these formats to help me make decisions during my CI/CD pipeline on whatever or not the changes should be applied unsupervised. They also help me reduce the visual noise when helmfile has to process a lot of releases.

I also been using the "template" output format to feed data to external system that needs to know what resource could be affected on upgrades.

This PR do not fix anything. I'm just sharing code. Please feel free to reject it without explanation.

Examples

Simple with helmfile

Screen Shot 2020-06-29 at 15 54 18

Template with a json like output

Screen Shot 2020-06-29 at 02 31 13

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.

@semoac Hey! Thank you so much for this awesome work ☺️

This LGTM overall. But can I later make json output format as an alias to the current template output? I think that's more straightforward for users wanting to use json output.

Probably we can easily add yaml output on top of that, but that's another story!

@mumoshu
Copy link
Collaborator

mumoshu commented Jul 20, 2020

@semoac Also - would you mind if we reused your screencaptures in our README?

@mumoshu mumoshu merged commit 55d7572 into databus23:master Jul 20, 2020
@semoac
Copy link
Contributor Author

semoac commented Jul 20, 2020

@semoac Also - would you mind if we reused your screencaptures in our README?

Sure. Go ahead!

mumoshu added a commit that referenced this pull request Jul 20, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
mumoshu added a commit that referenced this pull request Jul 20, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
@mumoshu mumoshu mentioned this pull request Jul 20, 2020
mumoshu added a commit that referenced this pull request Jul 20, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
mumoshu added a commit that referenced this pull request Jul 21, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
mumoshu added a commit that referenced this pull request Jul 21, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
mumoshu added a commit that referenced this pull request Jul 21, 2020
This adds the JSON output on top of #221, which can be enabled by passing `--output json`. Internally it works exactly the same as the `template` output format with the default template.

```
********************

        Release was not present in Helm.  Diff will show entire contents as new.

********************
[{
  "api": "v1",
  "kind": "Secret",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "ConfigMap",
  "namespace": "default",
  "name": "mysql-1567775891-test",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "PersistentVolumeClaim",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "v1",
  "kind": "Service",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
},{
  "api": "apps",
  "kind": "Deployment",
  "namespace": "default",
  "name": "mysql-1567775891",
  "change": "ADD"
}]
```

Ref #221 (review)
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