vulcanizer icon indicating copy to clipboard operation
vulcanizer copied to clipboard

Diff mappings

Open xsaamiir opened this issue 5 years ago • 4 comments

I saw in the functionality diff mappings in the roadmap. Have you already given any thought on how should this be implemented ? (calling git from the go code?)

The desired behaviour of this functionality using the CLI, I guess would be to print the diff git style on the console, but how should this functionality behave when vulcanizer is used as a library ?

xsaamiir avatar Mar 25 '19 22:03 xsaamiir

Thanks for the question! I admit, this feature might not be the most useful, so I don't think it's worth spending a lot of time on.

The idea would be if you had several time series indices on a cluster to be able to compare logs-2019-02-01 and logs-2019-03-01 and see if any of the mappings had changed between those two indices. The output could be a string similar to the go-comp output.

nickcanz avatar Mar 26 '19 13:03 nickcanz

I've got a POC going with https://github.com/nsf/jsondiff image

The problem is that the output is absolutely massive because of the mapping file sizes.

I was working on a custom reporter for https://github.com/google/go-cmp but it was a bit over my head. The default settings for go-cmp is very verbose, so we would need a custom reporter, as seen here: https://pkg.go.dev/github.com/google/go-cmp/[email protected]?tab=doc#example-Reporter.

The example reporter only outputs the actual diff with the path leading up to that, but it's still very dense so would need some customisation.

root
["mappings"]
 .(map[string]interface {})
  ["kube-logs"]
   .(map[string]interface {})
    ["properties"]
     .(map[string]interface {})
      ["extra"]
       .(map[string]interface {})
        ["properties"]
         .(map[string]interface {})
          ["req"]
           .(map[string]interface {})
            ["properties"]
             .(map[string]interface {})
              ["headers"]
               .(map[string]interface {})
                ["properties"]
                 .(map[string]interface {})
                  ["dnt"]
                   :
	-: <invalid reflect.Value>
	+: map[fields:map[keyword:map[ignore_above:256 type:keyword]] norms:false type:text]

root
["mappings"]
 .(map[string]interface {})
  ["kube-logs"]
   .(map[string]interface {})
    ["properties"]
     .(map[string]interface {})
      ["message_args"]
       .(map[string]interface {})
        ["fields"]
         :
	-: map[keyword:map[ignore_above:256 type:keyword]]
	+: <invalid reflect.Value>

I also have some reflect value issues here.

leosunmo avatar Jul 06 '20 22:07 leosunmo

The main issue for go-cmp is that we don't have a struct this can be marshalled in to, so everything is a map[string]interface {}

leosunmo avatar Jul 06 '20 22:07 leosunmo

It looks like https://github.com/nsf/jsondiff/issues/6 was finally solved! Going to give it a try

leosunmo avatar Sep 23 '21 07:09 leosunmo