Skip to content

Commit

Permalink
Better comparison of compose files (#12561)
Browse files Browse the repository at this point in the history
* Better comparison of compose files

* Add github.com/docker/libcompose/config and deps to vendor
  • Loading branch information
raphink authored and stack72 committed Mar 14, 2017
1 parent 3daed73 commit 4faeabf
Show file tree
Hide file tree
Showing 57 changed files with 9,740 additions and 9 deletions.
38 changes: 30 additions & 8 deletions builtin/providers/rancher/resource_rancher_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package rancher
import (
"fmt"
"log"
"reflect"
"strings"
"time"

compose "github.com/docker/libcompose/config"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -41,12 +43,14 @@ func resourceRancherStack() *schema.Resource {
ForceNew: true,
},
"docker_compose": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: suppressComposeDiff,
},
"rancher_compose": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: suppressComposeDiff,
},
"environment": {
Type: schema.TypeMap,
Expand All @@ -72,12 +76,14 @@ func resourceRancherStack() *schema.Resource {
Optional: true,
},
"rendered_docker_compose": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
DiffSuppressFunc: suppressComposeDiff,
},
"rendered_rancher_compose": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
DiffSuppressFunc: suppressComposeDiff,
},
},
}
Expand Down Expand Up @@ -432,3 +438,19 @@ func makeStackData(d *schema.ResourceData, meta interface{}) (data map[string]in

return data, nil
}

func suppressComposeDiff(k, old, new string, d *schema.ResourceData) bool {
cOld, err := compose.CreateConfig([]byte(old))
if err != nil {
// TODO: log?
return false
}

cNew, err := compose.CreateConfig([]byte(new))
if err != nil {
// TODO: log?
return false
}

return reflect.DeepEqual(cOld, cNew)
}
2 changes: 1 addition & 1 deletion vendor/github.com/docker/docker/NOTICE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions vendor/github.com/docker/docker/api/types/strslice/strslice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions vendor/github.com/docker/docker/pkg/urlutil/urlutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

191 changes: 191 additions & 0 deletions vendor/github.com/docker/go-connections/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4faeabf

Please sign in to comment.