Skip to content

Commit

Permalink
Move dyff to homeport
Browse files Browse the repository at this point in the history
Move `dyff` project into the `homeport` organization.
  • Loading branch information
HeavyWombat committed Apr 2, 2019
1 parent 6e68eb5 commit 58bdfe3
Show file tree
Hide file tree
Showing 33 changed files with 75 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2018 Matthias Diester
# Copyright © 2019 The Homeport Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
language: go
go:
- 1.11.x
- 1.12.x

install:
- curl --silent --location https://goo.gl/g1CpPX | bash -s v1.0.5
- curl --silent --location https://goo.gl/g1CpPX | bash -s v1.0.7

script:
- GO111MODULE=on go mod download
Expand All @@ -27,5 +28,5 @@ deploy:
file_glob: true
file: binaries/*
on:
condition: $TRAVIS_GO_VERSION =~ ^1\.11
condition: $TRAVIS_GO_VERSION =~ ^1\.12
tags: true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Matthias Diester
Copyright (c) 2019 The Homeport Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2018 Matthias Diester
# Copyright © 2019 The Homeport Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,8 +23,8 @@
all: test

clean:
@go clean -i -r -cache
@rm -rf $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/binaries
@go clean -i -cache $(shell go list ./...)

vet:
$(dir $(realpath $(firstword $(MAKEFILE_LIST))))scripts/go-vet.sh
Expand Down
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[![License](https://img.shields.io/github/license/HeavyWombat/dyff.svg)](https://github.com/HeavyWombat/dyff/blob/master/LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/HeavyWombat/dyff)](https://goreportcard.com/report/github.com/HeavyWombat/dyff)
[![Build Status](https://travis-ci.org/HeavyWombat/dyff.svg?branch=master)](https://travis-ci.org/HeavyWombat/dyff)
[![Codecov](https://img.shields.io/codecov/c/github/HeavyWombat/dyff/master.svg)](https://codecov.io/gh/HeavyWombat/dyff)
[![GoDoc](https://godoc.org/github.com/HeavyWombat/dyff/pkg?status.svg)](https://godoc.org/github.com/HeavyWombat/dyff/pkg)
[![Release](https://img.shields.io/github/release/HeavyWombat/dyff.svg)](https://github.com/HeavyWombat/dyff/releases/latest)

# δyƒƒ /ˈdʏf/

[![License](https://img.shields.io/github/license/homeport/dyff.svg)](https://github.com/homeport/dyff/blob/master/LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/homeport/dyff)](https://goreportcard.com/report/github.com/homeport/dyff)
[![Build Status](https://travis-ci.org/homeport/dyff.svg?branch=master)](https://travis-ci.org/homeport/dyff)
[![Codecov](https://img.shields.io/codecov/c/github/homeport/dyff/master.svg)](https://codecov.io/gh/homeport/dyff)
[![GoDoc](https://godoc.org/github.com/homeport/dyff/pkg?status.svg)](https://godoc.org/github.com/homeport/dyff/pkg)
[![Release](https://img.shields.io/github/release/homeport/dyff.svg)](https://github.com/homeport/dyff/releases/latest)

A diff tool for YAML files, and sometimes JSON

![dyff between example](docs/images/dyff-between-example.png?raw=true "dyff between example of two cf-deployment versions")

## Description

`dyff` is inspired by the way the old [BOSH v1](https://bosh.io/) deployment output reported changes from one version to another by only showing the parts of a YAML file that change.

Each difference is referenced by its location in the YAML document by using either the [Spruce](https://github.com/geofffranks/spruce) or [go-patch](https://github.com/cppforlife/go-patch) path syntax. The output report aims to be as compact as possible to give a clear and simple overview of the change.
Expand All @@ -22,55 +24,69 @@ Input files can be local files (filesystem path), remote files (URI), or the sta
All orders of keys in hashes are preserved during processing and output to the terminal, most notably in the sub-commands to convert YAML to JSON and vice versa.

## Installation

On macOS, `dyff` is available via Homebrew:

```bash
brew install HeavyWombat/tap/dyff
brew install homeport/tap/dyff
```

Prebuilt binaries for a lot of operating systems and architectures can be [downloaded from the releases section](https://github.com/HeavyWombat/dyff/releases/latest).
Prebuilt binaries for a lot of operating systems and architectures can be [downloaded from the releases section](https://github.com/homeport/dyff/releases/latest).

There is a convenience script to download the latest release for Linux or macOS if you want to keep it simple (you need `curl` and `jq` installed on your machine):

```bash
curl --silent --location https://goo.gl/DRXDVN | bash
```

And of course, you can download and build `dyff` from source using `go`:

```bash
go get github.com/HeavyWombat/dyff
go get github.com/homeport/dyff
```

## Use cases and examples

- Show the differences between two versions of [`cf-deployment`](https://github.com/cloudfoundry/cf-deployment/) YAMLs:

```bash
dyff between \
https://raw.githubusercontent.com/cloudfoundry/cf-deployment/v1.19.0/cf-deployment.yml \
https://raw.githubusercontent.com/cloudfoundry/cf-deployment/v1.20.0/cf-deployment.yml
```

- Convert a JSON stream to YAML

```bash
sometool --json | jq --raw-output '.data' | dyff yaml -
```

- Sometimes you end up with YAML or JSON files, where the order of the keys in maps was sorted alphabetically. With `dyff` you can restructure keys in maps to a more human appealing order:

```bash
sometool --export --json | dyff - yaml --restructure
```

Or, rewrite a file _in place_ with the restructured order of keys.

```bash
dyff yaml --restructure --in-place somefile.yml
```

- Just print a YAML (or JSON) file to the terminal to look at it. By default, `dyff` will use a neat output schema which includes different colors and indent helper lines to improve readability. The colors are roughly based on the default [Atom](https://atom.io) schema and work best on dark terminal backgrounds. The neat output is disabled the output of `dyff` is redirected into a pipe, or you can disable it explicitly using the `--plain` flag.

```bash
dyff yaml somefile.yml
```

- Convert a YAML file to JSON and vice versa:

```bash
dyff json https://raw.githubusercontent.com/cloudfoundry/cf-deployment/v1.19.0/cf-deployment.yml
```

The `dyff` sub-command (`yaml`, or `json`) defines the output format, the tool automatically detects the input format itself.

```bash
dyff yaml https://raw.githubusercontent.com/HeavyWombat/dyff/develop/assets/bosh-yaml/manifest.json
dyff yaml https://raw.githubusercontent.com/homeport/dyff/develop/assets/bosh-yaml/manifest.json
```
4 changes: 2 additions & 2 deletions cmd/dyff/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,7 +20,7 @@

package main

import "github.com/HeavyWombat/dyff/internal/cmd"
import "github.com/homeport/dyff/internal/cmd"

func main() {
cmd.Execute()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/HeavyWombat/dyff
module github.com/homeport/dyff

require (
github.com/homeport/gonvenience v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/between.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -26,7 +26,7 @@ import (
"os"
"strings"

"github.com/HeavyWombat/dyff/pkg/v1/dyff"
"github.com/homeport/dyff/pkg/v1/dyff"
"github.com/homeport/ytbx/pkg/v1/ytbx"
"github.com/spf13/cobra"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/cmd_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,7 +25,7 @@ import (
"os"
"testing"

. "github.com/HeavyWombat/dyff/internal/cmd"
. "github.com/homeport/dyff/internal/cmd"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/json.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -28,7 +28,7 @@ import (
"io/ioutil"
"os"

"github.com/HeavyWombat/dyff/pkg/v1/dyff"
"github.com/homeport/dyff/pkg/v1/dyff"
"github.com/homeport/gonvenience/pkg/v1/bunt"
"github.com/homeport/gonvenience/pkg/v1/neat"
"github.com/homeport/ytbx/pkg/v1/ytbx"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/yaml.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/compare_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,7 +21,7 @@
package dyff_test

import (
. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
"github.com/homeport/ytbx/pkg/v1/ytbx"

. "github.com/onsi/ginkgo"
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/core.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/core_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -34,7 +34,7 @@ import (
. "github.com/homeport/gonvenience/pkg/v1/bunt"
"github.com/homeport/ytbx/pkg/v1/ytbx"

. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
yaml "gopkg.in/yaml.v2"

. "github.com/onsi/ginkgo"
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/core_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,7 +21,7 @@
package dyff_test

import (
. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
"github.com/homeport/ytbx/pkg/v1/ytbx"
yaml "gopkg.in/yaml.v2"

Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/logs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/models.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/output.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/output_brief.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/output_human.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/output_human_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,7 +24,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
)

var _ = Describe("human readable report", func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/output_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -26,7 +26,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
. "github.com/homeport/gonvenience/pkg/v1/bunt"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/dyff/restructure.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions pkg/v1/dyff/restructure_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2018 Matthias Diester
// Copyright © 2019 The Homeport Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,7 +21,7 @@
package dyff_test

import (
. "github.com/HeavyWombat/dyff/pkg/v1/dyff"
. "github.com/homeport/dyff/pkg/v1/dyff"
yaml "gopkg.in/yaml.v2"

. "github.com/onsi/ginkgo"
Expand Down
4 changes: 2 additions & 2 deletions scripts/compile-version.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Copyright © 2018 Matthias Diester
# Copyright © 2019 The Homeport Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -71,7 +71,7 @@ while read -r OS ARCH; do
TARGET_FILE="${TARGET_FILE}.exe"
fi

(cd "$BASEDIR" && GO111MODULE=on CGO_ENABLED=0 GOOS="$OS" GOARCH="$ARCH" go build -tags netgo -ldflags="-s -w -extldflags '-static' -X github.com/HeavyWombat/dyff/internal/cmd.version=${VERSION}" -o "$TARGET_FILE" cmd/dyff/main.go)
(cd "$BASEDIR" && GO111MODULE=on CGO_ENABLED=0 GOOS="$OS" GOARCH="$ARCH" go build -tags netgo -ldflags="-s -w -extldflags '-static' -X github.com/homeport/dyff/internal/cmd.version=${VERSION}" -o "$TARGET_FILE" cmd/dyff/main.go)

done <<EOL
darwin 386
Expand Down
Loading

0 comments on commit 58bdfe3

Please sign in to comment.