VMware vSphere Integrated Containers provider (#206)

* Add Virtual Kubelet provider for VIC

Initial virtual kubelet provider for VMware VIC.  This provider currently
handles creating and starting of a pod VM via the VIC portlayer and persona
server.  Image store handling via the VIC persona server.  This provider
currently requires the feature/wolfpack branch of VIC.

* Added pod stop and delete.  Also added node capacity.

Added the ability to stop and delete pod VMs via VIC.  Also retrieve
node capacity information from the VCH.

* Cleanup and readme file

Some file clean up and added a Readme.md markdown file for the VIC
provider.

* Cleaned up errors, added function comments, moved operation code

1. Cleaned up error handling.  Set standard for creating errors.
2. Added method prototype comments for all interface functions.
3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder.

* Add mocking code and unit tests for podcache, podcreator, and podstarter

Used the unit test framework used in VIC to handle assertions in the provider's
unit test.  Mocking code generated using OSS project mockery, which is compatible
with the testify assertion framework.

* Vendored packages for the VIC provider

Requires feature/wolfpack branch of VIC and a few specific commit sha of
projects used within VIC.

* Implementation of POD Stopper and Deleter unit tests (#4)

* Updated files for initial PR
This commit is contained in:
Loc Nguyen
2018-06-04 15:41:32 -07:00
committed by Ria Bhatia
parent 98a111e8b7
commit 513cebe7b7
6296 changed files with 1123685 additions and 8 deletions

189
vendor/github.com/vmware/vic/pkg/registry/entry.go generated vendored Normal file
View File

@@ -0,0 +1,189 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import (
"net"
"net/url"
"strings"
glob "github.com/ryanuber/go-glob"
)
type Entry interface {
Contains(e Entry) bool
Match(e string) bool
Equal(other Entry) bool
String() string
IsCIDR() bool
IsURL() bool
}
type URLEntry interface {
Entry
URL() *url.URL
}
func ParseEntry(s string) Entry {
_, ipnet, err := net.ParseCIDR(s)
if err == nil {
return &cidrEntry{ipnet: ipnet}
}
if u := parseURL(s); u != nil {
return &urlEntry{u: u}
}
return nil
}
type cidrEntry struct {
ipnet *net.IPNet
}
func (c *cidrEntry) IsCIDR() bool {
return true
}
func (c *cidrEntry) IsURL() bool {
return false
}
func (c *cidrEntry) Contains(e Entry) bool {
switch e := e.(type) {
case *urlEntry:
if ip := net.ParseIP(e.u.Hostname()); ip != nil {
return c.ipnet.Contains(ip)
}
case *cidrEntry:
return c.ipnet.Contains(e.ipnet.IP.Mask(e.ipnet.Mask))
}
return false
}
func (c *cidrEntry) Match(s string) bool {
return c.Contains(ParseEntry(s))
}
func (c *cidrEntry) Equal(other Entry) bool {
return other.String() == c.ipnet.String()
}
func (c *cidrEntry) String() string {
return c.ipnet.String()
}
type urlEntry struct {
u *url.URL
}
func (u *urlEntry) IsCIDR() bool {
return false
}
func (u *urlEntry) IsURL() bool {
return true
}
func ensurePort(u *url.URL) *url.URL {
_, _, err := net.SplitHostPort(u.Host)
if err == nil {
return u // port already present
}
res := *u
switch u.Scheme {
case "http":
res.Host = u.Host + ":80"
case "https":
res.Host = u.Host + ":443"
}
return &res
}
func (u *urlEntry) Contains(e Entry) bool {
switch e := e.(type) {
case *urlEntry:
up := ensurePort(u.u)
ep := ensurePort(e.u)
if up.Port() == "" && ep.Port() != "" {
ep.Host = ep.Hostname()
}
return (u.u.Scheme == "" || u.u.Scheme == e.u.Scheme) &&
strings.HasPrefix(e.u.Path, u.u.Path) &&
glob.Glob(up.Host, ep.Host)
}
return false
}
func (u *urlEntry) Match(s string) bool {
q := ParseEntry(s)
query, ok := q.(URLEntry)
if !ok {
return false
}
// copy u to nu ("new u") so we don't modify the record
nu, _ := ParseEntry(u.String()).(URLEntry)
if query.URL().Scheme != "" && nu.URL().Scheme == "" {
query.URL().Scheme = nu.URL().Scheme
} else if nu.URL().Scheme != "" && query.URL().Scheme == "" {
nu.URL().Scheme = query.URL().Scheme
}
return nu.Contains(query)
}
func (u *urlEntry) String() string {
if u.u.Scheme == "" {
return strings.TrimPrefix(u.u.String(), "//")
}
return u.u.String()
}
func (u *urlEntry) Equal(other Entry) bool {
if other, ok := other.(*urlEntry); ok {
up := ensurePort(u.u)
otherp := ensurePort(other.u)
return up.String() == otherp.String()
}
return other.String() == u.u.String()
}
func (u *urlEntry) URL() *url.URL {
return u.u
}
func parseURL(s string) *url.URL {
for _, p := range []string{"", "https://"} {
u, err := url.Parse(p + s)
if err == nil && len(u.Host) > 0 {
if p != "" {
u.Scheme = "" // ignore the scheme
}
return u
}
}
return nil
}

370
vendor/github.com/vmware/vic/pkg/registry/entry_test.go generated vendored Normal file
View File

@@ -0,0 +1,370 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import (
"net"
"testing"
"github.com/stretchr/testify/assert"
)
func TestEntryContains(t *testing.T) {
var tests = []struct {
first, second Entry
res bool
}{
{
first: ParseEntry("192.168.0.1"),
second: ParseEntry("192.168.0.1"),
res: true,
},
{
first: ParseEntry("192.168.0.1"),
second: ParseEntry("192.168.0.1/16"),
res: false,
},
{
first: ParseEntry("192.168.0.1"),
second: ParseEntry("192.168.0.2"),
res: false,
},
{
first: ParseEntry("192.168.0.1/24"),
second: ParseEntry("192.168.0.11"),
res: true,
},
{
first: ParseEntry("172.16.0.0/12"),
second: ParseEntry("172.17.0.0/24"),
res: true,
},
{
first: ParseEntry("172.16.0.0/12"),
second: ParseEntry("172.15.0.0/24"),
res: false,
},
{
first: ParseEntry("172.16.0.0/12"),
second: ParseEntry("*.google.com"),
res: false,
},
{
first: ParseEntry("192.168.0.1/24"),
second: ParseEntry("192.168.1.0"),
res: false,
},
{
first: ParseEntry("192.168.0.1/24"),
second: ParseEntry("192.168.0.1/24"),
res: true,
},
{
first: ParseEntry("*.google.com"),
second: ParseEntry("*.com"),
res: false,
},
{
first: ParseEntry("mail.google.com"),
second: ParseEntry("*.google.com"),
res: false,
},
{
first: ParseEntry("*.google.com"),
second: ParseEntry("mail.google.com"),
res: true,
},
{
first: ParseEntry("*.com"),
second: ParseEntry("*.google.com"),
res: true,
},
{
first: ParseEntry("192.168.1.1:123"),
second: ParseEntry("192.168.1.1"),
res: false,
},
{
first: ParseEntry("foo:123"),
second: ParseEntry("foo"),
res: false,
},
{
first: ParseEntry("foo"),
second: ParseEntry("foo:123"),
res: true,
},
{
first: ParseEntry("192.168.1.1"),
second: ParseEntry("192.168.1.1:123"),
res: true,
},
}
for _, te := range tests {
assert.Equal(t, te.res, te.first.Contains(te.second), "test: %s contains %s", te.first, te.second)
}
}
func TestEntryMatch(t *testing.T) {
var tests = []struct {
e Entry
s string
res bool
}{
{
e: ParseEntry("192.168.0.1"),
s: "192.168.0.1",
res: true,
},
{
e: ParseEntry("192.168.0.1"),
s: "192.168.0",
res: false,
},
{
e: ParseEntry("192.168.0.1/24"),
s: "192.168.0.1",
res: true,
},
{
e: ParseEntry("192.168.0.1/24"),
s: "192.168.1.1",
res: false,
},
{
e: ParseEntry("192.168.0.1/24"),
s: "192.168.0.1/24",
res: true,
},
{
e: ParseEntry("*.google.com"),
s: "mail.google.com",
res: true,
},
{
e: ParseEntry("*.google.com"),
s: "mail.yahoo.com",
res: false,
},
{
e: ParseEntry("*.google.com"),
s: "google.com",
res: false,
},
{
e: ParseEntry("foo:123"),
s: "foo",
res: false,
},
{
e: ParseEntry("foo:123"),
s: "http://foo/bar", // this should be interpreted as http://foo:80/bar
res: false,
},
{
e: ParseEntry("foo:123"),
s: "http://foo:123/bar",
res: true,
},
{
e: ParseEntry("foo:123"),
s: "https://foo:123/bar",
res: true,
},
{
e: ParseEntry("foo"),
s: "foo:123",
res: true,
},
{
e: ParseEntry("192.168.1.1"),
s: "192.168.1.1:123",
res: true,
},
{
e: ParseEntry("http://192.168.1.1"),
s: "http://192.168.1.1",
res: true,
},
{
e: ParseEntry("http://192.168.1.1"),
s: "192.168.1.1/foo/bar",
res: true,
},
{
e: ParseEntry("http://192.168.1.1"),
s: "https://192.168.1.1",
res: false,
},
{
e: ParseEntry("https://192.168.1.1"),
s: "http://192.168.1.1",
res: false,
},
// fqdn and corresponding ip should not match
{
e: ParseEntry("https://google.com"),
s: "216.58.195.78",
res: false,
},
}
for _, te := range tests {
assert.Equal(t, te.res, te.e.Match(te.s), "test: %s match %s", te.e, te.s)
}
}
func TestEntryEqual(t *testing.T) {
var tests = []struct {
e, other Entry
res bool
}{
{
e: ParseEntry("192.168.0.1"),
other: ParseEntry("192.168.0.1"),
res: true,
},
{
e: ParseEntry("192.168.0.1"),
other: ParseEntry("192.168.0.2"),
res: false,
},
{
e: ParseEntry("192.168.0.1"),
other: ParseEntry("192.168.1.0/24"),
res: false,
},
{
e: ParseEntry("192.168.0.1"),
other: ParseEntry("*.google.com"),
res: false,
},
{
e: ParseEntry("192.168.0.1/24"),
other: ParseEntry("192.168.0.1/24"),
res: true,
},
{
e: ParseEntry("192.168.0.1/24"),
other: ParseEntry("192.168.0.1/16"),
res: false,
},
{
e: ParseEntry("192.168.0.1/24"),
other: ParseEntry("192.168.0.1"),
res: false,
},
{
e: ParseEntry("192.168.0.1/24"),
other: ParseEntry("*.google.com"),
res: false,
},
{
e: ParseEntry("*.google.com"),
other: ParseEntry("*.google.com"),
res: true,
},
{
e: ParseEntry("*.google.com"),
other: ParseEntry("mail.google.com"),
res: false,
},
{
e: ParseEntry("*.google.com"),
other: ParseEntry("*.yahoo.com"),
res: false,
},
{
e: ParseEntry("*.google.com"),
other: ParseEntry("192.168.0.1"),
res: false,
},
{
e: ParseEntry("*.google.com"),
other: ParseEntry("192.168.0.1/24"),
res: false,
},
}
for _, te := range tests {
assert.Equal(t, te.res, te.e.Equal(te.other), "test: %s equal %s", te.e, te.other)
}
}
func TestParseEntry(t *testing.T) {
var tests = []struct {
s string
res Entry
}{
{
s: "foo bar",
},
{
s: "192.168.0.1",
res: &urlEntry{u: parseURL("192.168.0.1")},
},
{
s: "192.168.0.1:80",
res: &urlEntry{u: parseURL("192.168.0.1:80")},
},
{
s: "192.168.0",
res: &urlEntry{u: parseURL("192.168.0")},
},
{
s: "192.168.0.1/24",
res: &cidrEntry{ipnet: &net.IPNet{IP: net.ParseIP("192.168.0.0"), Mask: net.CIDRMask(24, 32)}},
},
{
s: "192.168.0/24",
res: &urlEntry{u: parseURL("192.168.0/24")},
},
{
s: "*.google.com",
res: &urlEntry{u: parseURL("*.google.com")},
},
{
s: "google.com",
res: &urlEntry{u: parseURL("google.com")},
},
{
s: "google.com:8080",
res: &urlEntry{u: parseURL("google.com:8080")},
},
{
s: "http://*.google.com",
res: &urlEntry{u: parseURL("http://*.google.com")},
},
{
s: "http://google.com",
res: &urlEntry{u: parseURL("http://google.com")},
},
{
s: "http://google.com:8080",
res: &urlEntry{u: parseURL("http://google.com:8080")},
},
}
for _, te := range tests {
res := ParseEntry(te.s)
if te.res == nil {
assert.Nil(t, res, "ParseEntry(%s) != %s, got %s", te.s, te.res, res)
continue
}
assert.True(t, te.res.Equal(res), "ParseEntry(%s) != %s, got %s", te.s, te.res, res)
}
}

View File

@@ -0,0 +1,107 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import mock "github.com/stretchr/testify/mock"
// MockEntry is an autogenerated mock type for the Entry type
type MockEntry struct {
mock.Mock
}
// Contains provides a mock function with given fields: e
func (_m *MockEntry) Contains(e Entry) bool {
ret := _m.Called(e)
var r0 bool
if rf, ok := ret.Get(0).(func(Entry) bool); ok {
r0 = rf(e)
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// Equal provides a mock function with given fields: other
func (_m *MockEntry) Equal(other Entry) bool {
ret := _m.Called(other)
var r0 bool
if rf, ok := ret.Get(0).(func(Entry) bool); ok {
r0 = rf(other)
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// IsCIDR provides a mock function with given fields:
func (_m *MockEntry) IsCIDR() bool {
ret := _m.Called()
var r0 bool
if rf, ok := ret.Get(0).(func() bool); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// IsURL provides a mock function with given fields:
func (_m *MockEntry) IsURL() bool {
ret := _m.Called()
var r0 bool
if rf, ok := ret.Get(0).(func() bool); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// Match provides a mock function with given fields: e
func (_m *MockEntry) Match(e string) bool {
ret := _m.Called(e)
var r0 bool
if rf, ok := ret.Get(0).(func(string) bool); ok {
r0 = rf(e)
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// String provides a mock function with given fields:
func (_m *MockEntry) String() string {
ret := _m.Called()
var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}
return r0
}
var _ Entry = (*MockEntry)(nil)

View File

@@ -0,0 +1,46 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import mock "github.com/stretchr/testify/mock"
// MockMerger is an autogenerated mock type for the Merger type
type MockMerger struct {
mock.Mock
}
// Merge provides a mock function with given fields: _a0, _a1
func (_m *MockMerger) Merge(_a0 Entry, _a1 Entry) (Entry, error) {
ret := _m.Called(_a0, _a1)
var r0 Entry
if rf, ok := ret.Get(0).(func(Entry, Entry) Entry); ok {
r0 = rf(_a0, _a1)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(Entry)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(Entry, Entry) error); ok {
r1 = rf(_a0, _a1)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
var _ Merger = (*MockMerger)(nil)

81
vendor/github.com/vmware/vic/pkg/registry/set.go generated vendored Normal file
View File

@@ -0,0 +1,81 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
type Set []Entry
type Merger interface {
Merge(Entry, Entry) (Entry, error)
}
type defaultMerger struct{}
func (m *defaultMerger) Merge(orig, other Entry) (Entry, error) {
if orig.String() == other.String() {
return other, nil
}
return nil, nil
}
func (s Set) Match(m string) bool {
for _, e := range s {
if e.Match(m) {
return true
}
}
return false
}
func (s Set) Merge(other Set, merger Merger) (Set, error) {
if merger == nil {
merger = &defaultMerger{}
}
res := make([]Entry, len(s))
var adds Set
copy(res, s)
for _, o := range other {
merged := false
for i := 0; i < len(res); i++ {
e, err := merger.Merge(res[i], o)
if err != nil {
return nil, err
}
if e != nil {
res[i] = e
merged = true
break
}
}
if !merged {
adds = append(adds, o)
}
}
return append(res, adds...), nil
}
func (s Set) Strings() []string {
res := make([]string, len(s))
for i := range s {
res[i] = s[i].String()
}
return res
}

127
vendor/github.com/vmware/vic/pkg/registry/set_test.go generated vendored Normal file
View File

@@ -0,0 +1,127 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func TestSetMerge(t *testing.T) {
var tests = []struct {
orig, other Set
res Set
err error
}{
{},
{
orig: nil,
other: Set{ParseEntry("192.168.0.1")},
res: Set{ParseEntry("192.168.0.1")},
},
{
orig: Set{ParseEntry("192.168.0.1")},
other: nil,
res: Set{ParseEntry("192.168.0.1")},
},
{
orig: Set{ParseEntry("192.168.0.1")},
other: Set{ParseEntry("192.168.0.1")},
res: Set{ParseEntry("192.168.0.1")},
},
{
orig: Set{ParseEntry("192.168.0.1")},
other: Set{ParseEntry("192.168.0.2")},
res: Set{
ParseEntry("192.168.0.1"),
ParseEntry("192.168.0.2"),
},
},
{
orig: Set{
ParseEntry("192.168.0.1"),
ParseEntry("192.168.0.2"),
},
other: Set{
ParseEntry("192.168.0.2"),
},
res: Set{
ParseEntry("192.168.0.1"),
ParseEntry("192.168.0.2"),
},
},
{
orig: Set{
ParseEntry("192.168.0.1"),
ParseEntry("192.168.0.2"),
},
other: Set{
ParseEntry("192.168.0.3"),
},
res: Set{
ParseEntry("192.168.0.1"),
ParseEntry("192.168.0.2"),
ParseEntry("192.168.0.3"),
},
},
}
for _, te := range tests {
res, err := te.orig.Merge(te.other, nil)
assert.Equal(t, te.err, err)
assert.Len(t, res, len(te.res))
for _, r := range res {
found := false
for _, r2 := range te.res {
if r2.String() == r.String() {
found = true
break
}
}
assert.True(t, found)
}
}
}
func TestSetMergeMergerError(t *testing.T) {
m := &MockMerger{}
m.On("Merge", mock.Anything, mock.Anything).Return(nil, assert.AnError)
s := Set{ParseEntry("192.168.0.1")}
other := Set{ParseEntry("192.168.0.1")}
res, err := s.Merge(other, m)
assert.Nil(t, res)
assert.Error(t, err)
assert.EqualValues(t, assert.AnError, err)
}
func TestSetMatch(t *testing.T) {
e1 := &MockEntry{}
e1.On("Match", mock.Anything).Return(false)
e2 := &MockEntry{}
e2.On("Match", mock.Anything).Return(true)
s := Set{e1, e2}
assert.True(t, s.Match("foo"))
s = Set{e2}
assert.True(t, s.Match("foo"))
s = Set{e1}
assert.False(t, s.Match("foo"))
}

58
vendor/github.com/vmware/vic/pkg/registry/utils.go generated vendored Normal file
View File

@@ -0,0 +1,58 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package registry
import (
"crypto/x509"
"fmt"
"net/url"
"time"
log "github.com/Sirupsen/logrus"
urlfetcher "github.com/vmware/vic/pkg/fetcher"
)
// Reachable test if a registry is a valid registry for VIC use and returns a url with scheme prepended
func Reachable(registry, scheme, username, password string, registryCAs *x509.CertPool, timeout time.Duration, skipVerify bool) (string, error) {
registryPath := fmt.Sprintf("%s/v2/", registry)
if scheme != "" {
registryPath = fmt.Sprintf("%s://%s/v2/", scheme, registry)
}
url, err := url.Parse(registryPath)
if err != nil {
return "", err
}
log.Debugf("URL: %s", url)
fetcher := urlfetcher.NewURLFetcher(urlfetcher.Options{
Timeout: timeout,
Username: username,
Password: password,
InsecureSkipVerify: skipVerify,
RootCAs: registryCAs,
})
headers, err := fetcher.Head(url)
if err != nil {
return "", err
}
// v2 API requires this check
if headers.Get("Docker-Distribution-API-Version") != "registry/2.0" {
return "", fmt.Errorf("Missing Docker-Distribution-API-Version header")
}
return registryPath, nil
}