Skip to content
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
2 changes: 1 addition & 1 deletion crypto/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (c digestImpl) Verify(reader io.Reader) error {
func (m digestImpl) VerifyFilePath(filePath string, fs boshsys.FileSystem) error {
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
if err != nil {
return bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
return bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
}
defer func() {
_ = file.Close()
Expand Down
2 changes: 1 addition & 1 deletion crypto/digest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var _ = Describe("digestImpl", func() {

err := digest.VerifyFilePath(file.Name(), fileSystem)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal(fmt.Sprintf("Calculating digest of '%s': nope", file.Name())))
Expect(err.Error()).To(Equal(fmt.Sprintf("calculating digest of '%s': nope", file.Name())))
})
})

Expand Down
10 changes: 5 additions & 5 deletions crypto/multiple_digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ParseMultipleDigest(json string) (MultipleDigest, error) {
func NewMultipleDigestFromPath(filePath string, fs boshsys.FileSystem, algos []Algorithm) (MultipleDigest, error) {
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
if err != nil {
return MultipleDigest{}, bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
return MultipleDigest{}, bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
}
defer func() {
_ = file.Close()
Expand Down Expand Up @@ -94,7 +94,7 @@ func (m MultipleDigest) Verify(reader io.Reader) error {
func (m MultipleDigest) VerifyFilePath(filePath string, fs boshsys.FileSystem) error {
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
if err != nil {
return bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
return bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
}
defer func() {
_ = file.Close()
Expand All @@ -104,7 +104,7 @@ func (m MultipleDigest) VerifyFilePath(filePath string, fs boshsys.FileSystem) e

func (m MultipleDigest) validate() error {
if len(m.digests) == 0 {
return errors.New("Expected to find at least one digest") //nolint:staticcheck
return errors.New("expected to find at least one digest")
}

algosUsed := map[string]struct{}{}
Expand Down Expand Up @@ -192,7 +192,7 @@ func (m MultipleDigest) parseMultipleDigestString(multipleDigest string) (Multip
}

if len(digests) == 0 {
return MultipleDigest{}, errors.New("No digest algorithm found. Supported algorithms: sha1, sha256, sha512") //nolint:staticcheck
return MultipleDigest{}, errors.New("no digest algorithm found. Supported algorithms: sha1, sha256, sha512")
}

return MultipleDigest{digests: digests}, nil
Expand All @@ -213,7 +213,7 @@ func (MultipleDigest) parseDigestString(digest string) (Digest, error) {

for _, piece := range pieces {
if !isStringAlphanumeric(piece) {
return nil, errors.New("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters.") //nolint:staticcheck
return nil, errors.New("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters")
}
}

Expand Down
16 changes: 8 additions & 8 deletions crypto/multiple_digest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ var _ = Describe("MultipleDigest", func() {
It("returns error if unmarshalling fails", func() {
_, err := ParseMultipleDigest("")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
Expect(err.Error()).To(Equal("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
})
It("returns error if digest contains non-alphanumeric characters", func() {
_, err := ParseMultipleDigest("sha1:!")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
})

It("returns error if algorithm key contains non-alphanumeric characters", func() {
_, err := ParseMultipleDigest("d!m!tr3:abc")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
})

It("returns error if algorithm key is empty", func() {
_, err := ParseMultipleDigest(":")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
})
})

Expand Down Expand Up @@ -97,7 +97,7 @@ var _ = Describe("MultipleDigest", func() {

err := digest.VerifyFilePath(file.Name(), fileSystem)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal(fmt.Sprintf("Calculating digest of '%s': nope", file.Name())))
Expect(err.Error()).To(Equal(fmt.Sprintf("calculating digest of '%s': nope", file.Name())))
})
})

Expand All @@ -106,7 +106,7 @@ var _ = Describe("MultipleDigest", func() {
It("returns error", func() {
err := MultipleDigest{}.Verify(strings.NewReader("desired content"))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Expected to find at least one digest"))
Expect(err.Error()).To(Equal("expected to find at least one digest"))
})
})

Expand Down Expand Up @@ -461,13 +461,13 @@ var _ = Describe("MultipleDigest", func() {
It("returns an error if the JSON does not contain any digests", func() {
err := json.Unmarshal([]byte(`""`), &digest)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
Expect(err.Error()).To(ContainSubstring("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
})

It("returns an error if the JSON contains only semicolon", func() {
err := json.Unmarshal([]byte(`";"`), &digest)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
Expect(err.Error()).To(ContainSubstring("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
})
})
})
6 changes: 2 additions & 4 deletions crypto/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QAOSxgrLBblGLWcDF9fjMeYaUnI34pHviCKeVxfgsxDR+Jg11F78sPdYLOF6ipBe

certPool, err := crypto.CertPoolFromPEM([]byte(caCert))
Expect(err).ToNot(HaveOccurred())
Expect(certPool.Subjects()[0]).To(ContainSubstring("Internet Widgits Pty Ltd")) //nolint:staticcheck
Expect(certPool).ToNot(BeNil())
})

It("returns error if PEM formatted block is invalid", func() {
Expand Down Expand Up @@ -133,9 +133,7 @@ nH9ttalAwSLBsobVaK8mmiAdtAdx+CmHWrB4UNxCPYasrt5A6a9A9SiQ2dLd

certPool, err := crypto.CertPoolFromPEM([]byte(caCert))
Expect(err).ToNot(HaveOccurred())
Expect(len(certPool.Subjects())).To(Equal(2)) //nolint:staticcheck
Expect(certPool.Subjects()[0]).To(ContainSubstring("Internet Widgits Pty Ltd")) //nolint:staticcheck
Expect(certPool.Subjects()[1]).To(ContainSubstring("Cloud Foundry")) //nolint:staticcheck
Expect(certPool).ToNot(BeNil())
})
})
})
2 changes: 1 addition & 1 deletion errors/multi_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewMultiError(errors ...error) error {
}

func (e MultiError) Error() string {
errors := make([]string, len(e.Errors), len(e.Errors)) //nolint:staticcheck
errors := make([]string, len(e.Errors))
for i, err := range e.Errors {
errors[i] = err.Error()
}
Expand Down
4 changes: 1 addition & 3 deletions fileutil/tarball_compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ func (c tarballCompressor) CompressSpecificFilesInDir(dir string, files []string
args = append([]string{"--no-mac-metadata"}, args...)
}

for _, file := range files { //nolint:staticcheck
args = append(args, file)
}
args = append(args, files...)

_, _, _, err = c.cmdRunner.RunCommand("tar", args...)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion httpclient/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func scrubEndpointQuery(endpoint string) string {
}

query := parsedURL.Query()
for key, _ := range query { //nolint:staticcheck
for key := range query {
query[key] = []string{"<redacted>"}
}

Expand Down
1 change: 0 additions & 1 deletion httpclient/mutual_tls_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func NewMutualTLSClient(identity tls.Certificate, caCertPool *x509.CertPool, ser
)

clientConfig := tlsConfig.Client(tlsconfig.WithAuthority(caCertPool))
clientConfig.BuildNameToCertificate() //nolint:staticcheck
clientConfig.ServerName = serverName

return &http.Client{
Expand Down
2 changes: 1 addition & 1 deletion logger/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var _ = Describe("Logger", func() {
tick := time.NewTicker(WriteInterval / 10)
defer tick.Stop()
go func() {
for _ = range tick.C { //nolint:staticcheck
for range tick.C {
logger.Debug("NEW", "new")
}
}()
Expand Down
2 changes: 1 addition & 1 deletion logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Levelify(levelString string) (LogLevel, error) {
level, ok := levels[upperLevelString]
if !ok {
expected := strings.Join(levelKeys, ", ")
return level, fmt.Errorf("Unknown LogLevel string '%s', expected one of [%s]", levelString, expected) //nolint:staticcheck
return level, fmt.Errorf("unknown LogLevel string '%s', expected one of [%s]", levelString, expected)
}
return level, nil
}
Expand Down
4 changes: 2 additions & 2 deletions logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ var _ = Describe("Levelify", func() {
It("errors on unknown input", func() {
_, err := Levelify("unknown")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Unknown LogLevel string 'unknown', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))
Expect(err.Error()).To(Equal("unknown LogLevel string 'unknown', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))

_, err = Levelify("")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Unknown LogLevel string '', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))
Expect(err.Error()).To(Equal("unknown LogLevel string '', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))
})
})

Expand Down
2 changes: 1 addition & 1 deletion main/verify_multidigest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var _ = Describe("VerifyMultidigest", func() {
session, err := runVerifyMultidigest("create-multi-digest", "sha1", "potato")
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(gexec.Exit(1))
Eventually(session.Err).Should(gbytes.Say("Calculating digest of 'potato': open potato:"))
Eventually(session.Err).Should(gbytes.Say("calculating digest of 'potato': open potato:"))
})

It("exits 1 when the algorithm is unknown", func() {
Expand Down
2 changes: 1 addition & 1 deletion property/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func BuildMap(rawProperties map[interface{}]interface{}) (Map, error) {
// BuildList creates a new property List from an slice of interface{}, erroring if any elements are maps with non-string keys.
// Slices in the property List are converted to property Lists. Maps in the property List are converted to property Maps.
func BuildList(rawProperties []interface{}) (List, error) {
result := make(List, len(rawProperties), len(rawProperties)) //nolint:staticcheck
result := make(List, len(rawProperties))

for i, val := range rawProperties {
convertedVal, err := Build(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ func main() {
fmt.Printf("child_pid=%d\n", os.Getpid())

sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGKILL) //nolint:staticcheck
signal.Notify(sigCh, syscall.SIGTERM)

go func() {
for {
switch <-sigCh {
case syscall.SIGTERM:
fmt.Printf("Child received SIGTERM\n")
case syscall.SIGKILL:
fmt.Printf("Child received SIGKILL\n")
}
}
}()
Expand Down
4 changes: 1 addition & 3 deletions system/exec_cmd_runner_fixtures/exe_exits/exe_exits.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import (

func main() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGKILL) //nolint:staticcheck
signal.Notify(sigCh, syscall.SIGTERM)

go func() {
for {
switch <-sigCh {
case syscall.SIGTERM:
fmt.Printf("Exe received SIGTERM\n")
case syscall.SIGKILL:
fmt.Printf("Exe received SIGKILL\n")
}
}
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ func main() {
fmt.Printf("parent_pid=%d\n", os.Getpid())

sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGKILL) //nolint:staticcheck
signal.Notify(sigCh, syscall.SIGTERM)

go func() {
for {
switch <-sigCh {
case syscall.SIGTERM:
fmt.Printf("Parent received SIGTERM\n")
case syscall.SIGKILL:
fmt.Printf("Parent received SIGKILL\n")
}
}
}()
Expand Down
5 changes: 1 addition & 4 deletions system/exec_cmd_runner_fixtures/windows_exe/windows_exe.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func main() {
sigCh := make(chan os.Signal, 1)

signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGKILL) //nolint:staticcheck
signal.Notify(sigCh, syscall.SIGTERM)

done := make(chan struct{})
var exitStatus int
Expand All @@ -21,9 +21,6 @@ func main() {
case "SIGTERM":
fmt.Println("Received SIGTERM")
exitStatus = 13
case "SIGKILL":
fmt.Println("Received SIGKILL")
exitStatus = 27
default:
fmt.Printf("Received unhandled signal: %s\n", s)
exitStatus = 17
Expand Down
2 changes: 1 addition & 1 deletion system/exec_cmd_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func unixCommand(cmdName string) Command {

func parseEnvFields(envDump string, convertKeysToUpper bool) map[string]string {
fields := make(map[string]string)
envDump = strings.Replace(envDump, "\r", "", -1) //nolint:staticcheck
envDump = strings.ReplaceAll(envDump, "\r", "")
for _, line := range strings.Split(envDump, "\n") {
// don't split on '=' as '=' is allowed in the value on Windows
if n := strings.IndexByte(line, '='); n != -1 {
Expand Down
Loading
Loading