From 5deff720176b0b755d29baad063dc2b4fd28234c Mon Sep 17 00:00:00 2001 From: Maxim Muzafarov Date: Thu, 21 Jul 2022 09:47:10 +0100 Subject: [PATCH 1/5] Upgrade golangci-lint to 1.47.1 --- .github/workflows/golangci-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b0d4f797..f9b1943a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ jobs: with: go-version: 1.17 - name: golangci-lint - uses: golangci/golangci-lint-action@v3.1.0 + uses: golangci/golangci-lint-action@v3.2.0 with: - version: v1.44.0 + version: v1.47.1 working-directory: ${{matrix.working-directory}} From efedafed9f26b74ac08e14b5b1d29818e601e8b2 Mon Sep 17 00:00:00 2001 From: Maxim Muzafarov Date: Thu, 21 Jul 2022 09:54:04 +0100 Subject: [PATCH 2/5] Define ReadHeaderTimeout to 1 minute (as nginx default does) --- virtualcluster/cmd/vn-agent/app/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virtualcluster/cmd/vn-agent/app/server.go b/virtualcluster/cmd/vn-agent/app/server.go index 0486e1cf..d7c64ced 100644 --- a/virtualcluster/cmd/vn-agent/app/server.go +++ b/virtualcluster/cmd/vn-agent/app/server.go @@ -22,6 +22,7 @@ import ( "fmt" "net/http" "os" + "time" "k8s.io/apiserver/pkg/server/healthz" @@ -98,8 +99,9 @@ func Run(c *config.Config, serverOption *options.ServerOption, stopCh <-chan str } s := &http.Server{ - Addr: fmt.Sprintf(":%d", serverOption.Port), - Handler: handler, + Addr: fmt.Sprintf(":%d", serverOption.Port), + Handler: handler, + ReadHeaderTimeout: time.Minute, TLSConfig: &tls.Config{ ClientAuth: tls.RequestClientCert, MinVersion: tls.VersionTLS12, From 013b959a9df04fd4057d850e7ea16ce6446d5840 Mon Sep 17 00:00:00 2001 From: Maxim Muzafarov Date: Thu, 21 Jul 2022 09:43:45 +0100 Subject: [PATCH 3/5] Enable goheader linter and fix copyright headers --- virtualcluster/.golangci.yml | 26 ++++++++++++++++++- .../pkg/controller/controllers/metrics.go | 16 ++++++++++++ .../pkg/controller/util/net/util.go | 16 ++++++++++++ .../pkg/syncer/resources/configmap/checker.go | 5 ++-- .../pkg/syncer/resources/crd/checker.go | 7 +++-- .../pkg/syncer/resources/crd/controller.go | 3 +++ .../pkg/syncer/resources/endpoints/checker.go | 5 ++-- .../pkg/syncer/resources/namespace/checker.go | 5 ++-- .../persistentvolume/checker_test.go | 3 +++ .../pod/validationplugin/interface.go | 3 +++ .../syncer/resources/service/checker_test.go | 3 +++ .../resources/serviceaccount/checker.go | 5 ++-- .../resources/serviceaccount/checker_test.go | 3 +++ virtualcluster/test/e2e/e2e.go | 3 +++ .../test/e2e/framework/framework.go | 3 +++ .../test/e2e/framework/text_context.go | 3 +++ virtualcluster/test/e2e/framework/util.go | 3 +++ 17 files changed, 101 insertions(+), 11 deletions(-) diff --git a/virtualcluster/.golangci.yml b/virtualcluster/.golangci.yml index ab9ff1ac..d26d677a 100644 --- a/virtualcluster/.golangci.yml +++ b/virtualcluster/.golangci.yml @@ -12,6 +12,7 @@ linters: - gocritic - gocyclo - gofmt + - goheader - goimports - goprintffuncname - gosec @@ -56,6 +57,29 @@ linters-settings: # Controller Runtime - pkg: sigs.k8s.io/controller-runtime alias: ctrl + goheader: + values: + const: + AUTHOR: The Kubernetes Authors + regexp: + LICENSE_YEAR: 20\d\d + SCHEME: http(s)? + # The template use for checking. + # Default: "" + template: |- + Copyright {{ LICENSE_YEAR }} {{ AUTHOR }}. + + Licensed 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 + + {{ SCHEME }}://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. issues: max-same-issues: 0 @@ -120,7 +144,7 @@ issues: text: "appendAssign: append result not assigned to the same slice" run: - timeout: 10m + timeout: 20m skip-files: - "zz_generated.*\\.go$" - ".*conversion.*\\.go$" diff --git a/virtualcluster/pkg/controller/controllers/metrics.go b/virtualcluster/pkg/controller/controllers/metrics.go index 35c5905f..ee789e62 100644 --- a/virtualcluster/pkg/controller/controllers/metrics.go +++ b/virtualcluster/pkg/controller/controllers/metrics.go @@ -1,3 +1,19 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed 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 + + https://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. +*/ + package controllers import ( diff --git a/virtualcluster/pkg/controller/util/net/util.go b/virtualcluster/pkg/controller/util/net/util.go index ffb54ec4..7b658402 100644 --- a/virtualcluster/pkg/controller/util/net/util.go +++ b/virtualcluster/pkg/controller/util/net/util.go @@ -1,3 +1,19 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed 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 + + https://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. +*/ + package net import ( diff --git a/virtualcluster/pkg/syncer/resources/configmap/checker.go b/virtualcluster/pkg/syncer/resources/configmap/checker.go index 694ab6d5..621f90cb 100644 --- a/virtualcluster/pkg/syncer/resources/configmap/checker.go +++ b/virtualcluster/pkg/syncer/resources/configmap/checker.go @@ -1,10 +1,11 @@ /* Copyright 2021 The Kubernetes Authors. - Licensed under the Apache License, Version 2.0 (the "License"); + +Licensed 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 + 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, diff --git a/virtualcluster/pkg/syncer/resources/crd/checker.go b/virtualcluster/pkg/syncer/resources/crd/checker.go index 8a6cf235..604b94a4 100644 --- a/virtualcluster/pkg/syncer/resources/crd/checker.go +++ b/virtualcluster/pkg/syncer/resources/crd/checker.go @@ -1,9 +1,12 @@ /* Copyright 2021 The Kubernetes Authors. - Licensed under the Apache License, Version 2.0 (the "License"); + +Licensed 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 + + 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. diff --git a/virtualcluster/pkg/syncer/resources/crd/controller.go b/virtualcluster/pkg/syncer/resources/crd/controller.go index 1cb46451..d14eaaa1 100644 --- a/virtualcluster/pkg/syncer/resources/crd/controller.go +++ b/virtualcluster/pkg/syncer/resources/crd/controller.go @@ -1,9 +1,12 @@ /* Copyright 2021 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/pkg/syncer/resources/endpoints/checker.go b/virtualcluster/pkg/syncer/resources/endpoints/checker.go index 8d96c6a6..bde9f97a 100644 --- a/virtualcluster/pkg/syncer/resources/endpoints/checker.go +++ b/virtualcluster/pkg/syncer/resources/endpoints/checker.go @@ -1,10 +1,11 @@ /* Copyright 2019 The Kubernetes Authors. - Licensed under the Apache License, Version 2.0 (the "License"); + +Licensed 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 + https://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, diff --git a/virtualcluster/pkg/syncer/resources/namespace/checker.go b/virtualcluster/pkg/syncer/resources/namespace/checker.go index 3c28ac78..eea12667 100644 --- a/virtualcluster/pkg/syncer/resources/namespace/checker.go +++ b/virtualcluster/pkg/syncer/resources/namespace/checker.go @@ -1,10 +1,11 @@ /* Copyright 2019 The Kubernetes Authors. - Licensed under the Apache License, Version 2.0 (the "License"); + +Licensed 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 + 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, diff --git a/virtualcluster/pkg/syncer/resources/persistentvolume/checker_test.go b/virtualcluster/pkg/syncer/resources/persistentvolume/checker_test.go index 18a3f542..f01fa260 100644 --- a/virtualcluster/pkg/syncer/resources/persistentvolume/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/persistentvolume/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/pkg/syncer/resources/pod/validationplugin/interface.go b/virtualcluster/pkg/syncer/resources/pod/validationplugin/interface.go index ccaf0a09..a57e22a4 100644 --- a/virtualcluster/pkg/syncer/resources/pod/validationplugin/interface.go +++ b/virtualcluster/pkg/syncer/resources/pod/validationplugin/interface.go @@ -1,9 +1,12 @@ /* Copyright 2022 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/pkg/syncer/resources/service/checker_test.go b/virtualcluster/pkg/syncer/resources/service/checker_test.go index e36426be..a07a24db 100644 --- a/virtualcluster/pkg/syncer/resources/service/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/service/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/pkg/syncer/resources/serviceaccount/checker.go b/virtualcluster/pkg/syncer/resources/serviceaccount/checker.go index ff80363f..19b739e7 100644 --- a/virtualcluster/pkg/syncer/resources/serviceaccount/checker.go +++ b/virtualcluster/pkg/syncer/resources/serviceaccount/checker.go @@ -1,10 +1,11 @@ /* Copyright 2019 The Kubernetes Authors. - Licensed under the Apache License, Version 2.0 (the "License"); + +Licensed 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 + 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, diff --git a/virtualcluster/pkg/syncer/resources/serviceaccount/checker_test.go b/virtualcluster/pkg/syncer/resources/serviceaccount/checker_test.go index 70f4521d..06df3253 100644 --- a/virtualcluster/pkg/syncer/resources/serviceaccount/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/serviceaccount/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/test/e2e/e2e.go b/virtualcluster/test/e2e/e2e.go index 9279e0c9..16dcf525 100644 --- a/virtualcluster/test/e2e/e2e.go +++ b/virtualcluster/test/e2e/e2e.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/test/e2e/framework/framework.go b/virtualcluster/test/e2e/framework/framework.go index 155b9dc5..cefdb0cb 100644 --- a/virtualcluster/test/e2e/framework/framework.go +++ b/virtualcluster/test/e2e/framework/framework.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/test/e2e/framework/text_context.go b/virtualcluster/test/e2e/framework/text_context.go index 97e5d27c..61c57d6f 100644 --- a/virtualcluster/test/e2e/framework/text_context.go +++ b/virtualcluster/test/e2e/framework/text_context.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/test/e2e/framework/util.go b/virtualcluster/test/e2e/framework/util.go index d3681fbb..8eb64a9d 100644 --- a/virtualcluster/test/e2e/framework/util.go +++ b/virtualcluster/test/e2e/framework/util.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. From 1eb968a7ceb7dfb2491539eccfb4ed8a6c6d073a Mon Sep 17 00:00:00 2001 From: Maxim Muzafarov Date: Thu, 21 Jul 2022 10:44:37 +0100 Subject: [PATCH 4/5] Fix headers in test files --- virtualcluster/pkg/syncer/resources/ingress/checker_test.go | 5 ++++- .../pkg/syncer/resources/priorityclass/checker_test.go | 5 ++++- .../pkg/syncer/resources/storageclass/checker_test.go | 3 +++ virtualcluster/test/e2e/e2e_test.go | 5 ++++- virtualcluster/test/e2e/framework/vc.go | 5 ++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/virtualcluster/pkg/syncer/resources/ingress/checker_test.go b/virtualcluster/pkg/syncer/resources/ingress/checker_test.go index 9723a19a..76aceb30 100644 --- a/virtualcluster/pkg/syncer/resources/ingress/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/ingress/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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 + + https://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. diff --git a/virtualcluster/pkg/syncer/resources/priorityclass/checker_test.go b/virtualcluster/pkg/syncer/resources/priorityclass/checker_test.go index fa10a115..8c6dde75 100644 --- a/virtualcluster/pkg/syncer/resources/priorityclass/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/priorityclass/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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 + + https://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. diff --git a/virtualcluster/pkg/syncer/resources/storageclass/checker_test.go b/virtualcluster/pkg/syncer/resources/storageclass/checker_test.go index 9581e090..89a2c028 100644 --- a/virtualcluster/pkg/syncer/resources/storageclass/checker_test.go +++ b/virtualcluster/pkg/syncer/resources/storageclass/checker_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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. diff --git a/virtualcluster/test/e2e/e2e_test.go b/virtualcluster/test/e2e/e2e_test.go index 8e89c012..b6c1a1d8 100644 --- a/virtualcluster/test/e2e/e2e_test.go +++ b/virtualcluster/test/e2e/e2e_test.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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 + + https://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. diff --git a/virtualcluster/test/e2e/framework/vc.go b/virtualcluster/test/e2e/framework/vc.go index d335f4fd..39d69197 100644 --- a/virtualcluster/test/e2e/framework/vc.go +++ b/virtualcluster/test/e2e/framework/vc.go @@ -1,9 +1,12 @@ /* Copyright 2020 The Kubernetes Authors. + Licensed 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 + + https://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. From 23b650af638944a7208d8452821dc9fe763e55dc Mon Sep 17 00:00:00 2001 From: Maxim Muzafarov Date: Thu, 21 Jul 2022 12:23:21 +0100 Subject: [PATCH 5/5] Fix slow revive rules --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index f9b1943a..8768855d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,5 +19,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.2.0 with: - version: v1.47.1 + version: v1.47.2 working-directory: ${{matrix.working-directory}}