Skip to content

Ignore diff created by helm when using --three-way-merge #349

Closed

Description

@yuvalhnoga

Hi,
Currently when using the --three-way-merge options it shows some changes that were made by helm and it would be nice if it didn't show them because they are irrelevant.

Example:

  apiVersion: apps/v1
  kind: Deployment
  metadata:
-   annotations:
-     deployment.kubernetes.io/revision: "5"
    creationTimestamp: "2021-04-08T14:16:14Z"
-   generation: 8
+   generation: 9

Activity

  1. mumoshu commented on Jan 13, 2022

    @mumoshu
    Collaborator

    @yuvalhnoga Hey. deployment.kubernetes.io/revision: "5" does look irrelevant because it's added automatically by K8s. I want your insight about generation- what's the rationale of marking generation irrelevant, you think?

  2. yuvalhnoga commented on Jan 13, 2022

    @yuvalhnoga
    Author

    Thanks for replying :)
    generation seems irrelevant to me because it's added automatically too and will always show up when using diff

  3. mumoshu commented on Jan 13, 2022

    @mumoshu
    Collaborator

    @yuvalhnoga I see. Thanks for validation 😄

  4. mumoshu commented on Jan 22, 2022

    @mumoshu
    Collaborator

    We already have similar cleanup logics in

    helm-diff/cmd/upgrade.go

    Lines 546 to 572 in 9086688

    func deleteStatusAndTidyMetadata(obj []byte) (map[string]interface{}, error) {
    var objectMap map[string]interface{}
    err := jsoniterator.Unmarshal(obj, &objectMap)
    if err != nil {
    return nil, errors.Wrap(err, "could not unmarshal byte sequence")
    }
    delete(objectMap, "status")
    metadata := objectMap["metadata"].(map[string]interface{})
    delete(metadata, "managedFields")
    // See the below for the goal of this metadata tidy logic.
    // https://github.com/databus23/helm-diff/issues/326#issuecomment-1008253274
    if a := metadata["annotations"]; a != nil {
    annotations := a.(map[string]interface{})
    delete(annotations, "meta.helm.sh/release-name")
    delete(annotations, "meta.helm.sh/release-namespace")
    if len(annotations) == 0 {
    delete(metadata, "annotations")
    }
    }
    return objectMap, nil
    }

    Could anyone contribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions