Skip to content

Commit 9c0abfa

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
1 parent d267697 commit 9c0abfa

15 files changed

Lines changed: 96 additions & 96 deletions

File tree

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/lock_config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewLockConfig() LockConfig {
3131
func NewLockConfigFromFile(path string) (LockConfig, error) {
3232
bs, err := os.ReadFile(path)
3333
if err != nil {
34-
return LockConfig{}, fmt.Errorf("Reading lock config '%s': %s", path, err)
34+
return LockConfig{}, fmt.Errorf("reading lock config '%s': %s", path, err)
3535
}
3636

3737
return NewLockConfigFromBytes(bs)
@@ -42,12 +42,12 @@ func NewLockConfigFromBytes(bs []byte) (LockConfig, error) {
4242

4343
err := yaml.Unmarshal(bs, &config)
4444
if err != nil {
45-
return LockConfig{}, fmt.Errorf("Unmarshaling lock config: %s", err)
45+
return LockConfig{}, fmt.Errorf("unmarshaling lock config: %s", err)
4646
}
4747

4848
err = config.Validate()
4949
if err != nil {
50-
return LockConfig{}, fmt.Errorf("Validating lock config: %s", err)
50+
return LockConfig{}, fmt.Errorf("validating lock config: %s", err)
5151
}
5252

5353
return config, nil
@@ -56,18 +56,18 @@ func NewLockConfigFromBytes(bs []byte) (LockConfig, error) {
5656
func (c LockConfig) WriteToFile(path string) error {
5757
existingBytes, err := os.ReadFile(path)
5858
if err != nil && !errors.Is(err, fs.ErrNotExist) {
59-
return fmt.Errorf("Failed to check existing lock file: %w", err)
59+
return fmt.Errorf("failed to check existing lock file: %w", err)
6060
}
6161

6262
bs, err := c.AsBytes()
6363
if err != nil {
64-
return fmt.Errorf("Marshaling lock config: %s", err)
64+
return fmt.Errorf("marshaling lock config: %s", err)
6565
}
6666

6767
if bytes.Compare(existingBytes, bs) != 0 {
6868
err = os.WriteFile(path, bs, 0600)
6969
if err != nil {
70-
return fmt.Errorf("Writing lock config: %s", err)
70+
return fmt.Errorf("writing lock config: %s", err)
7171
}
7272
}
7373

@@ -77,7 +77,7 @@ func (c LockConfig) WriteToFile(path string) error {
7777
func (c LockConfig) AsBytes() ([]byte, error) {
7878
bs, err := yaml.Marshal(c)
7979
if err != nil {
80-
return nil, fmt.Errorf("Marshaling lock config: %s", err)
80+
return nil, fmt.Errorf("marshaling lock config: %s", err)
8181
}
8282

8383
return bs, nil
@@ -90,10 +90,10 @@ func (c LockConfig) Validate() error {
9090
)
9191

9292
if c.APIVersion != knownAPIVersion {
93-
return fmt.Errorf("Validating apiVersion: Unknown version (known: %s)", knownAPIVersion)
93+
return fmt.Errorf("validating apiVersion: Unknown version (known: %s)", knownAPIVersion)
9494
}
9595
if c.Kind != knownKind {
96-
return fmt.Errorf("Validating kind: Unknown kind (known: %s)", knownKind)
96+
return fmt.Errorf("validating kind: Unknown kind (known: %s)", knownKind)
9797
}
9898
return nil
9999
}
@@ -106,7 +106,7 @@ func (c LockConfig) FindContents(dirPath, conPath string) (LockDirectoryContents
106106
return con, nil
107107
}
108108
}
109-
return LockDirectoryContents{}, fmt.Errorf("Expected to find contents '%s' "+
109+
return LockDirectoryContents{}, fmt.Errorf("expected to find contents '%s' "+
110110
"within directory '%s' in lock config, but did not", conPath, dirPath)
111111
}
112112
}

pkg/vendir/directory/directory.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
9898
// copy previously fetched contents to staging dir
9999
err = dircopy.Copy(filepath.Join(d.opts.Path, contents.Path), stagingDstPath)
100100
if err != nil {
101-
return lockConfig, fmt.Errorf("Lazy content missing. Run sync with --lazy=false to fix. '%s': %s", d.opts.Path, err)
101+
return lockConfig, fmt.Errorf("lazy content missing. Run sync with --lazy=false to fix. '%s': %s", d.opts.Path, err)
102102
}
103103
continue
104104
}
@@ -114,7 +114,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
114114

115115
lock, err := gitSync.Sync(stagingDstPath, stagingDir.TempArea())
116116
if err != nil {
117-
return lockConfig, fmt.Errorf("Syncing directory '%s' with git contents: %s", contents.Path, err)
117+
return lockConfig, fmt.Errorf("syncing directory '%s' with git contents: %s", contents.Path, err)
118118
}
119119
lockDirContents.Git = &lock
120120

@@ -125,7 +125,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
125125

126126
lock, err := hgSync.Sync(stagingDstPath, stagingDir.TempArea())
127127
if err != nil {
128-
return lockConfig, fmt.Errorf("Syncing directory '%s' with hg contents: %s", contents.Path, err)
128+
return lockConfig, fmt.Errorf("syncing directory '%s' with hg contents: %s", contents.Path, err)
129129
}
130130

131131
lockDirContents.Hg = &lock
@@ -135,7 +135,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
135135

136136
lock, err := ctlhttp.NewSync(*contents.HTTP, syncOpts.RefFetcher).Sync(stagingDstPath, stagingDir.TempArea())
137137
if err != nil {
138-
return lockConfig, fmt.Errorf("Syncing directory '%s' with HTTP contents: %s", contents.Path, err)
138+
return lockConfig, fmt.Errorf("syncing directory '%s' with HTTP contents: %s", contents.Path, err)
139139
}
140140

141141
lockDirContents.HTTP = &lock
@@ -147,7 +147,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
147147

148148
lock, err := imageSync.Sync(stagingDstPath)
149149
if err != nil {
150-
return lockConfig, fmt.Errorf("Syncing directory '%s' with image contents: %s", contents.Path, err)
150+
return lockConfig, fmt.Errorf("syncing directory '%s' with image contents: %s", contents.Path, err)
151151
}
152152

153153
lockDirContents.Image = &lock
@@ -159,7 +159,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
159159

160160
lock, err := imgpkgBundleSync.Sync(stagingDstPath)
161161
if err != nil {
162-
return lockConfig, fmt.Errorf("Syncing directory '%s' with imgpkgBundle contents: %s", contents.Path, err)
162+
return lockConfig, fmt.Errorf("syncing directory '%s' with imgpkgBundle contents: %s", contents.Path, err)
163163
}
164164

165165
lockDirContents.ImgpkgBundle = &lock
@@ -175,7 +175,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
175175

176176
lock, err := sync.Sync(stagingDstPath, stagingDir.TempArea())
177177
if err != nil {
178-
return lockConfig, fmt.Errorf("Syncing directory '%s' with github release contents: %s", contents.Path, err)
178+
return lockConfig, fmt.Errorf("syncing directory '%s' with github release contents: %s", contents.Path, err)
179179
}
180180

181181
lockDirContents.GithubRelease = &lock
@@ -188,7 +188,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
188188

189189
lock, err := helmChartSync.Sync(stagingDstPath, stagingDir.TempArea())
190190
if err != nil {
191-
return lockConfig, fmt.Errorf("Syncing directory '%s' with helm chart contents: %s", contents.Path, err)
191+
return lockConfig, fmt.Errorf("syncing directory '%s' with helm chart contents: %s", contents.Path, err)
192192
}
193193
lockDirContents.HelmChart = &lock
194194

@@ -199,7 +199,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
199199

200200
err := os.Rename(srcPath, stagingDstPath)
201201
if err != nil {
202-
return lockConfig, fmt.Errorf("Moving directory '%s' to staging dir: %s", srcPath, err)
202+
return lockConfig, fmt.Errorf("moving directory '%s' to staging dir: %s", srcPath, err)
203203
}
204204

205205
lockDirContents.Manual = &ctlconf.LockDirectoryContentsManual{}
@@ -211,7 +211,7 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
211211

212212
err := dircopy.Copy(contents.Directory.Path, stagingDstPath)
213213
if err != nil {
214-
return lockConfig, fmt.Errorf("Copying another directory contents into directory '%s': %s", contents.Path, err)
214+
return lockConfig, fmt.Errorf("copying another directory contents into directory '%s': %s", contents.Path, err)
215215
}
216216

217217
lockDirContents.Directory = &ctlconf.LockDirectoryContentsDirectory{}
@@ -221,33 +221,33 @@ func (d *Directory) Sync(syncOpts SyncOpts) (ctlconf.LockDirectory, error) {
221221

222222
lock, err := ctlinl.NewSync(*contents.Inline, syncOpts.RefFetcher).Sync(stagingDstPath)
223223
if err != nil {
224-
return lockConfig, fmt.Errorf("Syncing directory '%s' with inline contents: %s", contents.Path, err)
224+
return lockConfig, fmt.Errorf("syncing directory '%s' with inline contents: %s", contents.Path, err)
225225
}
226226

227227
lockDirContents.Inline = &lock
228228

229229
default:
230-
return lockConfig, fmt.Errorf("Unknown contents type for directory '%s'", contents.Path)
230+
return lockConfig, fmt.Errorf("unknown contents type for directory '%s'", contents.Path)
231231
}
232232

233233
if !skipFileFilter {
234234
err = FileFilter{contents}.Apply(stagingDstPath)
235235
if err != nil {
236-
return lockConfig, fmt.Errorf("Filtering paths in directory '%s': %s", contents.Path, err)
236+
return lockConfig, fmt.Errorf("filtering paths in directory '%s': %s", contents.Path, err)
237237
}
238238
}
239239

240240
if !skipNewRootPath && len(contents.NewRootPath) > 0 {
241241
err = NewSubPath(contents.NewRootPath).Extract(stagingDstPath, stagingDstPath, stagingDir.TempArea())
242242
if err != nil {
243-
return lockConfig, fmt.Errorf("Changing to new root path '%s': %s", contents.Path, err)
243+
return lockConfig, fmt.Errorf("changing to new root path '%s': %s", contents.Path, err)
244244
}
245245
}
246246

247247
// Copy files from current source if values are supposed to be ignored
248248
err = stagingDir.CopyExistingFiles(d.opts.Path, stagingDstPath, contents.IgnorePaths)
249249
if err != nil {
250-
return lockConfig, fmt.Errorf("Copying existing content to staging '%s': %s", d.opts.Path, err)
250+
return lockConfig, fmt.Errorf("copying existing content to staging '%s': %s", d.opts.Path, err)
251251
}
252252

253253
// after everything else is done, ensure the inner dir's access perms are set

pkg/vendir/directory/file_filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (d FileFilter) Apply(dirPath string) error {
6262
if !matched {
6363
err := os.RemoveAll(path)
6464
if err != nil {
65-
return fmt.Errorf("Deleting file %s: %s", path, err)
65+
return fmt.Errorf("deleting file %s: %s", path, err)
6666
}
6767
}
6868

@@ -120,7 +120,7 @@ func (d FileFilter) deleteEmptyDirs(dirPath string, topLevel bool) (bool, error)
120120

121121
if !hasFiles {
122122
if topLevel {
123-
return false, fmt.Errorf("Expected to find at least one file within directory")
123+
return false, fmt.Errorf("expected to find at least one file within directory")
124124
}
125125
// not RemoveAll to double check directory is empty
126126
return false, os.Remove(dirPath)

0 commit comments

Comments
 (0)