Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable ci for release/2.7 #3385

Merged
merged 5 commits into from Mar 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Expand Up @@ -2,11 +2,7 @@ name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

Expand Down Expand Up @@ -34,7 +30,7 @@ jobs:
- name: Dependencies
run: |
sudo apt-get -q update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install python-minimal
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install python2-minimal
cd /tmp && go get -u github.com/vbatts/git-validation

- name: Build
Expand Down
20 changes: 20 additions & 0 deletions .golangci.yml
@@ -0,0 +1,20 @@
linters:
enable:
- structcheck
- varcheck
- staticcheck
- unconvert
- gofmt
- goimports
- golint
- ineffassign
- vet
- unused
- misspell
disable:
- errcheck

run:
deadline: 2m
skip-dirs:
- vendor
15 changes: 0 additions & 15 deletions .gometalinter.json

This file was deleted.

51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -50,7 +50,7 @@ version/version.go:

check: ## run all linters (TODO: enable "unused", "varcheck", "ineffassign", "unconvert", "staticheck", "goimports", "structcheck")
@echo "$(WHALE) $@"
gometalinter --config .gometalinter.json ./...
golangci-lint run

test: ## run tests, except integration test with test.short
@echo "$(WHALE) $@"
Expand Down
2 changes: 1 addition & 1 deletion blobs.go
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/docker/distribution/reference"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/registry-api-descriptor-template/main.go
Expand Up @@ -21,7 +21,7 @@ import (
"text/template"

"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
)

var spaceRegex = regexp.MustCompile(`\n\s*`)
Expand Down
8 changes: 4 additions & 4 deletions configuration/configuration.go
Expand Up @@ -388,7 +388,7 @@ func (loglevel *Loglevel) UnmarshalYAML(unmarshal func(interface{}) error) error
switch loglevelString {
case "error", "warn", "info", "debug":
default:
return fmt.Errorf("Invalid loglevel %s Must be one of [error, warn, info, debug]", loglevelString)
return fmt.Errorf("invalid loglevel %s Must be one of [error, warn, info, debug]", loglevelString)
}

*loglevel = Loglevel(loglevelString)
Expand Down Expand Up @@ -463,7 +463,7 @@ func (storage *Storage) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

if len(types) > 1 {
return fmt.Errorf("Must provide exactly one storage type. Provided: %v", types)
return fmt.Errorf("must provide exactly one storage type. Provided: %v", types)
}
}
*storage = storageMap
Expand Down Expand Up @@ -665,11 +665,11 @@ func Parse(rd io.Reader) (*Configuration, error) {
v0_1.Loglevel = Loglevel("")
}
if v0_1.Storage.Type() == "" {
return nil, errors.New("No storage configuration provided")
return nil, errors.New("no storage configuration provided")
}
return (*Configuration)(v0_1), nil
}
return nil, fmt.Errorf("Expected *v0_1Configuration, received %#v", c)
return nil, fmt.Errorf("expected *v0_1Configuration, received %#v", c)
},
},
})
Expand Down
4 changes: 1 addition & 3 deletions configuration/configuration_test.go
Expand Up @@ -540,9 +540,7 @@ func copyConfig(config Configuration) *Configuration {
}

configCopy.Notifications = Notifications{Endpoints: []Endpoint{}}
for _, v := range config.Notifications.Endpoints {
configCopy.Notifications.Endpoints = append(configCopy.Notifications.Endpoints, v)
}
configCopy.Notifications.Endpoints = append(configCopy.Notifications.Endpoints, config.Notifications.Endpoints...)

configCopy.HTTP.Headers = make(http.Header)
for k, v := range config.HTTP.Headers {
Expand Down
2 changes: 1 addition & 1 deletion configuration/parser.go
Expand Up @@ -122,7 +122,7 @@ func (p *Parser) Parse(in []byte, v interface{}) error {

parseInfo, ok := p.mapping[versionedStruct.Version]
if !ok {
return fmt.Errorf("Unsupported version: %q", versionedStruct.Version)
return fmt.Errorf("unsupported version: %q", versionedStruct.Version)
}

parseAs := reflect.New(parseInfo.ParseAs)
Expand Down
2 changes: 1 addition & 1 deletion health/api/api.go
Expand Up @@ -14,7 +14,7 @@ var (
// DownHandler registers a manual_http_status that always returns an Error
func DownHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
updater.Update(errors.New("Manual Check"))
updater.Update(errors.New("manual Check"))
} else {
w.WriteHeader(http.StatusNotFound)
}
Expand Down
6 changes: 3 additions & 3 deletions manifest/manifestlist/manifestlist.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

const (
Expand Down Expand Up @@ -163,7 +163,7 @@ func FromDescriptorsWithMediaType(descriptors []ManifestDescriptor, mediaType st
},
}

m.Manifests = make([]ManifestDescriptor, len(descriptors), len(descriptors))
m.Manifests = make([]ManifestDescriptor, len(descriptors))
copy(m.Manifests, descriptors)

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

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

Expand Down
2 changes: 1 addition & 1 deletion manifest/manifestlist/manifestlist_test.go
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/docker/distribution"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var expectedManifestListSerialization = []byte(`{
Expand Down
4 changes: 2 additions & 2 deletions manifest/ocischema/builder.go
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// Builder is a type for constructing manifests.
Expand Down Expand Up @@ -48,7 +48,7 @@ func NewManifestBuilder(bs distribution.BlobService, configJSON []byte, annotati
// valid media type for oci image manifests currently: "" or "application/vnd.oci.image.manifest.v1+json"
func (mb *Builder) SetMediaType(mediaType string) error {
if mediaType != "" && mediaType != v1.MediaTypeImageManifest {
return errors.New("Invalid media type for OCI image manifest")
return errors.New("invalid media type for OCI image manifest")
}

mb.mediaType = mediaType
Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/builder_test.go
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/docker/distribution"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type mockBlobService struct {
Expand Down
4 changes: 2 additions & 2 deletions manifest/ocischema/manifest.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var (
Expand Down Expand Up @@ -87,7 +87,7 @@ func FromStruct(m Manifest) (*DeserializedManifest, error) {

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

Expand Down
2 changes: 1 addition & 1 deletion manifest/ocischema/manifest_test.go
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var expectedManifestSerialization = []byte(`{
Expand Down
4 changes: 2 additions & 2 deletions manifest/schema1/manifest.go
Expand Up @@ -108,7 +108,7 @@ type SignedManifest struct {

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

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

// sm.Canonical stores the canonical manifest JSON
sm.Canonical = make([]byte, len(bytes), len(bytes))
sm.Canonical = make([]byte, len(bytes))
copy(sm.Canonical, bytes)

// Unmarshal canonical JSON into Manifest object
Expand Down
2 changes: 1 addition & 1 deletion manifest/schema1/reference_builder.go
Expand Up @@ -58,7 +58,7 @@ func (mb *referenceManifestBuilder) Build(ctx context.Context) (distribution.Man
func (mb *referenceManifestBuilder) AppendReference(d distribution.Describable) error {
r, ok := d.(Reference)
if !ok {
return fmt.Errorf("Unable to add non-reference type to v1 builder")
return fmt.Errorf("unable to add non-reference type to v1 builder")
}

// Entries need to be prepended
Expand Down
2 changes: 1 addition & 1 deletion manifest/schema2/manifest.go
Expand Up @@ -106,7 +106,7 @@ func FromStruct(m Manifest) (*DeserializedManifest, error) {

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

Expand Down
2 changes: 1 addition & 1 deletion manifests.go
Expand Up @@ -87,7 +87,7 @@ func ManifestMediaTypes() (mediaTypes []string) {
// UnmarshalFunc implements manifest unmarshalling a given MediaType
type UnmarshalFunc func([]byte) (Manifest, Descriptor, error)

var mappings = make(map[string]UnmarshalFunc, 0)
var mappings = make(map[string]UnmarshalFunc)

// UnmarshalManifest looks up manifest unmarshal functions based on
// MediaType
Expand Down
9 changes: 0 additions & 9 deletions notifications/bridge.go
Expand Up @@ -125,15 +125,6 @@ func (b *bridge) RepoDeleted(repo reference.Named) error {
return b.sink.Write(*event)
}

func (b *bridge) createManifestEventAndWrite(action string, repo reference.Named, sm distribution.Manifest) error {
manifestEvent, err := b.createManifestEvent(action, repo, sm)
if err != nil {
return err
}

return b.sink.Write(*manifestEvent)
}

func (b *bridge) createManifestDeleteEventAndWrite(action string, repo reference.Named, dgst digest.Digest) error {
event := b.createEvent(action)
event.Target.Repository = repo.Name()
Expand Down
2 changes: 1 addition & 1 deletion notifications/bridge_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/api/v2"
v2 "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/uuid"
"github.com/docker/libtrust"
"github.com/opencontainers/go-digest"
Expand Down
9 changes: 3 additions & 6 deletions notifications/event_test.go
Expand Up @@ -114,8 +114,7 @@ func TestEventEnvelopeJSONFormat(t *testing.T) {
prototype.Request.UserAgent = "test/0.1"
prototype.Source.Addr = "hostname.local:port"

var manifestPush Event
manifestPush = prototype
var manifestPush = prototype
manifestPush.ID = "asdf-asdf-asdf-asdf-0"
manifestPush.Target.Digest = "sha256:0123456789abcdef0"
manifestPush.Target.Length = 1
Expand All @@ -124,8 +123,7 @@ func TestEventEnvelopeJSONFormat(t *testing.T) {
manifestPush.Target.Repository = "library/test"
manifestPush.Target.URL = "http://example.com/v2/library/test/manifests/latest"

var layerPush0 Event
layerPush0 = prototype
var layerPush0 = prototype
layerPush0.ID = "asdf-asdf-asdf-asdf-1"
layerPush0.Target.Digest = "sha256:3b3692957d439ac1928219a83fac91e7bf96c153725526874673ae1f2023f8d5"
layerPush0.Target.Length = 2
Expand All @@ -134,8 +132,7 @@ func TestEventEnvelopeJSONFormat(t *testing.T) {
layerPush0.Target.Repository = "library/test"
layerPush0.Target.URL = "http://example.com/v2/library/test/manifests/latest"

var layerPush1 Event
layerPush1 = prototype
var layerPush1 = prototype
layerPush1.ID = "asdf-asdf-asdf-asdf-2"
layerPush1.Target.Digest = "sha256:3b3692957d439ac1928219a83fac91e7bf96c153725526874673ae1f2023f8d6"
layerPush1.Target.Length = 3
Expand Down
3 changes: 1 addition & 2 deletions notifications/http.go
Expand Up @@ -133,8 +133,7 @@ type headerRoundTripper struct {
}

func (hrt *headerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
var nreq http.Request
nreq = *req
var nreq = *req
nreq.Header = make(http.Header)

merge := func(headers http.Header) {
Expand Down