feat: labels/annotations parser.

This commit is contained in:
Fernandez Ludovic 2017-12-02 19:25:29 +01:00 committed by Traefiker
parent dc74f76a03
commit ce6bbbaa33
8 changed files with 1361 additions and 14 deletions

View file

@ -95,8 +95,8 @@ func (p *Provider) scanTable(client *dynamoClient) ([]map[string]*dynamodb.Attri
return items, nil
}
// loadDynamoConfig retrieves items from dynamodb and converts them into Backends and Frontends in a Configuration
func (p *Provider) loadDynamoConfig(client *dynamoClient) (*types.Configuration, error) {
// buildConfiguration retrieves items from dynamodb and converts them into Backends and Frontends in a Configuration
func (p *Provider) buildConfiguration(client *dynamoClient) (*types.Configuration, error) {
items, err := p.scanTable(client)
if err != nil {
return nil, err
@ -167,7 +167,7 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
return handleCanceled(ctx, err)
}
configuration, err := p.loadDynamoConfig(awsClient)
configuration, err := p.buildConfiguration(awsClient)
if err != nil {
return handleCanceled(ctx, err)
}
@ -184,7 +184,7 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
log.Debug("Watching Provider...")
select {
case <-reload.C:
configuration, err := p.loadDynamoConfig(awsClient)
configuration, err := p.buildConfiguration(awsClient)
if err != nil {
return handleCanceled(ctx, err)
}

View file

@ -84,14 +84,14 @@ func (m *mockDynamoDBClient) ScanPages(input *dynamodb.ScanInput, fn func(*dynam
return nil
}
func TestLoadDynamoConfigSuccessful(t *testing.T) {
func TestBuildConfigurationSuccessful(t *testing.T) {
dbiface := &dynamoClient{
db: &mockDynamoDBClient{
testWithError: false,
},
}
provider := Provider{}
loadedConfig, err := provider.loadDynamoConfig(dbiface)
loadedConfig, err := provider.buildConfiguration(dbiface)
if err != nil {
t.Fatal(err)
}
@ -108,14 +108,14 @@ func TestLoadDynamoConfigSuccessful(t *testing.T) {
}
}
func TestLoadDynamoConfigFailure(t *testing.T) {
func TestBuildConfigurationFailure(t *testing.T) {
dbiface := &dynamoClient{
db: &mockDynamoDBClient{
testWithError: true,
},
}
provider := Provider{}
_, err := provider.loadDynamoConfig(dbiface)
_, err := provider.buildConfiguration(dbiface)
if err == nil {
t.Fatal("Expected error")
}