Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to set go1.20 in go.mod and upgrade golangci-lint #3073

Merged
merged 3 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: golangci-lint

on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: '1.20'
check-latest: true

- name: golangci-lint
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
with:
version: v1.52
args: --timeout=15m
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ linters-settings:
- hexLiteral
- httpNoBody
- ifElseChain
- ioutilDeprecated
- methodExprCall
- newDeref
- octalLiteral
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ verify-published-rpms: ## Ensure rpms have been published

##@ Verify

.PHONY: verify verify-boilerplate verify-build verify-dependencies verify-golangci-lint verify-go-mod
.PHONY: verify verify-boilerplate verify-build verify-dependencies verify-go-mod

verify: release-tools verify-boilerplate verify-build verify-dependencies verify-golangci-lint verify-go-mod ## Runs verification scripts to ensure correct execution
verify: release-tools verify-boilerplate verify-build verify-dependencies verify-go-mod ## Runs verification scripts to ensure correct execution

verify-boilerplate: ## Runs the file header check
./hack/verify-boilerplate.sh
Expand All @@ -49,9 +49,6 @@ verify-dependencies: ## Runs zeitgeist to verify dependency versions
verify-go-mod: ## Runs the go module linter
./hack/verify-go-mod.sh

verify-golangci-lint: ## Runs all golang linters
./hack/verify-golangci-lint.sh

##@ Tests

.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion cmd/ci-reporter/cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var githubCmd = &cobra.Command{
}

// look for token in environment variables & create a github client
func setGithubConfig(cmd *cobra.Command, args []string) {
func setGithubConfig(_ *cobra.Command, _ []string) {
cfg.GithubToken = env.Default("GITHUB_TOKEN", "")
if cfg.GithubToken == "" {
logrus.Fatal("Please specify your Github access token via the environment variable 'GITHUB_TOKEN' to generate a ci-report")
Expand Down
4 changes: 2 additions & 2 deletions cmd/ci-reporter/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func PrintReporterData(cfg *Config, reports *CIReportDataFields) error {
// print report in table format, (short table differs)
for _, r := range *reports {
// write header
_, err := out.WriteString(fmt.Sprintf("\n%s REPORT\n\n", strings.ToUpper(string(r.Info.Name))))
_, err := fmt.Fprintf(out, "\n%s REPORT\n\n", strings.ToUpper(string(r.Info.Name)))
if err != nil {
return fmt.Errorf("could not write to output stream: %w", err)
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func PrintReporterData(cfg *Config, reports *CIReportDataFields) error {
for category, categoryCount := range countCategories {
categoryCounts += fmt.Sprintf("%s:%d ", category, categoryCount)
}
if _, err := out.WriteString(fmt.Sprintf("\nSUMMARY - Total:%d %s\n", len(data), categoryCounts)); err != nil {
if _, err := fmt.Fprintf(out, "\nSUMMARY - Total:%d %s\n", len(data), categoryCounts); err != nil {
return fmt.Errorf("could not write to output stream: %w", err)
}
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/krel/cmd/sign_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func init() {
signCmd.AddCommand(signImagesCmd)
}

func runSignImages(signOpts *signOptions, args []string) error { //nolint:unparam // TODO: implement me :)
// TODO: implement me :)
func runSignImages(signOpts *signOptions, args []string) error { //nolint:revive,unparam // keeping the parameters for reference
logrus.Info("Not implemented")

return nil
Expand Down
14 changes: 4 additions & 10 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies:
match: "GO_MAJOR_VERSION: '\\d+.\\d+'"

- name: "golang: go.mod"
version: 1.19
version: 1.20
refPaths:
- path: go.mod
match: go \d+.\d+
Expand Down Expand Up @@ -370,16 +370,10 @@ dependencies:

# golangci-lint-version
- name: "golangci-lint"
version: 1.51.0
refPaths:
- path: hack/verify-golangci-lint.sh
match: VERSION=v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?

- name: "golangci-lint-checksum"
version: 0e09dedc7e35f511b7924b885e50d7fe48eef25bec78c86f22f5b5abd24976cc
version: v1.52
refPaths:
- path: hack/verify-golangci-lint.sh
match: INSTALL_CHECKSUM
- path: .github/workflows/lint.yml
match: "version: v\\d+.\\d+?\\.?(\\d+)?"

# Base images
- name: "Debian: codename (default)"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module k8s.io/release

go 1.19
go 1.20

require (
cloud.google.com/go/storage v1.30.1
Expand Down
52 changes: 0 additions & 52 deletions hack/verify-golangci-lint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion images/build/go-runner/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module k8s.io/release/images/build/go-runner

go 1.19
go 1.20
2 changes: 1 addition & 1 deletion packages/deb/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module k8s.io/release/packages/deb

go 1.19
go 1.20

require github.com/blang/semver/v4 v4.0.0
6 changes: 3 additions & 3 deletions pkg/anago/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ func (d *defaultReleaseImpl) ValidateImages(
}

func (d *defaultReleaseImpl) PublishVersion(
buildType, version, buildDir, bucket, gcsRoot string,
versionMarkers []string,
privateBucket, fast bool,
buildType, version, buildDir, bucket, gcsRoot string, //nolint: revive,gocritic
versionMarkers []string, //nolint: revive,gocritic
privateBucket, fast bool, //nolint: revive,gocritic
) error {
return release.
NewPublisher().
Expand Down
2 changes: 1 addition & 1 deletion pkg/build/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func (bi *Instance) PushContainerImages() error {
// TODO: Investigate if it's worthwhile to use any of the bi.objStore.Get*Path()
//
// functions here or create a new one to populate staging paths
func (bi *Instance) CopyStagedFromGCS(stagedBucket, buildVersion string) error {
func (bi *Instance) CopyStagedFromGCS(stagedBucket, buildVersion string) error { //nolint:revive // keeping the parameters for reference
logrus.Info("Copy staged release artifacts from GCS")

bi.objStore.SetOptions(
Expand Down
4 changes: 2 additions & 2 deletions pkg/cve/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (impl *defaultClientImplementation) CheckID(cveID string) error {

// ValidateCVEData checks a cve map
func (impl *defaultClientImplementation) ValidateCVEMap(
cveID, path string, opts *ClientOptions,
cveID, path string, _ *ClientOptions,
) (err error) {
// Parse the data map
maps, err := notes.ParseReleaseNotesMap(path)
Expand Down Expand Up @@ -225,7 +225,7 @@ func (impl *defaultClientImplementation) ValidateCVEMap(
}

// CreateEmptyFile creates an empty CVE map
func (impl *defaultClientImplementation) CreateEmptyFile(cve string, opts *ClientOptions) (
func (impl *defaultClientImplementation) CreateEmptyFile(cve string, _ *ClientOptions) (
file *os.File, err error,
) {
if err := impl.CheckID(cve); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubecross/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate . impl
type impl interface {
GetURLResponse(url string, trim bool) (string, error)
GetURLResponse(url string) (string, error)
}

type defaultImpl struct{}

func (*defaultImpl) GetURLResponse(url string, trim bool) (string, error) {
func (*defaultImpl) GetURLResponse(url string) (string, error) {
content, err := http.NewAgent().Get(url)
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecross/kubecross.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (k *KubeCross) ForBranch(branch string) (string, error) {
)

url := fmt.Sprintf("%s/%s/%s", baseURL, branch, versionPath)
version, err := k.impl.GetURLResponse(url, true)
version, err := k.impl.GetURLResponse(url)
if err != nil {
return "", fmt.Errorf("get URL response: %w", err)
}
Expand Down
18 changes: 8 additions & 10 deletions pkg/kubecross/kubecrossfakes/fake_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/packages/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (

var errTest = errors.New("")

func TestBuild(t *testing.T) {}

func TestRelease(t *testing.T) {
t.Parallel()
logrus.SetOutput(io.Discard)
Expand Down
2 changes: 1 addition & 1 deletion pkg/release/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (*defaultImageImpl) SignImage(signer *sign.Signer, reference string) error
return err
}

func (*defaultImageImpl) VerifyImage(signer *sign.Signer, reference string) error {
func (*defaultImageImpl) VerifyImage(_ *sign.Signer, _ string) error {
// TODO: bypassing this for now due to the fail in the promotion process
// that sign the images. We will release the Feb/2023 patch releases without full
// signatures but we will sign those in a near future in a deatached process
Expand Down