Copilot commented on code in PR #84: URL: https://github.com/apache/cloudstack-kubernetes-provider/pull/84#discussion_r2560510005
########## .golangci.yml: ########## @@ -1,53 +1,46 @@ -# 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. - -linters-settings: - goheader: - template: |- - * 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. - +version: "2" +run: + modules-download-mode: readonly + issues-exit-code: 1 linters: enable: - goheader - gosec - - gosimple - - govet - - ineffassign - misspell - - staticcheck - - typecheck - - unused - -run: - modules-download-mode: readonly - timeout: 5m - issues-exit-code: 1 + settings: Review Comment: The `settings` key should be nested under `linters`, not at the top level. In golangci-lint v2 configuration format, linter-specific settings should be under `linters.settings`. This configuration should be: ```yaml linters: enable: - goheader - gosec - misspell settings: goheader: template: |- ... ``` ########## Makefile: ########## @@ -53,3 +53,10 @@ docker: ifneq (${GIT_IS_TAG},NOT_A_TAG) docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} apache/cloudstack-kubernetes-provider:${GIT_TAG} endif + +lint: + @(echo "Running golangci-lint...") + golangci-lint run + @(echo "Running gofmt...") + @(echo "gofmt -l"; FMTFILES="$$(gofmt -l .)"; if test -n "$${FMTFILES}"; then echo "Go files that need to be reformatted (use 'go fmt'):\n$${FMTFILES}"; exit 1; fi) Review Comment: The `gofmt -l` command is incorrectly quoted within the shell command. The current structure has `"gofmt -l"` as a quoted string that would be echoed, followed by the actual `gofmt -l` command execution. The echo statement should be: ```makefile @(echo "Running gofmt..."; FMTFILES="$$(gofmt -l .)"; if test -n "$${FMTFILES}"; then echo "Go files that need to be reformatted (use 'go fmt'):\n$${FMTFILES}"; exit 1; fi) ``` Remove the redundant `"gofmt -l"` string from the echo. ```suggestion @(FMTFILES="$$(gofmt -l .)"; if test -n "$${FMTFILES}"; then echo "Go files that need to be reformatted (use 'go fmt'):\n$${FMTFILES}"; exit 1; fi) ``` ########## README.md: ########## @@ -151,13 +151,50 @@ The CCM supports the same cloud-config configuration file format used by [the cs so you can simply point it to that. ```bash -./cloudstack-ccm --cloud-provider external-cloudstack --cloud-config ~/.cloud-config --master k8s-apiserver +./cloudstack-ccm --cloud-provider external-cloudstack --cloud-config ./cloud-config --kubeconfig ~/.kube/config ``` Replace k8s-apiserver with the host name of your Kubernetes development clusters's API server. If you don't have a 'real' CloudStack installation, you can also launch a local [simulator instance](https://hub.docker.com/r/cloudstack/simulator) instead. This is very useful for dry-run testing. +### Debugging + +You can use the VSCode extension [Go](https://marketplace.visualstudio.com/items?itemName=golang.go) to debug the CCM. +Add the following configuration to the `.vscode/launch.json` file use it to launch the CCM. Review Comment: The sentence "Add the following configuration to the `.vscode/launch.json` file use it to launch the CCM" is grammatically incorrect. It should be: "Add the following configuration to the `.vscode/launch.json` file to use it to launch the CCM" or "Add the following configuration to the `.vscode/launch.json` file and use it to launch the CCM" ```suggestion Add the following configuration to the `.vscode/launch.json` file to use it to launch the CCM. ``` ########## .golangci.yml: ########## @@ -1,53 +1,46 @@ -# 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. - -linters-settings: - goheader: - template: |- - * 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. - +version: "2" +run: + modules-download-mode: readonly + issues-exit-code: 1 linters: enable: - goheader - gosec - - gosimple - - govet - - ineffassign - misspell - - staticcheck - - typecheck - - unused - -run: - modules-download-mode: readonly - timeout: 5m - issues-exit-code: 1 + settings: + goheader: + template: |- + * 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. + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ Review Comment: The `exclusions` key is not valid in golangci-lint v2 configuration. The correct key is `issues` with nested `exclude-rules` or `exclude` directives. The configuration should use: ```yaml issues: exclude-generated: lax exclude-dirs: - third_party - builtin - examples ``` Additionally, the `presets` feature should be under `issues.exclude-rules` if you want to exclude specific preset patterns. ```suggestion issues: exclude-generated: lax exclude-dirs: - third_party - builtin - examples # To emulate the old 'presets', add exclude-rules here if needed, e.g.: # exclude-rules: # - path: ".*" # text: "some pattern" ``` ########## .golangci.yml: ########## @@ -1,53 +1,46 @@ -# 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. - -linters-settings: - goheader: - template: |- - * 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. - +version: "2" +run: + modules-download-mode: readonly + issues-exit-code: 1 linters: enable: - goheader - gosec - - gosimple - - govet - - ineffassign - misspell - - staticcheck - - typecheck - - unused - -run: - modules-download-mode: readonly - timeout: 5m - issues-exit-code: 1 + settings: + goheader: + template: |- + * 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. + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ Review Comment: The `formatters.exclusions` section is not valid in golangci-lint v2 configuration. Formatters in golangci-lint are used for output formatting (like `json`, `colored-line-number`, etc.), not for excluding paths. If the intention is to exclude paths from all checks, this should be configured under the `issues` section using `exclude-dirs` or similar directives. ```suggestion ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
