This is an automated email from the ASF dual-hosted git repository.

lingsamuel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new e2475cf  feat: add format tool (#885)
e2475cf is described below

commit e2475cf8573f9f1efd6956c0e4e6eab2142b8061
Author: mango <[email protected]>
AuthorDate: Thu Feb 24 16:36:16 2022 +0800

    feat: add format tool (#885)
    
    * feat: add a formatting tool and format project files.
    
    Signed-off-by: mango <[email protected]>
    
    * add a blank line.
    
    Signed-off-by: mango <[email protected]>
    
    * change `fmt` to `update-gofmt`.
    
    Signed-off-by: mango <[email protected]>
---
 .licenserc.yaml                 |  1 +
 CHANGELOG.md                    | 22 +++++++++++++++++-----
 Makefile                        | 14 +++++++-------
 pkg/apisix/resource_test.go     |  4 ++--
 pkg/apisix/route_test.go        |  3 +--
 pkg/apisix/ssl_test.go          |  6 +++---
 pkg/apisix/stream_route_test.go |  6 +++---
 pkg/apisix/upstream_test.go     |  7 +++----
 pkg/types/pod_test.go           |  1 -
 test/e2e/scaffold/httpbin.go    |  5 ++---
 test/e2e/scaffold/k8s.go        |  2 +-
 utils/goimports-reviser.sh      | 33 +++++++++++++++++++++++++++++++++
 12 files changed, 73 insertions(+), 31 deletions(-)

diff --git a/.licenserc.yaml b/.licenserc.yaml
index 070b515..2c8a7ed 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -21,6 +21,7 @@ header:
 
   paths-ignore:
     - 'dist'
+    - 'vendor'
     - 'licenses'
     - '**/*.md'
     - '**/testdata/**'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 939b04e..8510755 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,7 +56,7 @@ In next release(v1.5), custom resource's API version v2 will 
be GA released. Ple
 * We can update the load balancing IP of the Ingress, and it can work in 
various public cloud environments 
[#740](https://github.com/apache/apisix-ingress-controller/pull/740)
 
 Please try out the release binaries and report any issues at
-https://github.com/apache/apisix-ingress-controller/issues.
+<https://github.com/apache/apisix-ingress-controller/issues.>
 
 ### Contributors
 
@@ -81,6 +81,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * zhang lun hai
 
 ### Changes
+
 <details><summary>40 commits</summary>
 <p>
 
@@ -124,6 +125,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 
[`97fdc90`](https://github.com/apache/apisix-ingress-controller/commit/97fdc90e313a71436f016f5c2e6a849495399ff9)
 fix: ignore delete pod cache error msg (#714)
 * 
[`fa27b03`](https://github.com/apache/apisix-ingress-controller/commit/fa27b0318468c0ffab40b8c384a8a6abc056748c)
 chore: fix spelling error in modules.png (#717)
 * 
[`68125e3`](https://github.com/apache/apisix-ingress-controller/commit/68125e3557428dd0e9424a273c977c85fcffc374)
 chore: v1.3 release (#716)
+
 </p>
 </details>
 
@@ -173,7 +175,7 @@ In next release(v1.4), all custom resource versions will be 
upgraded to version
 * Add new metrics `apisix_ingress_controller_check_cluster_health` and 
`apisix_ingress_controller_sync_success_total` 
[#627](https://github.com/apache/apisix-ingress-controller/pull/627)
 
 Please try out the release binaries and report any issues at
-https://github.com/apache/apisix-ingress-controller/issues.
+<https://github.com/apache/apisix-ingress-controller/issues.>
 
 ### Contributors
 
@@ -189,6 +191,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * oliver
 
 ### Changes
+
 <details><summary>27 commits</summary>
 <p>
 
@@ -219,6 +222,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 
[`d537ddc`](https://github.com/apache/apisix-ingress-controller/commit/d537ddc62bfabfe383c0bd402833377003a1d8dc)
 feat: add link check (#635)
 * 
[`d7128a1`](https://github.com/apache/apisix-ingress-controller/commit/d7128a1812053e9341f59f0e9c13c1c513c9db42)
 chore: skip CodeQL if go files have no changes (#636)
 * 
[`d8854c3`](https://github.com/apache/apisix-ingress-controller/commit/d8854c3bf7fefbc54c0d5b00b5ad669044f791f2)
 docs: fix config.json (#628)
+
 </p>
 </details>
 
@@ -247,7 +251,7 @@ This is a **GA** release.
 * **Implement schema API** 
[#601](https://github.com/apache/apisix-ingress-controller/pull/601)
 
 Please try out the release binaries and report any issues at
-https://github.com/apache/apisix-ingress-controller/issues.
+<https://github.com/apache/apisix-ingress-controller/issues.>
 
 ### Contributors
 
@@ -261,6 +265,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 天使莫忆
 
 ### Changes
+
 <details><summary>20 commits</summary>
 <p>
 
@@ -284,6 +289,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 
[`c78c823`](https://github.com/apache/apisix-ingress-controller/commit/c78c8237b9c114e0e5564bd74a6729bdee04259c)
 chore: merge from v1.1 (#583)
 * 
[`e649c50`](https://github.com/apache/apisix-ingress-controller/commit/e649c503ca6ba4103a27fef729f8835b90078a93)
 chore: add udp usage & upgrade the verion of ApisixRoute (#585)
 * 
[`57ec6da`](https://github.com/apache/apisix-ingress-controller/commit/57ec6dafa7b96b8c2fe5c386eedfce74cb581441)
 fix: misspell in FAQ (#577)
+
 </p>
 </details>
 
@@ -302,6 +308,7 @@ Previous release can be found at 
[1.1.0](https://github.com/apache/apisix-ingres
 Welcome to the 1.1.0 release of apisix-ingress-controller!
 
 This is a **GA** release.
+
 - an available Kubernetes cluster (version >= 1.15)
 - an available Apache APISIX (version >= 2.7)
 
@@ -313,7 +320,7 @@ This is a **GA** release.
 * **Support UDP definition** 
[#572](https://github.com/apache/apisix-ingress-controller/pull/572) 
[#576](https://github.com/apache/apisix-ingress-controller/pull/576)
 
 Please try out the release binaries and report any issues at
-https://github.com/apache/apisix-ingress-controller/issues.
+<https://github.com/apache/apisix-ingress-controller/issues.>
 
 ### Contributors
 
@@ -325,6 +332,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * benson211
 
 ### Changes
+
 <details><summary>11 commits</summary>
 <p>
 
@@ -339,6 +347,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 
[`2122d76`](https://github.com/apache/apisix-ingress-controller/commit/2122d76fd28cc7bce54e8f52e2d4c9d04a1e852a)
 docs: clarify installation by Kustomize (#558)
 * 
[`b4a6889`](https://github.com/apache/apisix-ingress-controller/commit/b4a6889e1564be61de6736af32a2075579c9b51f)
 Update default version in Makefile (#556)
 * 
[`f5cc76e`](https://github.com/apache/apisix-ingress-controller/commit/f5cc76ec6ac671772063d38a09f508db71ac2e48)
 chore: remove cancel-workflow.yml since no use (#550)
+
 </p>
 </details>
 
@@ -358,6 +367,7 @@ Previous release can be found at 
[1.0.0](https://github.com/apache/apisix-ingres
 Welcome to the 1.0.0 release of apisix-ingress-controller!
 
 This is the first **GA** release.
+
 - an available Kubernetes cluster (version >= 1.14)
 - an available Apache APISIX (version >= 2.7)
 
@@ -374,7 +384,7 @@ This is the first **GA** release.
 * **Support authentication for ApisixRoute** 
[#528](https://github.com/apache/apisix-ingress-controller/pull/528)
 
 Please try out the release binaries and report any issues at
-https://github.com/apache/apisix-ingress-controller/issues.
+<https://github.com/apache/apisix-ingress-controller/issues.>
 
 ### Contributors
 
@@ -393,6 +403,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 罗泽轩
 
 ### Changes
+
 <details><summary>58 commits</summary>
 <p>
 
@@ -454,6 +465,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
 * 
[`f199cdb`](https://github.com/apache/apisix-ingress-controller/commit/f199cdb5f5bfe3cb5acb19dc1903b1f5f426a353)
 test: add e2e test cases for server-info plugin (#406)
 * 
[`b0a6f3e`](https://github.com/apache/apisix-ingress-controller/commit/b0a6f3edba8a80e10e831ceaf408e43f89632adb)
 fix: typo in apisix_route_v2alpha1.md (#438)
 * 
[`d269a01`](https://github.com/apache/apisix-ingress-controller/commit/d269a01fe69c287cf13a3574d8ce6566c18a306c)
 ci: introduce skywalking-eyes (#430)
+
 </p>
 </details>
 
diff --git a/Makefile b/Makefile
index 749477f..91a5541 100644
--- a/Makefile
+++ b/Makefile
@@ -58,11 +58,6 @@ build-image:
 lint:
        golangci-lint run
 
-### gofmt:                Format all go codes
-.PHONY: gofmt
-gofmt:
-       find . -type f -name "*.go" | xargs gofmt -w -s
-
 ### unit-test:            Run unit test cases
 .PHONY: unit-test
 unit-test:
@@ -193,8 +188,13 @@ update-license:
 ### update-mdlint:        Update markdown files lint rules.
 .PHONY: update-mdlint
 update-mdlint:
-       docker run -it --rm -v $(PWD):/work tmknom/markdownlint '**/*.md' -f 
--ignore node_modules
+       docker run -it --rm -v $(PWD):/work tmknom/markdownlint '**/*.md' -f 
--ignore node_modules --ignore vendor
+
+### gofmt:                Format all go codes
+.PHONY: update-gofmt
+update-gofmt:
+       ./utils/goimports-reviser.sh
 
 ### update-all:           Update all update- rules.
 .PHONY: update-all
-update-all: update-codegen update-license update-mdlint
+update-all: update-codegen update-license update-mdlint update-gofmt
diff --git a/pkg/apisix/resource_test.go b/pkg/apisix/resource_test.go
index c640b97..2c96996 100644
--- a/pkg/apisix/resource_test.go
+++ b/pkg/apisix/resource_test.go
@@ -18,9 +18,9 @@ import (
        "encoding/json"
        "testing"
 
-       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
-
        "github.com/stretchr/testify/assert"
+
+       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 func TestItemUnmarshalJSON(t *testing.T) {
diff --git a/pkg/apisix/route_test.go b/pkg/apisix/route_test.go
index dfce794..67793b3 100644
--- a/pkg/apisix/route_test.go
+++ b/pkg/apisix/route_test.go
@@ -26,9 +26,8 @@ import (
        "strings"
        "testing"
 
-       "golang.org/x/net/nettest"
-
        "github.com/stretchr/testify/assert"
+       "golang.org/x/net/nettest"
 
        "github.com/apache/apisix-ingress-controller/pkg/metrics"
        v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
diff --git a/pkg/apisix/ssl_test.go b/pkg/apisix/ssl_test.go
index 8c2468b..ca62282 100644
--- a/pkg/apisix/ssl_test.go
+++ b/pkg/apisix/ssl_test.go
@@ -27,11 +27,11 @@ import (
        "strings"
        "testing"
 
-       "github.com/apache/apisix-ingress-controller/pkg/metrics"
-       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
-
        "github.com/stretchr/testify/assert"
        "golang.org/x/net/nettest"
+
+       "github.com/apache/apisix-ingress-controller/pkg/metrics"
+       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 type fakeAPISIXSSLSrv struct {
diff --git a/pkg/apisix/stream_route_test.go b/pkg/apisix/stream_route_test.go
index 83326fc..dfa669d 100644
--- a/pkg/apisix/stream_route_test.go
+++ b/pkg/apisix/stream_route_test.go
@@ -26,11 +26,11 @@ import (
        "strings"
        "testing"
 
-       "github.com/apache/apisix-ingress-controller/pkg/metrics"
-       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
-
        "github.com/stretchr/testify/assert"
        "golang.org/x/net/nettest"
+
+       "github.com/apache/apisix-ingress-controller/pkg/metrics"
+       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 type fakeAPISIXStreamRouteSrv struct {
diff --git a/pkg/apisix/upstream_test.go b/pkg/apisix/upstream_test.go
index da3a3fc..730f35f 100644
--- a/pkg/apisix/upstream_test.go
+++ b/pkg/apisix/upstream_test.go
@@ -26,12 +26,11 @@ import (
        "strings"
        "testing"
 
-       "github.com/apache/apisix-ingress-controller/pkg/metrics"
-       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
-
        "github.com/stretchr/testify/assert"
-
        "golang.org/x/net/nettest"
+
+       "github.com/apache/apisix-ingress-controller/pkg/metrics"
+       v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
 )
 
 type fakeAPISIXUpstreamSrv struct {
diff --git a/pkg/types/pod_test.go b/pkg/types/pod_test.go
index e9021a5..d32b496 100644
--- a/pkg/types/pod_test.go
+++ b/pkg/types/pod_test.go
@@ -18,7 +18,6 @@ import (
        "testing"
 
        "github.com/stretchr/testify/assert"
-
        corev1 "k8s.io/api/core/v1"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
diff --git a/test/e2e/scaffold/httpbin.go b/test/e2e/scaffold/httpbin.go
index eb15bb1..b508e94 100644
--- a/test/e2e/scaffold/httpbin.go
+++ b/test/e2e/scaffold/httpbin.go
@@ -18,11 +18,10 @@ import (
        "fmt"
        "time"
 
-       "github.com/onsi/ginkgo"
-       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-
        "github.com/gruntwork-io/terratest/modules/k8s"
+       "github.com/onsi/ginkgo"
        corev1 "k8s.io/api/core/v1"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
 var (
diff --git a/test/e2e/scaffold/k8s.go b/test/e2e/scaffold/k8s.go
index d6fde3d..09357cc 100644
--- a/test/e2e/scaffold/k8s.go
+++ b/test/e2e/scaffold/k8s.go
@@ -18,7 +18,6 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "github.com/apache/apisix-ingress-controller/pkg/metrics"
        "io/ioutil"
        "net/http"
        "net/url"
@@ -27,6 +26,7 @@ import (
        "time"
 
        "github.com/apache/apisix-ingress-controller/pkg/apisix"
+       "github.com/apache/apisix-ingress-controller/pkg/metrics"
        v1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
        "github.com/gruntwork-io/terratest/modules/k8s"
        "github.com/gruntwork-io/terratest/modules/retry"
diff --git a/utils/goimports-reviser.sh b/utils/goimports-reviser.sh
new file mode 100755
index 0000000..6221f93
--- /dev/null
+++ b/utils/goimports-reviser.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+go install github.com/incu6us/goimports-reviser/v2@latest
+
+PROJECT_NAME=github.com/apache/apisix-ingress-controller
+while IFS= read -r -d '' file; do
+  goimports-reviser  -file-path "$file" -project-name $PROJECT_NAME
+done <   <(find . -name '*.go' -not -path "./test/*" -not -path 
"./pkg/kube/apisix/*" -print0)
+
+
+PROJECT_NAME=github.com/apache/apisix-ingress-controller/test/e2e
+while IFS= read -r -d '' file; do
+  goimports-reviser  -file-path "$file" -project-name $PROJECT_NAME
+done <   <(find . -name '*.go' -path "./test/*" -print0)

Reply via email to