Merge pull request #7664 from ywk253100/190507_adapter

Rename the adapter name of docker registry
This commit is contained in:
Wenkai Yin 2019-05-07 17:24:59 +08:00 committed by GitHub
commit 78aea0920d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 12 deletions

View File

@ -20,16 +20,14 @@ import (
"github.com/goharbor/harbor/src/replication/model"
)
const registryTypeNative model.RegistryType = "native"
func init() {
if err := adp.RegisterFactory(registryTypeNative, func(registry *model.Registry) (adp.Adapter, error) {
if err := adp.RegisterFactory(model.RegistryTypeDockerRegistry, func(registry *model.Registry) (adp.Adapter, error) {
return newAdapter(registry)
}); err != nil {
log.Errorf("failed to register factory for %s: %v", registryTypeNative, err)
log.Errorf("failed to register factory for %s: %v", model.RegistryTypeDockerRegistry, err)
return
}
log.Infof("the factory for adapter %s registered", registryTypeNative)
log.Infof("the factory for adapter %s registered", model.RegistryTypeDockerRegistry)
}
func newAdapter(registry *model.Registry) (*native, error) {
@ -52,7 +50,7 @@ var _ adp.Adapter = native{}
func (native) Info() (info *model.RegistryInfo, err error) {
return &model.RegistryInfo{
Type: registryTypeNative,
Type: model.RegistryTypeDockerRegistry,
SupportedResourceTypes: []model.ResourceType{
model.ResourceTypeImage,
},

View File

@ -57,7 +57,7 @@ func Test_native_Info(t *testing.T) {
var info, err = adapter.Info()
assert.Nil(t, err)
assert.NotNil(t, info)
assert.Equal(t, registryTypeNative, info.Type)
assert.Equal(t, model.RegistryTypeDockerRegistry, info.Type)
assert.Equal(t, 1, len(info.SupportedResourceTypes))
assert.Equal(t, 2, len(info.SupportedResourceFilters))
assert.Equal(t, 2, len(info.SupportedTriggers))

View File

@ -65,7 +65,7 @@ func Test_native_FetchImages(t *testing.T) {
fmt.Println("mockNativeRegistry URL: ", mock.URL)
var registry = &model.Registry{
Type: registryTypeNative,
Type: model.RegistryTypeDockerRegistry,
URL: mock.URL,
Insecure: true,
}

View File

@ -22,10 +22,10 @@ import (
// const definition
const (
// RegistryTypeHarbor indicates registry type harbor
RegistryTypeHarbor RegistryType = "harbor"
RegistryTypeDockerHub RegistryType = "dockerHub"
RegistryTypeHuawei RegistryType = "Huawei"
RegistryTypeHarbor RegistryType = "harbor"
RegistryTypeDockerHub RegistryType = "docker-hub"
RegistryTypeDockerRegistry RegistryType = "docker-registry"
RegistryTypeHuawei RegistryType = "huawei"
FilterStyleTypeText = "input"
FilterStyleTypeRadio = "radio"