Skip to content

Commit

Permalink
bump to Go 1.21, lots of cleanup ancient stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
xrstf committed Aug 21, 2023
1 parent 99612ab commit 5a50bba
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 63 deletions.
45 changes: 28 additions & 17 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,41 @@
# See the License for the specific language governing permissions and
# limitations under the License.

project_name: boilerplate

builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.BuildTag={{.Version}} -X main.BuildCommit={{.Commit}} -X main.BuildDate={{.Date}}'
goos:
- linux
- darwin
- freebsd
- linux
- windows
goarch:
- amd64

- '386'
- arm64
ignore:
- goos: darwin
goarch: '386'
- goos: freebsd
goarch: '386'
- goos: windows
goarch: '386'
binary: '{{ .ProjectName }}'
archives:
- id: boilerplate
format: zip
files:
- README.md
- LICENSE

release:
prerelease: true

- format: tar.gz
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
wrap_in_directory: true
strip_parent_binary_folder: true
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-snapshot"
disable: true
2 changes: 1 addition & 1 deletion .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ presubmits:
clone_uri: "ssh://[email protected]/kubermatic-labs/boilerplate.git"
spec:
containers:
- image: golang:1.14-alpine
- image: golang:1.21-alpine
command:
- ./hack/verify-boilerplate.sh
resources:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Due to their public nature, GitHub and mailing lists are not appropriate places

This is a rough outline of what a contributor's workflow looks like:

- Create a topic branch from where you want to base your work (usually master).
- Create a topic branch from where you want to base your work (usually main).
- Make commits of logical units.
- Make sure your commit messages are in the proper format (see below).
- Push your changes to a topic branch in your fork of the repository.
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.17-alpine as builder
FROM golang:1.21-alpine as builder

WORKDIR /app/
COPY . .
RUN go build

FROM alpine:3.13
FROM alpine:3.17

RUN apk add -U --no-cache make bash
COPY --from=builder /app/boilerplate /usr/local/bin/
Expand Down
6 changes: 0 additions & 6 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@
approvers:
- kron4eg
- moadqassem
- moelsayed
- xmudrii
- xrstf
- youssefazrak
- thetechnick

reviewers:
- kron4eg
- moadqassem
- moelsayed
- xmudrii
- xrstf
- youssefazrak
- thetechnick
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Python script.
## Installation

```
go get github.com/kubermatic-labs/boilerplate
go install github.com/kubermatic-labs/boilerplate
```

## Usage
Expand Down
12 changes: 4 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module github.com/kubermatic-labs/boilerplate

go 1.14
go 1.20

require (
github.com/kr/pretty v0.1.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)
require github.com/sirupsen/logrus v1.9.3

require golang.org/x/sys v0.11.0 // indirect
25 changes: 7 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17 changes: 8 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -70,7 +69,7 @@ func (s *stringSlice) String() string {

func (s *stringSlice) Set(value string) error {
if _, err := filepath.Match(value, "test"); err != nil {
return fmt.Errorf("invalid glob pattern: %v", err)
return fmt.Errorf("invalid glob pattern: %w", err)
}

*s = append(*s, value)
Expand Down Expand Up @@ -169,7 +168,7 @@ func processSource(cwd string, source string, log logrus.FieldLogger, boilerplat

rel, err := filepath.Rel(cwd, currentPath)
if err != nil {
return fmt.Errorf("failed to determine relative path of %q: %v", currentPath, err)
return fmt.Errorf("failed to determine relative path of %q: %w", currentPath, err)
}

for _, exclude := range excludes {
Expand Down Expand Up @@ -203,7 +202,7 @@ func processSource(cwd string, source string, log logrus.FieldLogger, boilerplat

ok, err := processFile(currentPath, log.WithField("file", rel), boilerplates)
if err != nil {
return fmt.Errorf("failed to process %q: %v", rel, err)
return fmt.Errorf("failed to process %q: %w", rel, err)
}

if !ok {
Expand All @@ -217,9 +216,9 @@ func processSource(cwd string, source string, log logrus.FieldLogger, boilerplat
}

func processFile(filename string, log logrus.FieldLogger, boilerplates map[string]string) (bool, error) {
fileContent, err := ioutil.ReadFile(filename)
fileContent, err := os.ReadFile(filename)
if err != nil {
return false, fmt.Errorf("failed to read file: %v", err)
return false, fmt.Errorf("failed to read file: %w", err)
}

// determine extension to use to lookup the boilerplate header
Expand Down Expand Up @@ -310,7 +309,7 @@ func getBoilerplateForExtensions(sourceDir string) (map[string]string, error) {

matches, err := filepath.Glob(path.Join(sourceDir, "boilerplate.*.txt"))
if err != nil {
return nil, fmt.Errorf("finding files via glob: %v", err)
return nil, fmt.Errorf("finding files via glob: %w", err)
}

for _, match := range matches {
Expand All @@ -319,9 +318,9 @@ func getBoilerplateForExtensions(sourceDir string) (map[string]string, error) {
return nil, fmt.Errorf("wrong filename for boilerplate file: %q must be \"boilerplate.EXTENSION.txt\"", match)
}

content, err := ioutil.ReadFile(match)
content, err := os.ReadFile(match)
if err != nil {
return nil, fmt.Errorf("reading file: %v", err)
return nil, fmt.Errorf("reading file: %w", err)
}

// map file extension to the boilerplate for the file
Expand Down

0 comments on commit 5a50bba

Please sign in to comment.