Skip to content

Commit 76559da

Browse files
committed
fix: ST1005 error strings should not be capitalized
This fixes the staticcheck error ST1005, which states that error strings should not be capitalized. Ref: https://staticcheck.dev/docs/checks#ST1005 Signed-off-by: German Lashevich <german.lashevich@gmail.com>
1 parent d267697 commit 76559da

41 files changed

Lines changed: 254 additions & 254 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/vendir/cmd/sync.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (o *SyncOptions) Run() error {
6363
if len(o.Chdir) > 0 {
6464
err := os.Chdir(o.Chdir)
6565
if err != nil {
66-
return fmt.Errorf("Running chdir: %s", err)
66+
return fmt.Errorf("running chdir: %s", err)
6767
}
6868
}
6969

@@ -125,7 +125,7 @@ func (o *SyncOptions) Run() error {
125125

126126
cache, err := ctlcache.NewCache(os.Getenv("VENDIR_CACHE_DIR"), maxCacheableContentSize)
127127
if err != nil {
128-
return fmt.Errorf("Unable to create cache: %s", err)
128+
return fmt.Errorf("unable to create cache: %s", err)
129129
}
130130
syncOpts := ctldir.SyncOpts{
131131
RefFetcher: ctldir.NewNamedRefFetcher(secrets, configMaps),
@@ -143,7 +143,7 @@ func (o *SyncOptions) Run() error {
143143
directory := ctldir.NewDirectory(dirConf, dirExistingLockConf, o.ui)
144144
dirLockConf, err := directory.Sync(syncOpts)
145145
if err != nil {
146-
return fmt.Errorf("Syncing directory '%s': %s", dirConf.Path, err)
146+
return fmt.Errorf("syncing directory '%s': %s", dirConf.Path, err)
147147
}
148148
if !o.AllowAllSymlinkDestinations {
149149
err = ctldir.ValidateSymlinks(dirConf.Path)
@@ -217,7 +217,7 @@ func (o *SyncOptions) applyUseDirectories(conf *ctlconf.Config, dirs []dirOverri
217217

218218
err := conf.UseDirectory(dir.Path, dir.LocalDir)
219219
if err != nil {
220-
return false, fmt.Errorf("Overriding '%s' with local directory: %s", dir.Path, err)
220+
return false, fmt.Errorf("overriding '%s' with local directory: %s", dir.Path, err)
221221
}
222222
}
223223
return usesLocalDir, nil
@@ -276,7 +276,7 @@ func (dirs dirOverrides) ExpandUserHomeDirs() error {
276276
func (dirOverrides) userHomeDir() (string, error) {
277277
out, err := homedir.Dir()
278278
if err != nil {
279-
return "", fmt.Errorf("Expanding user home directory: %s", err)
279+
return "", fmt.Errorf("expanding user home directory: %s", err)
280280
}
281281
return strings.TrimSpace(string(out)), nil
282282
}

pkg/vendir/config/config.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewConfigFromFiles(paths []string) (Config, []Secret, []ConfigMap, error) {
3838

3939
err := yaml.Unmarshal(docBytes, &res)
4040
if err != nil {
41-
return fmt.Errorf("Unmarshaling doc: %s", err)
41+
return fmt.Errorf("unmarshaling doc: %s", err)
4242
}
4343

4444
switch {
@@ -47,7 +47,7 @@ func NewConfigFromFiles(paths []string) (Config, []Secret, []ConfigMap, error) {
4747

4848
err := yaml.Unmarshal(docBytes, &secret)
4949
if err != nil {
50-
return fmt.Errorf("Unmarshaling secret: %s", err)
50+
return fmt.Errorf("unmarshaling secret: %s", err)
5151
}
5252

5353
if s, ok := secretsNames[secret.Metadata.Name]; ok {
@@ -63,20 +63,20 @@ func NewConfigFromFiles(paths []string) (Config, []Secret, []ConfigMap, error) {
6363

6464
err := yaml.Unmarshal(docBytes, &cm)
6565
if err != nil {
66-
return fmt.Errorf("Unmarshaling config map: %s", err)
66+
return fmt.Errorf("unmarshaling config map: %s", err)
6767
}
6868
configMaps = append(configMaps, cm)
6969

7070
case res.APIVersion == knownAPIVersion && res.Kind == knownKind:
7171
config, err := NewConfigFromBytes(docBytes)
7272
config.cleanPaths()
7373
if err != nil {
74-
return fmt.Errorf("Unmarshaling config: %s", err)
74+
return fmt.Errorf("unmarshaling config: %s", err)
7575
}
7676
configs = append(configs, config)
7777

7878
default:
79-
return fmt.Errorf("Unknown apiVersion '%s' or kind '%s' for resource",
79+
return fmt.Errorf("unknown apiVersion '%s' or kind '%s' for resource",
8080
res.APIVersion, res.Kind)
8181
}
8282
return nil
@@ -91,10 +91,10 @@ func NewConfigFromFiles(paths []string) (Config, []Secret, []ConfigMap, error) {
9191
}
9292

9393
if len(configs) == 0 {
94-
return Config{}, nil, nil, fmt.Errorf("Expected to find at least one config, but found none")
94+
return Config{}, nil, nil, fmt.Errorf("expected to find at least one config, but found none")
9595
}
9696
if len(configs) > 1 {
97-
return Config{}, nil, nil, fmt.Errorf("Expected to find exactly one config, but found multiple")
97+
return Config{}, nil, nil, fmt.Errorf("expected to find exactly one config, but found multiple")
9898
}
9999

100100
return configs[0], secrets, configMaps, nil
@@ -105,38 +105,38 @@ func NewConfigFromBytes(bs []byte) (Config, error) {
105105

106106
err := yaml.Unmarshal(bs, &config)
107107
if err != nil {
108-
return Config{}, fmt.Errorf("Unmarshaling config: %s", err)
108+
return Config{}, fmt.Errorf("unmarshaling config: %s", err)
109109
}
110110

111111
err = config.Validate()
112112
if err != nil {
113-
return Config{}, fmt.Errorf("Validating config: %s", err)
113+
return Config{}, fmt.Errorf("validating config: %s", err)
114114
}
115115

116116
return config, nil
117117
}
118118

119119
func (c Config) Validate() error {
120120
if c.APIVersion != knownAPIVersion {
121-
return fmt.Errorf("Validating apiVersion: Unknown version (known: %s)", knownAPIVersion)
121+
return fmt.Errorf("validating apiVersion: Unknown version (known: %s)", knownAPIVersion)
122122
}
123123
if c.Kind != knownKind {
124-
return fmt.Errorf("Validating kind: Unknown kind (known: %s)", knownKind)
124+
return fmt.Errorf("validating kind: Unknown kind (known: %s)", knownKind)
125125
}
126126

127127
if len(c.MinimumRequiredVersion) > 0 {
128128
if c.MinimumRequiredVersion[0] == 'v' {
129-
return fmt.Errorf("Validating minimum version: Must not have prefix 'v' (e.g. '0.8.0')")
129+
return fmt.Errorf("validating minimum version: Must not have prefix 'v' (e.g. '0.8.0')")
130130
}
131131

132132
userConstraint, err := semver.NewConstraint(">=" + c.MinimumRequiredVersion)
133133
if err != nil {
134-
return fmt.Errorf("Parsing minimum version constraint: %s", err)
134+
return fmt.Errorf("parsing minimum version constraint: %s", err)
135135
}
136136

137137
vendirVersion, err := semver.NewVersion(version.Version)
138138
if err != nil {
139-
return fmt.Errorf("Parsing version constraint: %s", err)
139+
return fmt.Errorf("parsing version constraint: %s", err)
140140
}
141141

142142
if !userConstraint.Check(vendirVersion) {
@@ -148,7 +148,7 @@ func (c Config) Validate() error {
148148
for i, dir := range c.Directories {
149149
err := dir.Validate()
150150
if err != nil {
151-
return fmt.Errorf("Validating directory '%s' (%d): %s", dir.Path, i, err)
151+
return fmt.Errorf("validating directory '%s' (%d): %s", dir.Path, i, err)
152152
}
153153
}
154154

@@ -158,7 +158,7 @@ func (c Config) Validate() error {
158158
func (c Config) AsBytes() ([]byte, error) {
159159
bs, err := yaml.Marshal(c)
160160
if err != nil {
161-
return nil, fmt.Errorf("Marshaling config: %s", err)
161+
return nil, fmt.Errorf("marshaling config: %s", err)
162162
}
163163

164164
return bs, nil
@@ -173,7 +173,7 @@ func (c Config) UseDirectory(path, dirPath string) error {
173173
continue
174174
}
175175
if matched {
176-
return fmt.Errorf("Expected to match exactly one directory, but matched multiple")
176+
return fmt.Errorf("expected to match exactly one directory, but matched multiple")
177177
}
178178
matched = true
179179

@@ -192,7 +192,7 @@ func (c Config) UseDirectory(path, dirPath string) error {
192192
}
193193

194194
if !matched {
195-
return fmt.Errorf("Expected to match exactly one directory, but did not match any")
195+
return fmt.Errorf("expected to match exactly one directory, but did not match any")
196196
}
197197
return nil
198198
}
@@ -220,7 +220,7 @@ func (c Config) Subset(paths []string) (Config, error) {
220220
continue
221221
}
222222
if seen {
223-
return Config{}, fmt.Errorf("Expected to match path '%s' once, but matched multiple", entirePath)
223+
return Config{}, fmt.Errorf("expected to match path '%s' once, but matched multiple", entirePath)
224224
}
225225
pathsToSeen[entirePath] = true
226226

@@ -234,7 +234,7 @@ func (c Config) Subset(paths []string) (Config, error) {
234234

235235
for path, seen := range pathsToSeen {
236236
if !seen {
237-
return Config{}, fmt.Errorf("Expected to match path '%s' once, but did not match any", path)
237+
return Config{}, fmt.Errorf("expected to match path '%s' once, but did not match any", path)
238238
}
239239
}
240240

@@ -265,7 +265,7 @@ func (c Config) checkOverlappingPaths() error {
265265
for i, path := range paths {
266266
for i2, path2 := range paths {
267267
if i != i2 && strings.HasPrefix(path2+string(filepath.Separator), path+string(filepath.Separator)) {
268-
return fmt.Errorf("Expected to not manage overlapping paths: '%s' and '%s'", path2, path)
268+
return fmt.Errorf("expected to not manage overlapping paths: '%s' and '%s'", path2, path)
269269
}
270270
}
271271
}

pkg/vendir/config/directory.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ func (c Directory) Validate() error {
227227
}
228228
}
229229
if consumesEntireDir && len(c.Contents) != 1 {
230-
return fmt.Errorf("Expected only one directory contents if path is set to '%s'", EntireDirPath)
230+
return fmt.Errorf("expected only one directory contents if path is set to '%s'", EntireDirPath)
231231
}
232232
}
233233

234234
for i, con := range c.Contents {
235235
err := con.Validate()
236236
if err != nil {
237-
return fmt.Errorf("Validating directory contents '%s' (%d): %s", con.Path, i, err)
237+
return fmt.Errorf("validating directory contents '%s' (%d): %s", con.Path, i, err)
238238
}
239239
}
240240

@@ -276,10 +276,10 @@ func (c DirectoryContents) Validate() error {
276276
}
277277

278278
if len(srcTypes) == 0 {
279-
return fmt.Errorf("Expected directory contents type to be specified (one of git, manual, etc.)")
279+
return fmt.Errorf("expected directory contents type to be specified (one of git, manual, etc.)")
280280
}
281281
if len(srcTypes) > 1 {
282-
return fmt.Errorf("Expected exactly one directory contents type to be specified (multiple found: %s)", strings.Join(srcTypes, ", "))
282+
return fmt.Errorf("expected exactly one directory contents type to be specified (multiple found: %s)", strings.Join(srcTypes, ", "))
283283
}
284284

285285
// entire dir path is allowed for contents
@@ -307,7 +307,7 @@ func (c DirectoryContents) LegalPathsWithDefaults() []string {
307307
func isDisallowedPath(path string) error {
308308
for _, p := range disallowedPaths {
309309
if path == p {
310-
return fmt.Errorf("Expected path to not be one of '%s'",
310+
return fmt.Errorf("expected path to not be one of '%s'",
311311
strings.Join(disallowedPaths, "', '"))
312312
}
313313
}
@@ -343,39 +343,39 @@ func (c DirectoryContents) Lock(lockConfig LockDirectoryContents) error {
343343

344344
func (c *DirectoryContentsGit) Lock(lockConfig *LockDirectoryContentsGit) error {
345345
if lockConfig == nil {
346-
return fmt.Errorf("Expected git lock configuration to be non-empty")
346+
return fmt.Errorf("expected git lock configuration to be non-empty")
347347
}
348348
if len(lockConfig.SHA) == 0 {
349-
return fmt.Errorf("Expected git SHA to be non-empty")
349+
return fmt.Errorf("expected git SHA to be non-empty")
350350
}
351351
c.Ref = lockConfig.SHA
352352
return nil
353353
}
354354

355355
func (c *DirectoryContentsHg) Lock(lockConfig *LockDirectoryContentsHg) error {
356356
if lockConfig == nil {
357-
return fmt.Errorf("Expected hg lock configuration to be non-empty")
357+
return fmt.Errorf("expected hg lock configuration to be non-empty")
358358
}
359359
if len(lockConfig.SHA) == 0 {
360-
return fmt.Errorf("Expected hg SHA to be non-empty")
360+
return fmt.Errorf("expected hg SHA to be non-empty")
361361
}
362362
c.Ref = lockConfig.SHA
363363
return nil
364364
}
365365

366366
func (c *DirectoryContentsHTTP) Lock(lockConfig *LockDirectoryContentsHTTP) error {
367367
if lockConfig == nil {
368-
return fmt.Errorf("Expected HTTP lock configuration to be non-empty")
368+
return fmt.Errorf("expected HTTP lock configuration to be non-empty")
369369
}
370370
return nil
371371
}
372372

373373
func (c *DirectoryContentsImage) Lock(lockConfig *LockDirectoryContentsImage) error {
374374
if lockConfig == nil {
375-
return fmt.Errorf("Expected image lock configuration to be non-empty")
375+
return fmt.Errorf("expected image lock configuration to be non-empty")
376376
}
377377
if len(lockConfig.URL) == 0 {
378-
return fmt.Errorf("Expected image URL to be non-empty")
378+
return fmt.Errorf("expected image URL to be non-empty")
379379
}
380380
c.URL = lockConfig.URL
381381
c.TagSelection = nil // URL is fully resolved already
@@ -385,10 +385,10 @@ func (c *DirectoryContentsImage) Lock(lockConfig *LockDirectoryContentsImage) er
385385

386386
func (c *DirectoryContentsImgpkgBundle) Lock(lockConfig *LockDirectoryContentsImgpkgBundle) error {
387387
if lockConfig == nil {
388-
return fmt.Errorf("Expected image lock configuration to be non-empty")
388+
return fmt.Errorf("expected image lock configuration to be non-empty")
389389
}
390390
if len(lockConfig.Image) == 0 {
391-
return fmt.Errorf("Expected imgpkg bundle Image to be non-empty")
391+
return fmt.Errorf("expected imgpkg bundle Image to be non-empty")
392392
}
393393
c.Image = lockConfig.Image
394394
c.TagSelection = nil // URL is fully resolved already
@@ -398,10 +398,10 @@ func (c *DirectoryContentsImgpkgBundle) Lock(lockConfig *LockDirectoryContentsIm
398398

399399
func (c *DirectoryContentsGithubRelease) Lock(lockConfig *LockDirectoryContentsGithubRelease) error {
400400
if lockConfig == nil {
401-
return fmt.Errorf("Expected github release lock configuration to be non-empty")
401+
return fmt.Errorf("expected github release lock configuration to be non-empty")
402402
}
403403
if len(lockConfig.URL) == 0 {
404-
return fmt.Errorf("Expected github release URL to be non-empty")
404+
return fmt.Errorf("expected github release URL to be non-empty")
405405
}
406406
c.URL = lockConfig.URL
407407
c.Tag = lockConfig.Tag
@@ -410,10 +410,10 @@ func (c *DirectoryContentsGithubRelease) Lock(lockConfig *LockDirectoryContentsG
410410

411411
func (c *DirectoryContentsHelmChart) Lock(lockConfig *LockDirectoryContentsHelmChart) error {
412412
if lockConfig == nil {
413-
return fmt.Errorf("Expected helm chart lock configuration to be non-empty")
413+
return fmt.Errorf("expected helm chart lock configuration to be non-empty")
414414
}
415415
if len(lockConfig.Version) == 0 {
416-
return fmt.Errorf("Expected helm chart version to be non-empty")
416+
return fmt.Errorf("expected helm chart version to be non-empty")
417417
}
418418
c.Version = lockConfig.Version
419419
return nil

pkg/vendir/config/dockerconfigjson.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func (s Secret) ToRegistryAuthSecrets() ([]Secret, error) {
5959
if len(auth.Password) == 0 && len(auth.Auth) > 0 {
6060
decodedAuth, err := base64.StdEncoding.DecodeString(auth.Auth)
6161
if err != nil {
62-
return nil, fmt.Errorf("Decoding auth field: %s", err)
62+
return nil, fmt.Errorf("decoding auth field: %s", err)
6363
}
6464

6565
pieces := strings.SplitN(string(decodedAuth), ":", 2)
6666
if len(pieces) != 2 {
67-
return nil, fmt.Errorf("Expected auth field to have 'username:password' format, but did not")
67+
return nil, fmt.Errorf("expected auth field to have 'username:password' format, but did not")
6868
}
6969
auth.Username = pieces[0]
7070
auth.Password = pieces[1]

pkg/vendir/config/dockerconfigjson_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func TestSecretToRegistryAuthSecretsWithAuthFieldFallback(t *testing.T) {
115115
}
116116

117117
_, err := s1.ToRegistryAuthSecrets()
118-
require.EqualError(t, err, "Decoding auth field: illegal base64 data at input byte 4")
118+
require.EqualError(t, err, "decoding auth field: illegal base64 data at input byte 4")
119119
})
120120

121121
t.Run("password is empty and auth is invalid due to missing password (errors)", func(t *testing.T) {
@@ -127,7 +127,7 @@ func TestSecretToRegistryAuthSecretsWithAuthFieldFallback(t *testing.T) {
127127
}
128128

129129
_, err := s1.ToRegistryAuthSecrets()
130-
require.EqualError(t, err, "Expected auth field to have 'username:password' format, but did not")
130+
require.EqualError(t, err, "expected auth field to have 'username:password' format, but did not")
131131
})
132132

133133
t.Run("password is empty, falls back on auth field username+password", func(t *testing.T) {

0 commit comments

Comments
 (0)