Skip to content

Commit

Permalink
Update dependencies (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
jocgir authored Oct 3, 2024
1 parent 38b1275 commit db75c14
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 331 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: 1.23

- uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -37,9 +37,9 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: 1.23

- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand All @@ -53,9 +53,9 @@ jobs:
fetch-depth: 0 # goreleaser needs the whole history to build the release notes
- uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: 1.23

- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: 1.23
- uses: actions/checkout@v4
with:
fetch-depth: 0 # goreleaser needs the whole history to build the release notes

- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
Expand Down
6 changes: 3 additions & 3 deletions auto_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestMain(m *testing.M) {
// We don't want detailled logs in trace (time will always be different)
// We don't want detailed logs in trace (time will always be different)
log.SetFormat("%level:upper%: %message%")
log.SetDefaultConsoleHookLevel(logrus.DebugLevel)
os.Exit(m.Run())
Expand All @@ -39,7 +39,7 @@ func TestRunWithUpdateCheck(t *testing.T) {
latest string
runCount int
restartCount int
expectedlogPattern []string
expectedLogPattern []string
}{
{"lower", "1.20.0", "1.21.0", 0, 1, []string{
`WARNING: Updating .*tgf.test(?:\.exe)? from 1.20.0 ==> 1.21.0`,
Expand All @@ -66,7 +66,7 @@ func TestRunWithUpdateCheck(t *testing.T) {
mockUpdater := setupUpdaterMock(tt.local, tt.latest)
RunWithUpdateCheck(mockUpdater)
fmt.Println(buffer.String())
for _, logPattern := range tt.expectedlogPattern {
for _, logPattern := range tt.expectedLogPattern {
match, err := regexp.MatchString(logPattern, buffer.String())
assert.NoError(t, err)
assert.Truef(t, match, "Output doesn't contains %s", logPattern)
Expand Down
14 changes: 7 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (config *TGFConfig) validate() (errors []error) {
errors = append(errors, fmt.Errorf("unable to check recommended image version %s vs %s: %v", *config.ImageVersion, config.RequiredVersionRange, err))
return
} else if !valid {
errors = append(errors, VersionMistmatchError(fmt.Sprintf("Image %s does not meet the required version range %s", config.GetImageName(), config.RequiredVersionRange)))
errors = append(errors, VersionMismatchError(fmt.Sprintf("Image %s does not meet the required version range %s", config.GetImageName(), config.RequiredVersionRange)))
return
}
}
Expand All @@ -468,7 +468,7 @@ func (config *TGFConfig) ValidateVersion() bool {
switch err := err.(type) {
case ConfigWarning:
log.Warning(err)
case VersionMistmatchError:
case VersionMismatchError:
log.Error(err)
if version == "-" {
// We consider this as a fatal error only if the version has not been explicitly specified on the command line
Expand Down Expand Up @@ -725,10 +725,10 @@ func (e ConfigWarning) Error() string {
return string(e)
}

// VersionMistmatchError is used to describe an out of range version
type VersionMistmatchError string
// VersionMismatchError is used to describe an out of range version
type VersionMismatchError string

func (e VersionMistmatchError) Error() string {
func (e VersionMismatchError) Error() string {
return string(e)
}

Expand Down Expand Up @@ -848,12 +848,12 @@ func (config *TGFConfig) DoUpdate(url string) (err error) {
return
}

// GetLastRefresh get the lastime the tgf update file was updated
// GetLastRefresh get the last time the tgf update file was updated
func (config *TGFConfig) GetLastRefresh(autoUpdateFile string) time.Duration {
return lastRefresh(autoUpdateFile)
}

// SetLastRefresh set the lastime the tgf update file was updated
// SetLastRefresh set the last time the tgf update file was updated
func (config *TGFConfig) SetLastRefresh(autoUpdateFile string) {
touchImageRefresh(autoUpdateFile)
}
5 changes: 3 additions & 2 deletions config_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package main
import (
"bytes"
"fmt"
"github.com/coveooss/gotemplate/v3/yaml"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"

"github.com/coveooss/gotemplate/v3/yaml"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -78,5 +79,5 @@ func TestConfigDump_isValidYAML(t *testing.T) {
})

// --config-dump output can be redirected to a file, so it must be valid YAML.
assert.NoError(t, yaml.UnmarshalStrict([]byte(output), &TGFConfig{}))
assert.NoError(t, yaml.Unmarshal([]byte(output), &TGFConfig{}))
}
11 changes: 6 additions & 5 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/coveooss/multilogger/reutils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
types_image "github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
"github.com/fatih/color"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -366,7 +367,7 @@ func (docker *dockerConfig) prune(images ...string) {
for _, image := range images {
filters := filters.NewArgs()
filters.Add("reference", image)
if images, err := cli.ImageList(ctx, types.ImageListOptions{Filters: filters}); err == nil {
if images, err := cli.ImageList(ctx, types_image.ListOptions{Filters: filters}); err == nil {
for _, image := range images {
actual := getActualImageVersionFromImageID(image.ID)
if actual == "" {
Expand Down Expand Up @@ -396,7 +397,7 @@ func (docker *dockerConfig) prune(images ...string) {

func deleteImage(id string) {
cli, ctx := getDockerClient()
items, err := cli.ImageRemove(ctx, id, types.ImageRemoveOptions{})
items, err := cli.ImageRemove(ctx, id, types_image.RemoveOptions{})
if err != nil {
log.Error(err)
}
Expand All @@ -418,7 +419,7 @@ func (docker *dockerConfig) GetActualImageVersion() string {
func validateDockerVersion(version string) (bool, error) {
v, err := semver.ParseTolerant(version)
if err != nil {
return false, fmt.Errorf("Cannot parse %s: %w", version, err)
return false, fmt.Errorf("cannot parse %s: %w", version, err)
}

expectedRange, err := semver.ParseRange(allowedDockerVersions)
Expand Down Expand Up @@ -451,12 +452,12 @@ func getDockerClient() (*client.Client, context.Context) {
var dockerClient *client.Client
var dockerContext context.Context

func getImageSummary(imageName string) *types.ImageSummary {
func getImageSummary(imageName string) *types_image.Summary {
cli, ctx := getDockerClient()
// Find image
filters := filters.NewArgs()
filters.Add("reference", imageName)
images, err := cli.ImageList(ctx, types.ImageListOptions{Filters: filters})
images, err := cli.ImageList(ctx, types_image.ListOptions{Filters: filters})
if err != nil {
log.Errorf("unable to retrieve image summary of %s: %s", imageName, err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions docker_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package main
Expand Down
1 change: 1 addition & 0 deletions docker_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package main
Expand Down
Loading

0 comments on commit db75c14

Please sign in to comment.