From c3e054f762e864912c8aa6ddcb6290fba8c6ea68 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Thu, 16 Apr 2020 20:30:59 +0900 Subject: [PATCH] fix: fix filepath --- go.mod | 2 ++ go.sum | 10 ++-------- {client => graylog/client}/endpoint/view.go | 0 {client => graylog/client}/view.go | 2 +- {client => graylog/client}/view_test.go | 2 +- view.go => graylog/graylog/view.go | 15 +++++++-------- .../terraform}/resource_view.go | 4 ++-- {testdata => graylog/testdata}/view.json | 0 {testdata => graylog/testdata}/views.go | 2 +- {testdata => graylog/testdata}/views.json | 0 10 files changed, 16 insertions(+), 21 deletions(-) rename {client => graylog/client}/endpoint/view.go (100%) rename {client => graylog/client}/view.go (96%) rename {client => graylog/client}/view_test.go (94%) rename view.go => graylog/graylog/view.go (94%) rename {terraform/graylog => graylog/terraform}/resource_view.go (98%) rename {testdata => graylog/testdata}/view.json (100%) rename {testdata => graylog/testdata}/views.go (98%) rename {testdata => graylog/testdata}/views.json (100%) diff --git a/go.mod b/go.mod index f69fa813..8a02daf1 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,14 @@ require ( github.com/hashicorp/terraform v0.12.19 github.com/leodido/go-urn v1.2.0 // indirect github.com/mitchellh/mapstructure v1.1.2 + github.com/pkg/errors v0.8.1 github.com/sanity-io/litter v1.2.0 github.com/sirupsen/logrus v1.4.2 github.com/stretchr/testify v1.4.0 github.com/suzuki-shunsuke/flute v0.7.0 github.com/suzuki-shunsuke/go-jsoneq v0.1.2 github.com/suzuki-shunsuke/go-ptr v1.0.0 + github.com/suzuki-shunsuke/go-set v6.0.0+incompatible // indirect github.com/suzuki-shunsuke/go-set/v6 v6.0.1 gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 diff --git a/go.sum b/go.sum index d363cfae..71f41b36 100644 --- a/go.sum +++ b/go.sum @@ -95,12 +95,9 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -108,7 +105,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -219,7 +215,6 @@ github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82/go.mod h1:y54tfGmO3NKssKveTEFFzH8C/akrSOy/iW9qEAUDV84= @@ -300,7 +295,6 @@ github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQw github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= @@ -320,12 +314,13 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/suzuki-shunsuke/flute v0.7.0 h1:DvDSCMIMiLlRj4AQPMeJ1NfHE3lG5yfs2LU0Dnf1+oc= github.com/suzuki-shunsuke/flute v0.7.0/go.mod h1:UZOMr3GyEuYSr7/zf0nHgaLP9ZhKDB+2pBeV1WFkohE= github.com/suzuki-shunsuke/go-cliutil v0.0.0-20181211154308-176f852d9bca/go.mod h1:Vq3NkhgmA9DT/2UZ08x/3A34xxvzQ/vTMABnTWKoMbY= -github.com/suzuki-shunsuke/go-graylog v2.5.0+incompatible h1:6G5hjnyxyLjc1GGksED+wcbQSTNmVzVhkthhVll6HyY= github.com/suzuki-shunsuke/go-jsoneq v0.1.1/go.mod h1:vbOEb6bPf8nD+QASKzxtQ/vfVGgAyfWHyItUaUTwJWk= github.com/suzuki-shunsuke/go-jsoneq v0.1.2 h1:A4czEbmFqSELTbrEtXVo4dSgfz2e2Z0y6G3OpExUML8= github.com/suzuki-shunsuke/go-jsoneq v0.1.2/go.mod h1:ETXAwfruZTqMMKDxc9CYoS34CNSsnzcdcVIAW3+RujI= github.com/suzuki-shunsuke/go-ptr v1.0.0 h1:sVR6ICMJbdCyOpxzrflHErkO8KmItPFDu0E0PoQR0W8= github.com/suzuki-shunsuke/go-ptr v1.0.0/go.mod h1:4WKv+CJynv3Veutqvmt7yPUqEsZp0vezqFxVRukjga0= +github.com/suzuki-shunsuke/go-set v6.0.0+incompatible h1:APxAhd/XeHGrrp3vR6a9Yiwgak+HlM+CVREvDAULM8w= +github.com/suzuki-shunsuke/go-set v6.0.0+incompatible/go.mod h1:CZob7MsjSLZlWDHWKeRvDX/Q2eWA6qqbx+FXdy2FgnM= github.com/suzuki-shunsuke/go-set/v6 v6.0.1 h1:JxqxB+UYnkMqskPZhLrOFLas6SY/Z6yMNOm9kOvwSDY= github.com/suzuki-shunsuke/go-set/v6 v6.0.1/go.mod h1:3dlTSl52oLMev8ZwgkNkGl3euc+Gm0ehBpfR4g+MdXY= github.com/suzuki-shunsuke/gomic v0.5.6/go.mod h1:GEDQnxOB07p3mTZG/MiuclfyfcqnNqp0rt9AHgIzs7Q= @@ -463,7 +458,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= diff --git a/client/endpoint/view.go b/graylog/client/endpoint/view.go similarity index 100% rename from client/endpoint/view.go rename to graylog/client/endpoint/view.go diff --git a/client/view.go b/graylog/client/view.go similarity index 96% rename from client/view.go rename to graylog/client/view.go index de99ba8a..ee69b74e 100644 --- a/client/view.go +++ b/graylog/client/view.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/suzuki-shunsuke/go-graylog" + "github.com/suzuki-shunsuke/go-graylog/v11/graylog/graylog" ) // GetViews returns all views. diff --git a/client/view_test.go b/graylog/client/view_test.go similarity index 94% rename from client/view_test.go rename to graylog/client/view_test.go index e659f400..bd7432a2 100644 --- a/client/view_test.go +++ b/graylog/client/view_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/suzuki-shunsuke/flute/flute" - "github.com/suzuki-shunsuke/go-graylog/testdata" + "github.com/suzuki-shunsuke/go-graylog/v11/graylog/testdata" ) func TestClient_GetViews(t *testing.T) { diff --git a/view.go b/graylog/graylog/view.go similarity index 94% rename from view.go rename to graylog/graylog/view.go index c047299f..a5278a05 100644 --- a/view.go +++ b/graylog/graylog/view.go @@ -2,9 +2,8 @@ package graylog import ( "encoding/json" + "errors" "fmt" - - "github.com/pkg/errors" ) type ( @@ -121,7 +120,7 @@ func (widget MessagesViewWidgetConfig) Type() string { func (widget *ViewWidget) UnmarshalJSON(b []byte) error { errMsg := "failed to unmarshal JSON to view widget" if widget == nil { - return fmt.Errorf("%s: view widget is nil", errMsg) + return errors.New(errMsg + ": view widget is nil") } type alias ViewWidget a := struct { @@ -132,20 +131,20 @@ func (widget *ViewWidget) UnmarshalJSON(b []byte) error { alias: (*alias)(widget), } if err := json.Unmarshal(b, &a); err != nil { - return errors.Wrap(err, errMsg) + return fmt.Errorf(errMsg+": %w", err) } switch a.Type { case "aggregation": p := AggregationViewWidgetConfig{} if err := json.Unmarshal(a.Config, &p); err != nil { - return errors.Wrap(err, errMsg) + return fmt.Errorf(errMsg+": %w", err) } widget.Config = p return nil case "messages": p := MessagesViewWidgetConfig{} if err := json.Unmarshal(a.Config, &p); err != nil { - return errors.Wrap(err, errMsg) + return fmt.Errorf(errMsg+": %w", err) } widget.Config = p return nil @@ -158,7 +157,7 @@ func (widget *ViewWidget) UnmarshalJSON(b []byte) error { func (position *ViewWidgetPosition) UnmarshalJSON(b []byte) error { errMsg := "failed to unmarshal JSON to view widget position" if position == nil { - return fmt.Errorf("%s: view widget position is nil", errMsg) + return errors.New(errMsg + ": view widget position is nil") } type alias ViewWidgetPosition @@ -180,7 +179,7 @@ func (position *ViewWidgetPosition) UnmarshalJSON(b []byte) error { alias: (*alias)(position), } if err := json.Unmarshal(b, &c); err != nil { - return errors.Wrap(err, errMsg) + return fmt.Errorf(errMsg+": %w", err) } if i, err := c.Width.Int64(); err == nil { position.Width = int(i) diff --git a/terraform/graylog/resource_view.go b/graylog/terraform/resource_view.go similarity index 98% rename from terraform/graylog/resource_view.go rename to graylog/terraform/resource_view.go index 0abe7864..3f33fe8a 100644 --- a/terraform/graylog/resource_view.go +++ b/graylog/terraform/resource_view.go @@ -1,10 +1,10 @@ -package graylog +package terraform import ( "context" "github.com/hashicorp/terraform/helper/schema" - "github.com/suzuki-shunsuke/go-graylog" + "github.com/suzuki-shunsuke/go-graylog/v11/graylog/graylog" ) func resourceView() *schema.Resource { diff --git a/testdata/view.json b/graylog/testdata/view.json similarity index 100% rename from testdata/view.json rename to graylog/testdata/view.json diff --git a/testdata/views.go b/graylog/testdata/views.go similarity index 98% rename from testdata/views.go rename to graylog/testdata/views.go index 97a8e72f..3b16872a 100644 --- a/testdata/views.go +++ b/graylog/testdata/views.go @@ -1,7 +1,7 @@ package testdata import ( - "github.com/suzuki-shunsuke/go-graylog" + "github.com/suzuki-shunsuke/go-graylog/v11/graylog/graylog" ) var ( diff --git a/testdata/views.json b/graylog/testdata/views.json similarity index 100% rename from testdata/views.json rename to graylog/testdata/views.json