Skip to content

Commit

Permalink
Switch to WalkDir in bundle package
Browse files Browse the repository at this point in the history
Bump Go version to 1.16 to be able to use `WalkDir`.

Switch to `WalkDir` function.
  • Loading branch information
HeavyWombat committed Aug 30, 2021
1 parent d3b548f commit 5f6b547
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
unit:
strategy:
matrix:
go-version: [1.15.x]
go-version: [1.16.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.15.x]
go-version: [1.16.x]
os: [ubuntu-latest]
kubernetes:
# Only v1.20 is currently enabled because of the flakiness in the tests, specifically API calls failing with "etcdserver: request timed out"
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.15.x]
go-version: [1.16.x]
os: [ubuntu-latest]
kubernetes:
# Only v1.20 is currently enabled because of the flakiness in the tests, specifically API calls failing with "etcdserver: request timed out"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
go-version: ^1.16

- name: Check out code into the Go module directory
uses: actions/checkout@v2
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 github.com/shipwright-io/build

go 1.15
go 1.16

require (
github.com/docker/cli v20.10.7+incompatible
Expand Down
2 changes: 1 addition & 1 deletion openshift-ci/Dockerfile.tools
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ WORKDIR /tmp
RUN mkdir -p $GOPATH/bin
RUN mkdir -p /tmp/goroot

RUN curl -Lo go1.15.7.linux-amd64.tar.gz https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz && tar -C /tmp/goroot -xzf go1.15.7.linux-amd64.tar.gz
RUN curl -Lo go1.16.linux-amd64.tar.gz https://dl.google.com/go/go1.16.linux-amd64.tar.gz && tar -C /tmp/goroot -xzf go1.16.linux-amd64.tar.gz
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl $GOPATH/bin/

RUN go get -u github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI
Expand Down
12 changes: 9 additions & 3 deletions pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"bytes"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -144,21 +145,26 @@ func Pack(directory string) (io.Reader, error) {
var tw = tar.NewWriter(&buf)
defer tw.Close()

err := filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {
err := filepath.WalkDir(directory, func(path string, d fs.DirEntry, err error) error {
// Bail out on path errors
if err != nil {
return err
}

// Skip files on the ignore list
if matcher.Match(split(path), info.IsDir()) {
if info.IsDir() {
if matcher.Match(split(path), d.IsDir()) {
if d.IsDir() {
return filepath.SkipDir
}

return nil
}

info, err := d.Info()
if err != nil {
return err
}

header, err := tar.FileInfoHeader(info, path)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion samples/build/build_ko_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
- name: go-flags
value: "-v -mod=vendor -ldflags=-w"
- name: go-version
value: "1.15"
value: "1.16"
- name: package-directory
value: ./cmd/shipwright-build-controller
source:
Expand Down

0 comments on commit 5f6b547

Please sign in to comment.