Skip to content

Commit

Permalink
feat: add format tool (#885)
Browse files Browse the repository at this point in the history
* feat: add a formatting tool and format project files.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* add a blank line.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* change `fmt` to `update-gofmt`.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>
  • Loading branch information
mangoGoForward committed Feb 24, 2022
1 parent d30bef5 commit e2475cf
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 31 deletions.
1 change: 1 addition & 0 deletions .licenserc.yaml
Expand Up @@ -21,6 +21,7 @@ header:

paths-ignore:
- 'dist'
- 'vendor'
- 'licenses'
- '**/*.md'
- '**/testdata/**'
Expand Down
22 changes: 17 additions & 5 deletions CHANGELOG.md
Expand Up @@ -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

Expand All @@ -81,6 +81,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
* zhang lun hai

### Changes

<details><summary>40 commits</summary>
<p>

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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

Expand All @@ -189,6 +191,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
* oliver

### Changes

<details><summary>27 commits</summary>
<p>

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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

Expand All @@ -261,6 +265,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
* 天使莫忆

### Changes

<details><summary>20 commits</summary>
<p>

Expand All @@ -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>

Expand All @@ -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)

Expand All @@ -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

Expand All @@ -325,6 +332,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
* benson211

### Changes

<details><summary>11 commits</summary>
<p>

Expand All @@ -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>

Expand All @@ -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)

Expand All @@ -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

Expand All @@ -393,6 +403,7 @@ https://github.com/apache/apisix-ingress-controller/issues.
* 罗泽轩

### Changes

<details><summary>58 commits</summary>
<p>

Expand Down Expand Up @@ -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>

Expand Down
14 changes: 7 additions & 7 deletions Makefile
Expand Up @@ -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:
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions pkg/apisix/resource_test.go
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/apisix/route_test.go
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apisix/ssl_test.go
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/apisix/stream_route_test.go
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions pkg/apisix/upstream_test.go
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/types/pod_test.go
Expand Up @@ -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"
)
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/scaffold/httpbin.go
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/scaffold/k8s.go
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/apache/apisix-ingress-controller/pkg/metrics"
"io/ioutil"
"net/http"
"net/url"
Expand All @@ -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"
Expand Down
33 changes: 33 additions & 0 deletions 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)

0 comments on commit e2475cf

Please sign in to comment.