Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/utils/golang.org/x/m…
Browse files Browse the repository at this point in the history
…od-0.22.0
  • Loading branch information
acabarbaye authored Dec 16, 2024
2 parents 7fdb603 + 685188a commit d09e486
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 32 deletions.
10 changes: 10 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ linters:
- revive
- gocritic
- unconvert
- misspell

linters-settings:
goimports:
Expand All @@ -39,3 +40,12 @@ linters-settings:
disabled: false
arguments:
- "disableStutteringCheck"
misspell:
locale: UK
extra-words:
- typo: "sanetisation"
correction: "sanitisation"
- typo: "sanetise"
correction: "sanitise"
- typo: "sanetising"
correction: "sanitising"
37 changes: 21 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
minimum_pre_commit_version: 1.7.0
repos:
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
description: Fast linters runner for Go.
# Disabling Go module support is necessary to avoid it complaining about a missing go.mod file in the root
entry: env GO111MODULE=off golangci-lint run --config=.golangci.pre-commit.yaml ./...
language: system
types: [go]
pass_filenames: false

- repo: https://github.com/ARMmbed/continuous-delivery-scripts.git
rev: 2.5.0
hooks:
minimum_pre_commit_version: 1.7.0
repos:
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
description: Fast linters runner for Go.
# Disabling Go module support is necessary to avoid it complaining about a missing go.mod file in the root
entry: env GO111MODULE=off golangci-lint run --config=.golangci.pre-commit.yaml ./...
language: system
types: [go]
pass_filenames: false

- repo: https://github.com/golangci/misspell
rev: v0.6.0
hooks:
- id: misspell

- repo: https://github.com/ARMmbed/continuous-delivery-scripts.git
rev: 2.5.0
hooks:
- id: licensing
1 change: 1 addition & 0 deletions changes/202412161019.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:gear: Enforce [misspell](https://pkg.go.dev/github.com/golangci/misspell) linter
5 changes: 1 addition & 4 deletions utils/config/service_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func convertViperError(vErr error) (err error) {
err = fmt.Errorf("%w: %v", commonerrors.ErrUnsupported, vErr.Error())
case commonerrors.CorrespondTo(vErr, "not found"):
err = fmt.Errorf("%w: %v", commonerrors.ErrNotFound, vErr.Error())
case commonerrors.CorrespondTo(vErr, "parsing", "marshaling", "decoding"):
case commonerrors.CorrespondTo(vErr, "parsing", "marshaling", "decoding"): //nolint: misspell // errors are written in American English
err = fmt.Errorf("%w: %v", commonerrors.ErrMarshalling, vErr.Error())
default:
err = fmt.Errorf("%w: %v", commonerrors.ErrUnexpected, vErr.Error())
Expand Down Expand Up @@ -335,9 +335,6 @@ func DetermineConfigurationEnvironmentVariables(appName string, configurationToD
return
}
withoutPrefix = flattenDefaultsMap(withoutPrefix)
if err != nil {
return
}

defaults = make(map[string]interface{})
for key, value := range withoutPrefix {
Expand Down
2 changes: 1 addition & 1 deletion utils/config/service_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func TestGenerateEnvFile_Defaults(t *testing.T) {

// Test that you can load the struct with viper then generate the env file
func TestGenerateEnvFile_Populated(t *testing.T) {
// Load configuartion using viper
// Load configuration using viper
os.Clearenv()
configTest := &DummyConfiguration{}
defaults := DefaultDummyConfiguration()
Expand Down
2 changes: 1 addition & 1 deletion utils/environment/envvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestParseEnvironmentVariable(t *testing.T) {

func TestEnvVar_ParseEnvironmentVariables(t *testing.T) {
username := faker.Username()
entries := []string{"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/65357/bus", "HOME=/home/josjen01", faker.UUIDHyphenated(), "EDITOR=hx", "LOGNAME=josjen01", "DISPLAY=:0", "SSH_AUTH_SOCK=/tmp/ssh-eBrdhiWnaFYp/agent.4969", "KRB5CCNAME=FILE:/tmp/krb5cc_65357_XLwjEE", "GPG_AGENT_INFO=/run/user/65357/gnupg/S.gpg-agent:0:1", "LANGUAGE=en_US:", "USER=" + username, "XDG_RUNTIME_DIR=/run/user/65357", "WINDOWID=54525966", "KITTY_PID=151539", "CMSIS_PACK_ROOT=/home/josjen01/.cache/arm/packs", "XDG_SESSION_ID=4", "XDG_CONFIG_DIRS=/etc/xdg/xdg-i3:/etc/xdg", faker.Name(), "GDMSESSION=i3", "WINDOWPATH=2", "SHLVL=1", "DESKTOP_SESSION=i3", "GTK_MODULES=gail:atk-bridge", "LANG=en_US.UTF-8", "FZF_DEFAULT_OPTS=--color dark,hl:#d65d08,hl+:#d65d08,fg+:#282828,bg+:#282828,fg+:#b58900,info:#ebdbb2,prompt:#268bd2,pointer:#2aa198,marker:#d33682,spinner:#268bd2 -m", "XDG_SESSION_DESKTOP=i3", "XDG_SESSION_TYPE=x11", "KITTY_PUBLIC_KEY=1:^1R-7)Aw|}io+D^KqaYVJF0R&a!f&dpX}gSSEIH&", "XDG_SEAT=seat0", "TERM=xterm-kitty", "XDG_DATA_DIRS=/usr/share/i3:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", "DESKTOP_STARTUP_ID=i3/kitty/4969-5-e126332_TIME31895328", "SHELL=/bin/bash", "KITTY_WINDOW_ID=6", "QT_ACCESSIBILITY=1", "COLORTERM=truecolor", "TERMINFO=/home/josjen01/.local/kitty.app/lib/kitty/terminfo", "SSH_AGENT_PID=5033", "XDG_SESSION_CLASS=user", "KITTY_INSTALLATION_DIR=/home/josjen01/.local/kitty.app/lib/kitty", "XDG_CURRENT_DESKTOP=i3", "MANPATH=:/home/josjen01/.local/kitty.app/share/man::/opt/puppetlabs/puppet/share/man", "XAUTHORITY=/run/user/65357/gdm/Xauthority", "CMSIS_COMPILER_ROOT=/etc/cmsis-build", "XDG_VTNR=2", "I3SOCK=/run/user/65357/i3/ipc-socket.4969", "USERNAME=josjen01", "PATH=/usr/local/go/bin:/bin:/home/josjen01/.local/bin:/home/josjen01/go/bin:/home/josjen01/.cargo/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin", "PWD=/home/josjen01/Git/golang-utils/utils/environment", "GOCOVERDIR=/tmp/go-build1026478377/b001/gocoverdir", "test1=Accusantium voluptatem aut sit perferendis consequatur", "test2=Perferendis aut accusantium voluptatem sit consequatur.", faker.Word()}
entries := []string{"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/65357/bus", "HOME=/home/josjen01", faker.UUIDHyphenated(), "EDITOR=hx", "LOGNAME=josjen01", "DISPLAY=:0", "SSH_AUTH_SOCK=/tmp/ssh-eBrdhiWnaFYp/agent.4969", "KRB5CCNAME=FILE:/tmp/krb5cc_65357_XLwjEE", "GPG_AGENT_INFO=/run/user/65357/gnupg/S.gpg-agent:0:1", "LANGUAGE=en_US:", "USER=" + username, "XDG_RUNTIME_DIR=/run/user/65357", "WINDOWID=54525966", "KITTY_PID=151539", "CMSIS_PACK_ROOT=/home/josjen01/.cache/arm/packs", "XDG_SESSION_ID=4", "XDG_CONFIG_DIRS=/etc/xdg/xdg-i3:/etc/xdg", faker.Name(), "GDMSESSION=i3", "WINDOWPATH=2", "SHLVL=1", "DESKTOP_SESSION=i3", "GTK_MODULES=gail:atk-bridge", "LANG=en_US.UTF-8", "FZF_DEFAULT_OPTS=--colour dark,hl:#d65d08,hl+:#d65d08,fg+:#282828,bg+:#282828,fg+:#b58900,info:#ebdbb2,prompt:#268bd2,pointer:#2aa198,marker:#d33682,spinner:#268bd2 -m", "XDG_SESSION_DESKTOP=i3", "XDG_SESSION_TYPE=x11", "KITTY_PUBLIC_KEY=1:^1R-7)Aw|}io+D^KqaYVJF0R&a!f&dpX}gSSEIH&", "XDG_SEAT=seat0", "TERM=xterm-kitty", "XDG_DATA_DIRS=/usr/share/i3:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", "DESKTOP_STARTUP_ID=i3/kitty/4969-5-e126332_TIME31895328", "SHELL=/bin/bash", "KITTY_WINDOW_ID=6", "QT_ACCESSIBILITY=1", "COLOURTERM=truecolour", "TERMINFO=/home/josjen01/.local/kitty.app/lib/kitty/terminfo", "SSH_AGENT_PID=5033", "XDG_SESSION_CLASS=user", "KITTY_INSTALLATION_DIR=/home/josjen01/.local/kitty.app/lib/kitty", "XDG_CURRENT_DESKTOP=i3", "MANPATH=:/home/josjen01/.local/kitty.app/share/man::/opt/puppetlabs/puppet/share/man", "XAUTHORITY=/run/user/65357/gdm/Xauthority", "CMSIS_COMPILER_ROOT=/etc/cmsis-build", "XDG_VTNR=2", "I3SOCK=/run/user/65357/i3/ipc-socket.4969", "USERNAME=josjen01", "PATH=/usr/local/go/bin:/bin:/home/josjen01/.local/bin:/home/josjen01/go/bin:/home/josjen01/.cargo/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin", "PWD=/home/josjen01/Git/golang-utils/utils/environment", "GOCOVERDIR=/tmp/go-build1026478377/b001/gocoverdir", "test1=Accusantium voluptatem aut sit perferendis consequatur", "test2=Perferendis aut accusantium voluptatem sit consequatur.", faker.Word()}
environmentVariables := ParseEnvironmentVariables(entries...)
assert.NotEmpty(t, environmentVariables)
assert.Len(t, environmentVariables, len(entries)-3)
Expand Down
2 changes: 1 addition & 1 deletion utils/filesystem/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func TestStatTimes(t *testing.T) {
for _, fsType := range FileSystemTypes {
t.Run(fmt.Sprintf("%v_for_fs_%v", t.Name(), fsType), func(t *testing.T) {
fs := NewFs(fsType)
tmpFile, err := fs.TouchTempFileInTempDir("test-filetimes-*.txt")
tmpFile, err := fs.TouchTempFileInTempDir("test-file-times-*.txt")
require.NoError(t, err)
defer func() { _ = fs.Rm(tmpFile) }()

Expand Down
2 changes: 1 addition & 1 deletion utils/filesystem/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ type FS interface {
// See os.Open()
GenericOpen(name string) (File, error)
// OpenFile opens a file using the given flags and the given mode.
// OpenFile is the generalized open call
// OpenFile is the generalised open call
// most users will use GenericOpen or Create instead.
// See os.OpenFile
OpenFile(name string, flag int, perm os.FileMode) (File, error)
Expand Down
2 changes: 1 addition & 1 deletion utils/git/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type GitActionConfig struct {
Depth int `mapstructure:"depth"`
// Regerence can be a hash, a branch, or a tag
Reference string `mapstructure:"ref"`
// RecurseSubmodules after the clone is created, initialize all submodules
// RecurseSubmodules after the clone is created, initialise all submodules
// within, using their default settings. This option is ignored if the
// cloned repository does not have a worktree.
RecurseSubmodules bool `mapstructure:"recursive_submodules"`
Expand Down
4 changes: 2 additions & 2 deletions utils/http/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
)

// HTTPClientConfiguration defines the client configuration. It can be used to tweak low level transport
// parameters in order to adapt the client to your usecase.
// parameters in order to adapt the client to your use case.
// If unsure about the values to set, use the DefaultHTTPClientConfiguration or FastHTTPClientConfiguration depending on
// what flow you are dealing with.
type HTTPClientConfiguration struct {
// MaxConnsPerHost optionally limits the total number of
// connections per host, including connections in the dialing,
// connections per host, including connections in the dialling,
// active, and idle states. On limit violation, dials will block.
//
// Zero means no limit.
Expand Down
2 changes: 1 addition & 1 deletion utils/parallelisation/parallelisation.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func RunActionWithTimeoutAndCancelStore(ctx context.Context, timeout time.Durati
}

// RunActionWithParallelCheck runs an action with a check in parallel
// The function performing the check should return true if the check was favorable; false otherwise. If the check did not have the expected result and the whole function would be cancelled.
// The function performing the check should return true if the check was favourable; false otherwise. If the check did not have the expected result and the whole function would be cancelled.
func RunActionWithParallelCheck(ctx context.Context, action func(ctx context.Context) error, checkAction func(ctx context.Context) bool, checkPeriod time.Duration) error {
err := DetermineContextError(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils/reflection/reflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func fetchStructureField(structure interface{}, fieldName string) reflect.Value
// It returns an interface and a boolean, the field's content and a boolean denoting whether or not the field exists.
// If the boolean is false then there is no such field on the structure.
// If the boolean is true but the interface stores "" then the field exists but is not set.
// If the boolean is true and the interface is not emtpy, the field exists and is set.
// If the boolean is true and the interface is not empty, the field exists and is set.
func GetStructField(structure interface{}, fieldName string) (interface{}, bool) {
Field := fetchStructureField(structure, fieldName)
if !Field.IsValid() {
Expand Down
2 changes: 1 addition & 1 deletion utils/serialization/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package serialization
package serialization //nolint:misspell

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion utils/serialization/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package serialization
package serialization //nolint:misspell

import (
"path"
Expand Down
2 changes: 1 addition & 1 deletion utils/signing/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (k *Ed25519Signer) Sign(message []byte) (signature []byte, err error) {

signature, err = k.private.Sign(nil, message, &ed25519.Options{})
if err != nil {
err = fmt.Errorf("%w: error occured whilst signing: %v", commonerrors.ErrUnexpected, err.Error())
err = fmt.Errorf("%w: error occurred whilst signing: %v", commonerrors.ErrUnexpected, err.Error())
return
}

Expand Down

0 comments on commit d09e486

Please sign in to comment.