Skip to content

Commit

Permalink
Repo Cleanup (#1101)
Browse files Browse the repository at this point in the history
* house keeping: reordered .gitignore, add gofumpt to tools, added gitattributes for wsl dev, renamed Makefile

* Fix

---------

Co-authored-by: Zhiwei Liang <[email protected]>
Co-authored-by: Zhiwei Liang <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent cbd379d commit a522cc6
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 340 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
33 changes: 16 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
*.dll
*.exe
.DS_Store
example.tf
terraform.tfplan
terraform.tfstate
bin/
modules-dev/
/pkg/
website/.vagrant
website/.bundle
website/build
website/node_modules
.vagrant/
*.backup
./*.tfstate
.terraform/
*.log
*.bak
*~
.*.swp
.idea
*.iml
*.test
*.iml
.vscode

website/vendor
# tf
.terraform/
./*.tfstate
example.tf
terraform.tfplan
terraform.tfstate

# directories
bin/
modules-dev/
/pkg/
.vagrant/

# editors
.vscode
.idea

# Test exclusions
!command/test-fixtures/**/*.tfstate
Expand Down
85 changes: 3 additions & 82 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,98 +12,19 @@ linters-settings:
severity: warning
disabled: true
errcheck:
check-type-assertions: true
check-blank: true
exclude-functions:
- (*github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData).Set
- (*github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceDiff).SetNewComputed

gomoddirectives:
replace-allow-list:
- github.com/linode/linodego

govet:
check-shadowing: true

enable:
- atomicalign
- fieldalignment
enable-all: false
disable:
- shadow
disable-all: false
# golint:
# min-confidence: 0.8
# gocyclo:
# min-complexity: 30
# gocognit:
# min-complexity: 30
dupl:
threshold: 100

linters:
enable-all: true
disable:
- vetshadow
- gocyclo
- unparam
- nakedret
- dupl
- gosec
- gochecknoinits
- gochecknoglobals
- errcheck
- staticcheck
- stylecheck
- wsl
- interfacer
- gomnd

# not compatible with upper stream design
- ireturn

# deprecated linters
- deadcode
- structcheck
- varcheck
- golint
- nosnakecase
- maligned

# TODO(charliekenney23): enable these rules once compliant
- prealloc
- funlen
- whitespace
- godox
- unconvert
- gocognit
- unused
- gosimple
- gocritic
- scopelint

# Not useful because we widely use open-source dependencies.
- depguard

# These ignores have been added to maintain compatibility with the existing codebase.
# These issues should be resolved at a later date.
- wrapcheck
- varnamelen
- nonamedreturns
- nlreturn
- thelper
- predeclared
- nilnil
- ifshort
- goerr113
- errchkjson
- cyclop
- nestif
- maintidx
- forcetypeassert
- exhaustruct
- exhaustivestruct
- exhaustive
- errorlint
- forbidigo
- godot
- gomoddirectives

fast: false
46 changes: 22 additions & 24 deletions makefile → Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
SWEEP?="tf_test,tf-test"
GOFMT_FILES?=$$(find . -name '*.go')
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=linode/...

MARKDOWNLINT_IMG := 06kellyjac/markdownlint-cli
MARKDOWNLINT_TAG := 0.19.0
MARKDOWNLINT_TAG := 0.28.1

ACCTEST_COUNT?=1
ACCTEST_PARALLELISM?=20
ACCTEST_TIMEOUT?=240m
RUN_LONG_TESTS?="false"

.PHONY: build sweep test testacc vet fmt fmtcheck errcheck test-compile

tooldeps:
go generate -tags tools tools/tools.go

lint: fmtcheck
golangci-lint run --timeout 15m0s
lint:
# remove two disabled linters when their errors are addressed
golangci-lint run \
--disable gosimple \
--disable staticcheck \
--timeout 15m0s
tfproviderlint \
-AT001=false \
-AT004=false \
Expand All @@ -29,7 +33,7 @@ docscheck:
-v $$(pwd):/markdown:ro \
$(MARKDOWNLINT_IMG):$(MARKDOWNLINT_TAG) \
--config .markdownlint.yml \
website
docs

sweep:
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
Expand All @@ -38,7 +42,11 @@ sweep:
default: build

build: fmtcheck
go install
# trying to copy .goreleaser.yaml
go build -a -ldflags '-s -extldflags "-static"'

clean:
rm -f terraform-provider-linode

test: fmtcheck
go test -i $(TEST) || exit 1
Expand All @@ -61,23 +69,19 @@ unittest:
go test -v --tags=unit ./linode/...

vet:
@echo "go vet ."
@go vet $$(go list ./...) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
golangci-lint run --disable-all --enable govet ./...

fmt:
gofmt -w $(GOFMT_FILES)
gofumpt -w $(GOFMT_FILES)
gofumpt -w -l .

imports:
golangci-lint run --disable-all --enable goimports ./...

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
golangci-lint run --disable-all --enable gofumpt ./...

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
golangci-lint run --disable-all -E errcheck ./...

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand All @@ -86,9 +90,3 @@ test-compile:
exit 1; \
fi
go test -c $(TEST) $(TESTARGS) -timeout 120m -parallel=2


imports:
goimports -w $(GOFMT_FILES)

.PHONY: build sweep test testacc vet fmt fmtcheck errcheck test-compile
2 changes: 1 addition & 1 deletion docs/resources/object_storage_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The following arguments are supported:

* `force_destroy` - (Optional) Allow the object to be deleted regardless of any legal hold or object lock (defaults to `false`).

* `endpoint` - (Optional) Used with the s3 client to make bucket changes and will be computed automatically if left blank, override for testing/debug purposes.
* `endpoint` - (Optional) Used with the s3 client to make bucket changes and will be computed automatically if left blank, override for testing/debug purposes.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/linode/terraform-provider-linode

go 1.20

require (
github.com/aws/aws-sdk-go v1.47.0
github.com/go-resty/resty/v2 v2.9.1
Expand Down Expand Up @@ -103,5 +105,3 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

go 1.20
1 change: 1 addition & 0 deletions linode/acceptance/test_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ func (t *TRetry) Parallel() {
t.t.Parallel()
}

//lint:ignore U1000 Ignore unused function
func (t *TRetry) private() {}
4 changes: 0 additions & 4 deletions linode/acceptance/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ func GetRegionsWithCaps(capabilities []string) ([]string, error) {

// GetRandomRegionWithCaps gets a random region given a list of region capabilities.
func GetRandomRegionWithCaps(capabilities []string) (string, error) {
rand.Seed(time.Now().UnixNano())

regions, err := GetRegionsWithCaps(capabilities)
if err != nil {
return "", err
Expand All @@ -628,8 +626,6 @@ func GetRandomRegionWithCaps(capabilities []string) (string, error) {

// GetRandomOBJCluster gets a random Object Storage cluster.
func GetRandomOBJCluster() (string, error) {
rand.Seed(time.Now().UnixNano())

client, err := GetTestClient()
if err != nil {
return "", err
Expand Down
11 changes: 8 additions & 3 deletions linode/lke/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ func createResource(ctx context.Context, d *schema.ResourceData, meta interface{
}
d.SetId(strconv.Itoa(cluster.ID))

client.WaitForLKEClusterConditions(ctx, cluster.ID, linodego.LKEClusterPollOptions{
if err := client.WaitForLKEClusterConditions(ctx, cluster.ID, linodego.LKEClusterPollOptions{
TimeoutSeconds: 15 * 60,
}, k8scondition.ClusterHasReadyNode)
}, k8scondition.ClusterHasReadyNode); err != nil {
return diag.FromErr(err)
}
return readResource(ctx, d, meta)
}

Expand Down Expand Up @@ -248,7 +250,10 @@ func deleteResource(ctx context.Context, d *schema.ResourceData, meta interface{
if err != nil {
return diag.Errorf("failed to convert float64 creation timeout to int: %s", err)
}
client.WaitForLKEClusterStatus(ctx, id, "not_ready", timeoutSeconds)
_, err = client.WaitForLKEClusterStatus(ctx, id, "not_ready", timeoutSeconds)
if err != nil {
return diag.FromErr(err)
}
return nil
}

Expand Down
24 changes: 0 additions & 24 deletions scripts/errcheck.sh

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/gofmtcheck.sh

This file was deleted.

Loading

0 comments on commit a522cc6

Please sign in to comment.