Fix mispelling

* s/convertor/converter
* s/Convertor/Converter

Signed-off-by: clouderati <35942204+clouderati@users.noreply.github.com>
This commit is contained in:
clouderati 2018-10-25 21:29:46 +00:00
parent a48ae01e4b
commit 5c47e83bd6
18 changed files with 59 additions and 59 deletions

View File

@ -4,13 +4,13 @@ import (
"github.com/goharbor/harbor/src/replication/models"
)
// Convertor is designed to covert the format of output from upstream filter to the input format
// Converter is designed to covert the format of output from upstream filter to the input format
// required by the downstream filter if needed.
// Each convertor covers only one specified conversion process between the two filters.
// Each converter covers only one specified conversion process between the two filters.
// E.g:
// If project filter connects to repository filter, then one convertor should be defined for this connection;
// If project filter connects to repository filter, then one converter should be defined for this connection;
// If project filter connects to tag filter, then another one should be defined. The above one can not be reused.
type Convertor interface {
type Converter interface {
// Accept the items from upstream filter as input and then covert them to the required format and returned.
Convert(itemsOfUpstream []models.FilterItem) (itemsOfDownstream []models.FilterItem)
}

View File

@ -47,9 +47,9 @@ func (d *DefaultFilterChain) DoFilter(filterItems []models.FilterItem) []models.
}
for _, filter := range d.filters {
convertor := filter.GetConvertor()
if convertor != nil {
filterItems = convertor.Convert(filterItems)
converter := filter.GetConverter()
if converter != nil {
filterItems = converter.Convert(filterItems)
}
filterItems = filter.DoFilter(filterItems)
}

View File

@ -37,7 +37,7 @@ func TestFilters(t *testing.T) {
func TestDoFilter(t *testing.T) {
projectFilter := NewPatternFilter(replication.FilterItemKindProject, "library*")
repositoryFilter := NewPatternFilter(replication.FilterItemKindRepository,
"library/ubuntu*", &fakeRepositoryConvertor{})
"library/ubuntu*", &fakeRepositoryConverter{})
filters := []Filter{projectFilter, repositoryFilter}
items := []models.FilterItem{
@ -61,9 +61,9 @@ func TestDoFilter(t *testing.T) {
}
type fakeRepositoryConvertor struct{}
type fakeRepositoryConverter struct{}
func (f *fakeRepositoryConvertor) Convert(items []models.FilterItem) []models.FilterItem {
func (f *fakeRepositoryConverter) Convert(items []models.FilterItem) []models.FilterItem {
result := []models.FilterItem{}
for _, item := range items {
result = append(result, models.FilterItem{

View File

@ -10,8 +10,8 @@ type Filter interface {
// Initialize the filter
Init() error
// Return the convertor if existing or nil if never set
GetConvertor() Convertor
// Return the converter if existing or nil if never set
GetConverter() Converter
// Filter the items
DoFilter(filterItems []models.FilterItem) []models.FilterItem

View File

@ -34,8 +34,8 @@ func (l *LabelFilter) Init() error {
return nil
}
// GetConvertor ...
func (l *LabelFilter) GetConvertor() Convertor {
// GetConverter ...
func (l *LabelFilter) GetConverter() Converter {
return nil
}

View File

@ -29,9 +29,9 @@ func TestInitOfLabelFilter(t *testing.T) {
assert.Nil(t, filter.Init())
}
func TestGetConvertorOfLabelFilter(t *testing.T) {
func TestGetConverterOfLabelFilter(t *testing.T) {
filter := NewLabelFilter(1)
assert.Nil(t, filter.GetConvertor())
assert.Nil(t, filter.GetConverter())
}
func TestDoFilterOfLabelFilter(t *testing.T) {

View File

@ -25,18 +25,18 @@ import (
type PatternFilter struct {
kind string
pattern string
convertor Convertor
converter Converter
}
// NewPatternFilter returns an instance of PatternFilter
func NewPatternFilter(kind, pattern string, convertor ...Convertor) *PatternFilter {
func NewPatternFilter(kind, pattern string, converter ...Converter) *PatternFilter {
filer := &PatternFilter{
kind: kind,
pattern: pattern,
}
if len(convertor) > 0 {
filer.convertor = convertor[0]
if len(converter) > 0 {
filer.converter = converter[0]
}
return filer
@ -47,9 +47,9 @@ func (p *PatternFilter) Init() error {
return nil
}
// GetConvertor returns the convertor
func (p *PatternFilter) GetConvertor() Convertor {
return p.convertor
// GetConverter returns the converter
func (p *PatternFilter) GetConverter() Converter {
return p.converter
}
// DoFilter filters resources

View File

@ -28,8 +28,8 @@ func TestPatternFilterInit(t *testing.T) {
assert.Nil(t, pfilter.Init())
}
func TestPatternFilterGetConvertor(t *testing.T) {
assert.Nil(t, pfilter.GetConvertor())
func TestPatternFilterGetConverter(t *testing.T) {
assert.Nil(t, pfilter.GetConverter())
}
func TestPatternFilterDoFilter(t *testing.T) {

View File

@ -20,20 +20,20 @@ import (
"github.com/goharbor/harbor/src/replication/registry"
)
// RepositoryConvertor implement Convertor interface, convert projects to repositories
type RepositoryConvertor struct {
// RepositoryConverter implement Converter interface, convert projects to repositories
type RepositoryConverter struct {
registry registry.Adaptor
}
// NewRepositoryConvertor returns an instance of RepositoryConvertor
func NewRepositoryConvertor(registry registry.Adaptor) *RepositoryConvertor {
return &RepositoryConvertor{
// NewRepositoryConverter returns an instance of RepositoryConverter
func NewRepositoryConverter(registry registry.Adaptor) *RepositoryConverter {
return &RepositoryConverter{
registry: registry,
}
}
// Convert projects to repositories
func (r *RepositoryConvertor) Convert(items []models.FilterItem) []models.FilterItem {
func (r *RepositoryConverter) Convert(items []models.FilterItem) []models.FilterItem {
result := []models.FilterItem{}
for _, item := range items {
// just put it to the result list if the item is not a project

View File

@ -46,8 +46,8 @@ func TestRepositoryConvert(t *testing.T) {
},
}
convertor := NewRepositoryConvertor(&fakeRegistryAdaptor{})
assert.EqualValues(t, expected, convertor.Convert(items))
converter := NewRepositoryConverter(&fakeRegistryAdaptor{})
assert.EqualValues(t, expected, converter.Convert(items))
}
type fakeRegistryAdaptor struct{}

View File

@ -27,14 +27,14 @@ import (
// RepositoryFilter implement Filter interface to filter repository
type RepositoryFilter struct {
pattern string
convertor Convertor
converter Converter
}
// NewRepositoryFilter returns an instance of RepositoryFilter
func NewRepositoryFilter(pattern string, registry registry.Adaptor) *RepositoryFilter {
return &RepositoryFilter{
pattern: pattern,
convertor: NewRepositoryConvertor(registry),
converter: NewRepositoryConverter(registry),
}
}
@ -43,9 +43,9 @@ func (r *RepositoryFilter) Init() error {
return nil
}
// GetConvertor ...
func (r *RepositoryFilter) GetConvertor() Convertor {
return r.convertor
// GetConverter ...
func (r *RepositoryFilter) GetConverter() Converter {
return r.converter
}
// DoFilter filters repository and image(according to the repository part) and drops any other resource types

View File

@ -28,9 +28,9 @@ func TestInitOfRepositoryFilter(t *testing.T) {
assert.Nil(t, filter.Init())
}
func TestGetConvertorOfRepositoryFilter(t *testing.T) {
func TestGetConverterOfRepositoryFilter(t *testing.T) {
filter := NewRepositoryFilter("", &registry.HarborAdaptor{})
assert.NotNil(t, filter.GetConvertor())
assert.NotNil(t, filter.GetConverter())
}
func TestDoFilterOfRepositoryFilter(t *testing.T) {

View File

@ -36,8 +36,8 @@ func (t *TagCombinationFilter) Init() error {
return nil
}
// GetConvertor returns the convertor
func (t *TagCombinationFilter) GetConvertor() Convertor {
// GetConverter returns the converter
func (t *TagCombinationFilter) GetConverter() Converter {
return nil
}

View File

@ -28,8 +28,8 @@ func TestTagCombinationFilterInit(t *testing.T) {
assert.Nil(t, tcfilter.Init())
}
func TestTagCombinationFilterGetConvertor(t *testing.T) {
assert.Nil(t, tcfilter.GetConvertor())
func TestTagCombinationFilterGetConverter(t *testing.T) {
assert.Nil(t, tcfilter.GetConverter())
}
func TestTagCombinationFilterDoFilter(t *testing.T) {

View File

@ -20,20 +20,20 @@ import (
"github.com/goharbor/harbor/src/replication/registry"
)
// TagConvertor implement Convertor interface, convert repositories to tags
type TagConvertor struct {
// TagConverter implement Converter interface, convert repositories to tags
type TagConverter struct {
registry registry.Adaptor
}
// NewTagConvertor returns an instance of TagConvertor
func NewTagConvertor(registry registry.Adaptor) *TagConvertor {
return &TagConvertor{
// NewTagConverter returns an instance of TagConverter
func NewTagConverter(registry registry.Adaptor) *TagConverter {
return &TagConverter{
registry: registry,
}
}
// Convert repositories to tags
func (t *TagConvertor) Convert(items []models.FilterItem) []models.FilterItem {
func (t *TagConverter) Convert(items []models.FilterItem) []models.FilterItem {
result := []models.FilterItem{}
for _, item := range items {
if item.Kind != replication.FilterItemKindRepository {

View File

@ -46,6 +46,6 @@ func TestTagConvert(t *testing.T) {
},
}
convertor := NewTagConvertor(&fakeRegistryAdaptor{})
assert.EqualValues(t, expected, convertor.Convert(items))
converter := NewTagConverter(&fakeRegistryAdaptor{})
assert.EqualValues(t, expected, converter.Convert(items))
}

View File

@ -26,14 +26,14 @@ import (
// TagFilter implements Filter interface to filter tag
type TagFilter struct {
pattern string
convertor Convertor
converter Converter
}
// NewTagFilter returns an instance of TagFilter
func NewTagFilter(pattern string, registry registry.Adaptor) *TagFilter {
return &TagFilter{
pattern: pattern,
convertor: NewTagConvertor(registry),
converter: NewTagConverter(registry),
}
}
@ -42,9 +42,9 @@ func (t *TagFilter) Init() error {
return nil
}
// GetConvertor ...
func (t *TagFilter) GetConvertor() Convertor {
return t.convertor
// GetConverter ...
func (t *TagFilter) GetConverter() Converter {
return t.converter
}
// DoFilter filters tag of the image

View File

@ -28,9 +28,9 @@ func TestInitOfTagFilter(t *testing.T) {
assert.Nil(t, filter.Init())
}
func TestGetConvertorOfTagFilter(t *testing.T) {
func TestGetConverterOfTagFilter(t *testing.T) {
filter := NewTagFilter("", &registry.HarborAdaptor{})
assert.NotNil(t, filter.GetConvertor())
assert.NotNil(t, filter.GetConverter())
}
func TestDoFilterOfTagFilter(t *testing.T) {