Skip to content

Commit 0d3efad

Browse files
authored
Merge pull request #2840 from manishtomar/fix-lint
Fix gometalint errors
2 parents 411d6bc + 48818fd commit 0d3efad

48 files changed

Lines changed: 99 additions & 249 deletions

Some content is hidden

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

configuration/configuration.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (loglevel *Loglevel) UnmarshalYAML(unmarshal func(interface{}) error) error
391391
switch loglevelString {
392392
case "error", "warn", "info", "debug":
393393
default:
394-
return fmt.Errorf("Invalid loglevel %s Must be one of [error, warn, info, debug]", loglevelString)
394+
return fmt.Errorf("invalid loglevel %s Must be one of [error, warn, info, debug]", loglevelString)
395395
}
396396

397397
*loglevel = Loglevel(loglevelString)
@@ -466,7 +466,7 @@ func (storage *Storage) UnmarshalYAML(unmarshal func(interface{}) error) error {
466466
}
467467

468468
if len(types) > 1 {
469-
return fmt.Errorf("Must provide exactly one storage type. Provided: %v", types)
469+
return fmt.Errorf("must provide exactly one storage type. Provided: %v", types)
470470
}
471471
}
472472
*storage = storageMap
@@ -668,11 +668,11 @@ func Parse(rd io.Reader) (*Configuration, error) {
668668
v0_1.Loglevel = Loglevel("")
669669
}
670670
if v0_1.Storage.Type() == "" {
671-
return nil, errors.New("No storage configuration provided")
671+
return nil, errors.New("no storage configuration provided")
672672
}
673673
return (*Configuration)(v0_1), nil
674674
}
675-
return nil, fmt.Errorf("Expected *v0_1Configuration, received %#v", c)
675+
return nil, fmt.Errorf("expected *v0_1Configuration, received %#v", c)
676676
},
677677
},
678678
})

configuration/configuration_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ func copyConfig(config Configuration) *Configuration {
542542
}
543543

544544
configCopy.Notifications = Notifications{Endpoints: []Endpoint{}}
545-
for _, v := range config.Notifications.Endpoints {
546-
configCopy.Notifications.Endpoints = append(configCopy.Notifications.Endpoints, v)
547-
}
545+
configCopy.Notifications.Endpoints = append(configCopy.Notifications.Endpoints, config.Notifications.Endpoints...)
548546

549547
configCopy.HTTP.Headers = make(http.Header)
550548
for k, v := range config.HTTP.Headers {

configuration/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (p *Parser) Parse(in []byte, v interface{}) error {
122122

123123
parseInfo, ok := p.mapping[versionedStruct.Version]
124124
if !ok {
125-
return fmt.Errorf("Unsupported version: %q", versionedStruct.Version)
125+
return fmt.Errorf("unsupported version: %q", versionedStruct.Version)
126126
}
127127

128128
parseAs := reflect.New(parseInfo.ParseAs)

health/api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var (
1414
// DownHandler registers a manual_http_status that always returns an Error
1515
func DownHandler(w http.ResponseWriter, r *http.Request) {
1616
if r.Method == "POST" {
17-
updater.Update(errors.New("Manual Check"))
17+
updater.Update(errors.New("manual Check"))
1818
} else {
1919
w.WriteHeader(http.StatusNotFound)
2020
}

manifest/manifestlist/manifestlist.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func FromDescriptorsWithMediaType(descriptors []ManifestDescriptor, mediaType st
163163
},
164164
}
165165

166-
m.Manifests = make([]ManifestDescriptor, len(descriptors), len(descriptors))
166+
m.Manifests = make([]ManifestDescriptor, len(descriptors))
167167
copy(m.Manifests, descriptors)
168168

169169
deserialized := DeserializedManifestList{
@@ -177,7 +177,7 @@ func FromDescriptorsWithMediaType(descriptors []ManifestDescriptor, mediaType st
177177

178178
// UnmarshalJSON populates a new ManifestList struct from JSON data.
179179
func (m *DeserializedManifestList) UnmarshalJSON(b []byte) error {
180-
m.canonical = make([]byte, len(b), len(b))
180+
m.canonical = make([]byte, len(b))
181181
// store manifest list in canonical
182182
copy(m.canonical, b)
183183

manifest/ocischema/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewManifestBuilder(bs distribution.BlobService, configJSON []byte, annotati
4848
// valid media type for oci image manifests currently: "" or "application/vnd.oci.image.manifest.v1+json"
4949
func (mb *Builder) SetMediaType(mediaType string) error {
5050
if mediaType != "" && mediaType != v1.MediaTypeImageManifest {
51-
return errors.New("Invalid media type for OCI image manifest")
51+
return errors.New("invalid media type for OCI image manifest")
5252
}
5353

5454
mb.mediaType = mediaType

manifest/ocischema/manifest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func FromStruct(m Manifest) (*DeserializedManifest, error) {
8787

8888
// UnmarshalJSON populates a new Manifest struct from JSON data.
8989
func (m *DeserializedManifest) UnmarshalJSON(b []byte) error {
90-
m.canonical = make([]byte, len(b), len(b))
90+
m.canonical = make([]byte, len(b))
9191
// store manifest in canonical
9292
copy(m.canonical, b)
9393

manifest/schema1/manifest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type SignedManifest struct {
108108

109109
// UnmarshalJSON populates a new SignedManifest struct from JSON data.
110110
func (sm *SignedManifest) UnmarshalJSON(b []byte) error {
111-
sm.all = make([]byte, len(b), len(b))
111+
sm.all = make([]byte, len(b))
112112
// store manifest and signatures in all
113113
copy(sm.all, b)
114114

@@ -124,7 +124,7 @@ func (sm *SignedManifest) UnmarshalJSON(b []byte) error {
124124
}
125125

126126
// sm.Canonical stores the canonical manifest JSON
127-
sm.Canonical = make([]byte, len(bytes), len(bytes))
127+
sm.Canonical = make([]byte, len(bytes))
128128
copy(sm.Canonical, bytes)
129129

130130
// Unmarshal canonical JSON into Manifest object

manifest/schema1/reference_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (mb *referenceManifestBuilder) Build(ctx context.Context) (distribution.Man
5858
func (mb *referenceManifestBuilder) AppendReference(d distribution.Describable) error {
5959
r, ok := d.(Reference)
6060
if !ok {
61-
return fmt.Errorf("Unable to add non-reference type to v1 builder")
61+
return fmt.Errorf("unable to add non-reference type to v1 builder")
6262
}
6363

6464
// Entries need to be prepended

manifest/schema2/manifest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func FromStruct(m Manifest) (*DeserializedManifest, error) {
106106

107107
// UnmarshalJSON populates a new Manifest struct from JSON data.
108108
func (m *DeserializedManifest) UnmarshalJSON(b []byte) error {
109-
m.canonical = make([]byte, len(b), len(b))
109+
m.canonical = make([]byte, len(b))
110110
// store manifest in canonical
111111
copy(m.canonical, b)
112112

0 commit comments

Comments
 (0)