From b90d6ec910aa938877425e054c8cd3da034db352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Opasiak?= Date: Wed, 5 Jun 2024 14:40:05 +0100 Subject: [PATCH] lint: change to golangci-lint --- .golangci.yml | 37 +++++++++++++++ Makefile | 14 +++--- assets/pkged.go | 1 + cmd/generate.go | 5 ++- cmd/prune.go | 3 +- generate/hcl.go | 9 ++-- generate/hcl_test.go | 5 ++- generate/helper_test.go | 3 +- generate/state.go | 13 +++--- generate/state_test.go | 5 ++- go.mod | 45 ++++++++++++++----- go.sum | 18 -------- graph/edge_test.go | 5 ++- graph/graph_test.go | 5 ++- printer/dot/printer.go | 8 ++-- printer/factory/factory_test.go | 5 ++- provider/aws/aws.go | 1 - provider/aws/aws_test.go | 3 +- provider/aws/graph.go | 7 --- provider/azurerm/azurerm.go | 1 - provider/azurerm/azurerm_test.go | 3 +- provider/factory/factory.go | 3 +- provider/factory/factory_test.go | 5 ++- provider/flexibleengine/flexibleengine.go | 1 - .../flexibleengine/flexibleengine_test.go | 3 +- provider/google/google.go | 1 - provider/google/google_test.go | 3 +- provider/openstack/openstack.go | 1 - provider/openstack/openstack_test.go | 3 +- prune/prune.go | 7 +-- tools/tools.go | 1 + 31 files changed, 137 insertions(+), 87 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..30e1fb1 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,37 @@ +# options for analysis running +# full configuration example can be found at https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 10m + concurrency: 4 + go: "1.22" + + +# all available settings of specific linters +linters-settings: + + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + ignore-words: + - licence + - licences + - utilisation + - cancelled + + staticcheck: + # https://staticcheck.io/docs/options#checks + checks: ["all", "-SA1019", "-SA5012"] + + +linters: + disable-all: true + enable: + - staticcheck + - goimports + - ineffassign + - unused + - unconvert + - misspell diff --git a/Makefile b/Makefile index bdf5afc..6967969 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ BIN := inframap TOOL_BIN := $(PWD)/bin -GOLINT := $(TOOL_BIN)/golint GOIMPORTS := $(TOOL_BIN)/goimports ENUMER := $(TOOL_BIN)/enumer PKGER := $(TOOL_BIN)/go-bindata @@ -29,9 +28,6 @@ help: Makefile ## This help dialog $(ENUMER): @GOBIN=$(TOOL_BIN) go install github.com/dmarkham/enumer -$(GOLINT): - @GOBIN=$(TOOL_BIN) go install golang.org/x/lint/golint - $(GOIMPORTS): @GOBIN=$(TOOL_BIN) go install golang.org/x/tools/cmd/goimports @@ -43,8 +39,9 @@ test: ## Tests all the project @go test ./... .PHONY: lint -lint: $(GOLINT) $(GOIMPORTS) ## Runs the linter - @$(GOLINT) -set_exit_status ./... && test -z "`go list -f {{.Dir}} ./... | xargs $(GOIMPORTS) -l | tee /dev/stderr`" +lint: ## Lint the source code + @echo -e "# \e[33mRunning golangci-lint\e[0m" + @golangci-lint run -v .PHONY: generate generate: $(ENUMER) ## Generates the needed code @@ -76,3 +73,8 @@ build-compress: build-all ## Builds and compress the binaries .PHONY: dbuild dbuild: ## Builds the docker image with same name as the binary @docker build -t $(BIN) . + +.PHONY: format-go +format-go: + @gci write --skip-generated -s standard -s default -s "prefix(github.com/cycloidio)" . > /dev/null + @goimports -w -local github.com/cycloidio . diff --git a/assets/pkged.go b/assets/pkged.go index 90b0860..94c9dc2 100644 --- a/assets/pkged.go +++ b/assets/pkged.go @@ -1,5 +1,6 @@ // Code generated by pkger; DO NOT EDIT. +//go:build !skippkger // +build !skippkger package assets diff --git a/cmd/generate.go b/cmd/generate.go index 2d87b69..7a0a09f 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -6,12 +6,13 @@ import ( "os" "strings" + "github.com/spf13/afero" + "github.com/spf13/cobra" + "github.com/cycloidio/inframap/generate" "github.com/cycloidio/inframap/graph" "github.com/cycloidio/inframap/printer" "github.com/cycloidio/inframap/printer/factory" - "github.com/spf13/afero" - "github.com/spf13/cobra" ) var ( diff --git a/cmd/prune.go b/cmd/prune.go index e6889cd..3702549 100644 --- a/cmd/prune.go +++ b/cmd/prune.go @@ -4,8 +4,9 @@ import ( "errors" "fmt" - "github.com/cycloidio/inframap/prune" "github.com/spf13/cobra" + + "github.com/cycloidio/inframap/prune" ) var ( diff --git a/generate/hcl.go b/generate/hcl.go index d1c9dd6..5d44d89 100644 --- a/generate/hcl.go +++ b/generate/hcl.go @@ -5,9 +5,6 @@ import ( "fmt" "strings" - "github.com/cycloidio/inframap/errcode" - "github.com/cycloidio/inframap/graph" - "github.com/cycloidio/inframap/provider" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclsyntax" "github.com/hashicorp/hcl/v2/hclwrite" @@ -15,6 +12,10 @@ import ( "github.com/hashicorp/terraform/configs/hcl2shim" uuid "github.com/satori/go.uuid" "github.com/spf13/afero" + + "github.com/cycloidio/inframap/errcode" + "github.com/cycloidio/inframap/graph" + "github.com/cycloidio/inframap/provider" ) // FromHCL generates a new graph from the HCL on the path, @@ -90,7 +91,7 @@ func FromHCL(fs afero.Fs, path string, opt Options) (*graph.Graph, map[string]in nodeCanIDs[n.Canonical] = append(nodeCanIDs[n.Canonical], n.ID) - links := make(map[string][]string) + var links map[string][]string body, ok := rv.Config.(*hclsyntax.Body) if ok { links = getBodyLinks(body) diff --git a/generate/hcl_test.go b/generate/hcl_test.go index 1433f1c..080201e 100644 --- a/generate/hcl_test.go +++ b/generate/hcl_test.go @@ -3,10 +3,11 @@ package generate_test import ( "testing" - "github.com/cycloidio/inframap/generate" - "github.com/cycloidio/inframap/graph" "github.com/spf13/afero" "github.com/stretchr/testify/require" + + "github.com/cycloidio/inframap/generate" + "github.com/cycloidio/inframap/graph" ) func TestFromHCL_AWS(t *testing.T) { diff --git a/generate/helper_test.go b/generate/helper_test.go index a063e64..2211f7d 100644 --- a/generate/helper_test.go +++ b/generate/helper_test.go @@ -5,9 +5,10 @@ import ( "sort" "testing" - "github.com/cycloidio/inframap/graph" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cycloidio/inframap/graph" ) // assertEqualGraph will compare the expected graph to the actual one, the way it'll do that is by ignoring the IDs diff --git a/generate/state.go b/generate/state.go index 0a1dd6e..01bd009 100644 --- a/generate/state.go +++ b/generate/state.go @@ -5,18 +5,19 @@ import ( "encoding/json" "errors" "fmt" + "path" "regexp" "strings" + "github.com/hashicorp/terraform/addrs" + "github.com/hashicorp/terraform/states/statefile" + uuid "github.com/satori/go.uuid" + "github.com/cycloidio/flatmap" "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/graph" "github.com/cycloidio/inframap/provider" "github.com/cycloidio/inframap/provider/factory" - "github.com/hashicorp/terraform/addrs" - "github.com/hashicorp/terraform/states/statefile" - uuid "github.com/satori/go.uuid" - "path" ) // FromState generate a graph.Graph from the tfstate applying the opt @@ -259,8 +260,8 @@ func extractResourceName(attrs map[string]interface{}) string { // migrateVersions will try to apply migrations of old // statefile: -// * For version 3 will try to populate the Dependencies as they are -// removed by TF as they cannot be migrated from v3->v4 +// - For version 3 will try to populate the Dependencies as they are +// removed by TF as they cannot be migrated from v3->v4 func migrateVersions(src []byte, f *statefile.File) error { version, err := tfStateVersion(src) if err != nil { diff --git a/generate/state_test.go b/generate/state_test.go index e820c9b..f32305f 100644 --- a/generate/state_test.go +++ b/generate/state_test.go @@ -5,11 +5,12 @@ import ( "io/ioutil" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/generate" "github.com/cycloidio/inframap/graph" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestFromState(t *testing.T) { diff --git a/go.mod b/go.mod index a8fd3ff..60ba591 100644 --- a/go.mod +++ b/go.mod @@ -1,36 +1,59 @@ module github.com/cycloidio/inframap -go 1.15 +go 1.22 require ( github.com/adrg/xdg v0.4.0 - github.com/agext/levenshtein v1.2.3 // indirect github.com/awalterschulze/gographviz v2.0.3+incompatible github.com/chr4/pwgen v1.1.0 github.com/cycloidio/flatmap v1.0.0 github.com/cycloidio/tfdocs v0.0.0-20230516095646-1dc8f8412d50 github.com/dmarkham/enumer v1.5.6 + github.com/hashicorp/hcl/v2 v2.13.0 + github.com/hashicorp/terraform v0.15.3 + github.com/markbates/pkger v0.17.1 + github.com/satori/go.uuid v1.2.0 + github.com/spf13/afero v1.8.2 + github.com/spf13/cobra v1.5.0 + github.com/stretchr/testify v1.8.0 + golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 + golang.org/x/tools v0.1.12 +) + +require ( + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-versions v1.0.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/gobuffalo/here v0.6.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.6 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.0 // indirect github.com/hashicorp/go-version v1.3.0 // indirect - github.com/hashicorp/hcl/v2 v2.13.0 - github.com/hashicorp/terraform v0.15.3 - github.com/markbates/pkger v0.17.1 + github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/panicwrap v1.0.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pascaldekloe/name v1.0.1 // indirect - github.com/satori/go.uuid v1.2.0 - github.com/spf13/afero v1.8.2 - github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.8.0 - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/zclconf/go-cty v1.8.3 // indirect + golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect - golang.org/x/tools v0.1.12 + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 5908745..c70fa40 100644 --- a/go.sum +++ b/go.sum @@ -94,7 +94,6 @@ github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:o github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-shquot v0.0.1/go.mod h1:lw58XsE5IgUXZ9h0cxnypdx31p9mPFIVEQ9P3c7MlrU= -github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= @@ -137,8 +136,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cycloidio/flatmap v1.0.0 h1:JU3qCiedgEgw+Gv9Hd+a6uqw/b20roph+NtsFcPzmkU= github.com/cycloidio/flatmap v1.0.0/go.mod h1:mv5bQmrwtt5NLjC0l1JY+j6v/O69l61YrviC+3JwIck= -github.com/cycloidio/tfdocs v0.0.0-20220809201117-e73e2388cfa8 h1:wlW3Y1iIdXzi5GQDrzXoVaoKBPi15d+qmJqPCHbs97E= -github.com/cycloidio/tfdocs v0.0.0-20220809201117-e73e2388cfa8/go.mod h1:4zRiWOHuVkhb2vatajIFxV5g/AC4W7Zb/0pMF1G0yyA= github.com/cycloidio/tfdocs v0.0.0-20230516095646-1dc8f8412d50 h1:h52SDzmB7tAEAegKq747TzRFfWCWox1tMQZCTyCPwS0= github.com/cycloidio/tfdocs v0.0.0-20230516095646-1dc8f8412d50/go.mod h1:4zRiWOHuVkhb2vatajIFxV5g/AC4W7Zb/0pMF1G0yyA= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -323,7 +320,6 @@ github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04 github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= github.com/hashicorp/hcl/v2 v2.9.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= @@ -457,7 +453,6 @@ github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuB github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/name v1.0.0/go.mod h1:Z//MfYJnH4jVpQ9wkclwu2I2MkHmXTlT9wR5UZScttM= github.com/pascaldekloe/name v1.0.1 h1:9lnXOHeqeHHnWLbKfH6X98+4+ETVqFqxN09UXSjcMb0= github.com/pascaldekloe/name v1.0.1/go.mod h1:Z//MfYJnH4jVpQ9wkclwu2I2MkHmXTlT9wR5UZScttM= github.com/pkg/browser v0.0.0-20201207095918-0426ae3fba23/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= @@ -532,8 +527,6 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= @@ -569,7 +562,6 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -654,8 +646,6 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -679,8 +669,6 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -727,20 +715,16 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -750,7 +734,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -807,7 +790,6 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/graph/edge_test.go b/graph/edge_test.go index 7650d8d..a385572 100644 --- a/graph/edge_test.go +++ b/graph/edge_test.go @@ -3,10 +3,11 @@ package graph_test import ( "testing" - "github.com/cycloidio/inframap/errcode" - "github.com/cycloidio/inframap/graph" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cycloidio/inframap/errcode" + "github.com/cycloidio/inframap/graph" ) func TestEdgeReplace(t *testing.T) { diff --git a/graph/graph_test.go b/graph/graph_test.go index 4718368..91800ee 100644 --- a/graph/graph_test.go +++ b/graph/graph_test.go @@ -4,10 +4,11 @@ import ( "sort" "testing" - "github.com/cycloidio/inframap/errcode" - "github.com/cycloidio/inframap/graph" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cycloidio/inframap/errcode" + "github.com/cycloidio/inframap/graph" ) func TestAddNode(t *testing.T) { diff --git a/printer/dot/printer.go b/printer/dot/printer.go index 94d94c5..785117f 100644 --- a/printer/dot/printer.go +++ b/printer/dot/printer.go @@ -9,15 +9,15 @@ import ( "github.com/adrg/xdg" "github.com/awalterschulze/gographviz" - "github.com/cycloidio/inframap/graph" - "github.com/cycloidio/inframap/printer" - "github.com/cycloidio/inframap/provider" - "github.com/cycloidio/inframap/provider/factory" "github.com/markbates/pkger" // As we require to load the assets to be used // we import it as empty _ "github.com/cycloidio/inframap/assets" + "github.com/cycloidio/inframap/graph" + "github.com/cycloidio/inframap/printer" + "github.com/cycloidio/inframap/provider" + "github.com/cycloidio/inframap/provider/factory" ) // Dot is the struct that implements diff --git a/printer/factory/factory_test.go b/printer/factory/factory_test.go index 546666d..7695329 100644 --- a/printer/factory/factory_test.go +++ b/printer/factory/factory_test.go @@ -4,10 +4,11 @@ import ( "errors" "testing" - "github.com/cycloidio/inframap/errcode" - "github.com/cycloidio/inframap/printer/factory" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cycloidio/inframap/errcode" + "github.com/cycloidio/inframap/printer/factory" ) func TestGet(t *testing.T) { diff --git a/provider/aws/aws.go b/provider/aws/aws.go index dad0efd..5e94d83 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -5,7 +5,6 @@ import ( "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" - tfdocAWS "github.com/cycloidio/tfdocs/providers/aws" "github.com/cycloidio/tfdocs/resource" ) diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go index f533f14..b19b81e 100644 --- a/provider/aws/aws_test.go +++ b/provider/aws/aws_test.go @@ -3,8 +3,9 @@ package aws_test import ( "testing" - "github.com/cycloidio/inframap/provider/aws" "github.com/stretchr/testify/assert" + + "github.com/cycloidio/inframap/provider/aws" ) func TestResourceInOutNodes(t *testing.T) { diff --git a/provider/aws/graph.go b/provider/aws/graph.go index 51f28de..2dfabea 100644 --- a/provider/aws/graph.go +++ b/provider/aws/graph.go @@ -48,13 +48,6 @@ var ( "aws_launch_template": struct{}{}, } - // noSecurityGroup is a map of all the resourcese that do not - // have/relay on SecurityGroups - noSecurityGroup = map[string]struct{}{ - "aws_s3_bucket": struct{}{}, - "aws_cloudfront_distribution": struct{}{}, - } - // edgeTypes map of all the supported Edges edgeTypes = map[string]struct{}{ "aws_security_group": struct{}{}, diff --git a/provider/azurerm/azurerm.go b/provider/azurerm/azurerm.go index 3752b23..d0b2e9d 100644 --- a/provider/azurerm/azurerm.go +++ b/provider/azurerm/azurerm.go @@ -5,7 +5,6 @@ import ( "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" - tfdocAzurerm "github.com/cycloidio/tfdocs/providers/azurerm" "github.com/cycloidio/tfdocs/resource" ) diff --git a/provider/azurerm/azurerm_test.go b/provider/azurerm/azurerm_test.go index 84a4a8e..904a8f2 100644 --- a/provider/azurerm/azurerm_test.go +++ b/provider/azurerm/azurerm_test.go @@ -3,8 +3,9 @@ package azurerm_test import ( "testing" - "github.com/cycloidio/inframap/provider/azurerm" "github.com/stretchr/testify/assert" + + "github.com/cycloidio/inframap/provider/azurerm" ) func TestResourceInOut(t *testing.T) { diff --git a/provider/factory/factory.go b/provider/factory/factory.go index cb4b77f..d3ee4f2 100644 --- a/provider/factory/factory.go +++ b/provider/factory/factory.go @@ -5,11 +5,10 @@ import ( "regexp" "strings" - "github.com/cycloidio/inframap/provider/azurerm" - "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" "github.com/cycloidio/inframap/provider/aws" + "github.com/cycloidio/inframap/provider/azurerm" "github.com/cycloidio/inframap/provider/flexibleengine" "github.com/cycloidio/inframap/provider/google" "github.com/cycloidio/inframap/provider/im" diff --git a/provider/factory/factory_test.go b/provider/factory/factory_test.go index f222b30..d00e661 100644 --- a/provider/factory/factory_test.go +++ b/provider/factory/factory_test.go @@ -4,11 +4,12 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" "github.com/cycloidio/inframap/provider/factory" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestGetProviderAndResource(t *testing.T) { diff --git a/provider/flexibleengine/flexibleengine.go b/provider/flexibleengine/flexibleengine.go index e0ec67e..d79f22e 100644 --- a/provider/flexibleengine/flexibleengine.go +++ b/provider/flexibleengine/flexibleengine.go @@ -5,7 +5,6 @@ import ( "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" - tfdocFE "github.com/cycloidio/tfdocs/providers/flexibleengine" "github.com/cycloidio/tfdocs/resource" ) diff --git a/provider/flexibleengine/flexibleengine_test.go b/provider/flexibleengine/flexibleengine_test.go index 9f0d2a3..9b82f1d 100644 --- a/provider/flexibleengine/flexibleengine_test.go +++ b/provider/flexibleengine/flexibleengine_test.go @@ -3,8 +3,9 @@ package flexibleengine_test import ( "testing" - "github.com/cycloidio/inframap/provider/flexibleengine" "github.com/stretchr/testify/assert" + + "github.com/cycloidio/inframap/provider/flexibleengine" ) func TestResourceInOutNodes(t *testing.T) { diff --git a/provider/google/google.go b/provider/google/google.go index 3829e5b..bfaf7dd 100644 --- a/provider/google/google.go +++ b/provider/google/google.go @@ -5,7 +5,6 @@ import ( "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" - tfdocGCP "github.com/cycloidio/tfdocs/providers/google" "github.com/cycloidio/tfdocs/resource" ) diff --git a/provider/google/google_test.go b/provider/google/google_test.go index cce9052..69f141f 100644 --- a/provider/google/google_test.go +++ b/provider/google/google_test.go @@ -4,9 +4,10 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/assert" + "github.com/cycloidio/inframap/provider" "github.com/cycloidio/inframap/provider/google" - "github.com/stretchr/testify/assert" ) func TestResourceInOutNodes(t *testing.T) { diff --git a/provider/openstack/openstack.go b/provider/openstack/openstack.go index b5739f6..b06275d 100644 --- a/provider/openstack/openstack.go +++ b/provider/openstack/openstack.go @@ -5,7 +5,6 @@ import ( "github.com/cycloidio/inframap/errcode" "github.com/cycloidio/inframap/provider" - tfdocOS "github.com/cycloidio/tfdocs/providers/openstack" "github.com/cycloidio/tfdocs/resource" ) diff --git a/provider/openstack/openstack_test.go b/provider/openstack/openstack_test.go index 97dca50..6f86328 100644 --- a/provider/openstack/openstack_test.go +++ b/provider/openstack/openstack_test.go @@ -3,8 +3,9 @@ package openstack_test import ( "testing" - "github.com/cycloidio/inframap/provider/openstack" "github.com/stretchr/testify/assert" + + "github.com/cycloidio/inframap/provider/openstack" ) func TestResourceInOutNodes(t *testing.T) { diff --git a/prune/prune.go b/prune/prune.go index fed3600..620d454 100644 --- a/prune/prune.go +++ b/prune/prune.go @@ -9,12 +9,13 @@ import ( "strings" "github.com/chr4/pwgen" - "github.com/cycloidio/inframap/errcode" - "github.com/cycloidio/inframap/generate" - "github.com/cycloidio/inframap/provider/factory" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/states/statefile" uuid "github.com/satori/go.uuid" + + "github.com/cycloidio/inframap/errcode" + "github.com/cycloidio/inframap/generate" + "github.com/cycloidio/inframap/provider/factory" ) // reARN matches an arn string diff --git a/tools/tools.go b/tools/tools.go index 6224699..1334987 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools package tools