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

Integrate depresolver #192

Merged
merged 1 commit into from
Oct 30, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions controllers/depresolver/depresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ type Config struct {
EdgeDNSZone string
// DNSZone controlled by gslb; e.g. cloud.example.com
DNSZone string
// DNSTypeRoute53 switch
// TODO: hide for depresolver subscriber as depresolver retrieves EdgeDNSType. Maybe we can change configuration and set EdgeDNSType directly instead of DNSTypeRoute53 boolean
Route53Enabled bool
// Infoblox configuration
Infoblox Infoblox
// Override the behavior of GSLB in the test environments
Override Override
// route53Enabled hidden. EdgeDNSType defines all enabled Enabled types
route53Enabled bool
}

// DependencyResolver resolves configuration for GSLB
Expand Down
4 changes: 2 additions & 2 deletions controllers/depresolver/depresolver_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (dr *DependencyResolver) ResolveOperatorConfig() (*Config, error) {
dr.config.ReconcileRequeueSeconds, _ = env.GetEnvAsIntOrFallback(ReconcileRequeueSecondsKey, 30)
dr.config.ClusterGeoTag = env.GetEnvAsStringOrFallback(ClusterGeoTagKey, "")
dr.config.ExtClustersGeoTags = env.GetEnvAsArrayOfStringsOrFallback(ExtClustersGeoTagsKey, []string{})
dr.config.Route53Enabled = env.GetEnvAsBoolOrFallback(Route53EnabledKey, false)
dr.config.route53Enabled = env.GetEnvAsBoolOrFallback(Route53EnabledKey, false)
dr.config.EdgeDNSServer = env.GetEnvAsStringOrFallback(EdgeDNSServerKey, "")
dr.config.EdgeDNSZone = env.GetEnvAsStringOrFallback(EdgeDNSZoneKey, "")
dr.config.DNSZone = env.GetEnvAsStringOrFallback(DNSZoneKey, "")
Expand Down Expand Up @@ -110,7 +110,7 @@ func (dr *DependencyResolver) validateConfig(config *Config) (err error) {
// getEdgeDNSType contains logic retrieving EdgeDNSType
func getEdgeDNSType(config *Config) EdgeDNSType {
var t = DNSTypeNoEdgeDNS
if config.Route53Enabled {
if config.route53Enabled {
t = t | DNSTypeRoute53
}
if isNotEmpty(config.Infoblox.Host) {
Expand Down
45 changes: 22 additions & 23 deletions controllers/depresolver/depresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@ import (
)

var predefinedConfig = Config{
30,
"us",
[]string{"uk", "eu"},
DNSTypeInfoblox,
"cloud.example.com",
"8.8.8.8",
"example.com",
false,
Infoblox{
ReconcileRequeueSeconds: 30,
ClusterGeoTag: "us",
ExtClustersGeoTags: []string{"uk", "eu"},
EdgeDNSType: DNSTypeInfoblox,
EdgeDNSServer: "cloud.example.com",
EdgeDNSZone: "8.8.8.8",
DNSZone: "example.com",
Infoblox: Infoblox{
"Infoblox.host.com",
"0.0.3",
443,
"Infoblox",
"secret",
},
Override{
Override: Override{
false,
false,
},
Expand Down Expand Up @@ -268,14 +267,14 @@ func TestResolveConfigWithMalformedRoute53Enabled(t *testing.T) {
config, err := resolver.ResolveOperatorConfig()
// assert
assert.NoError(t, err)
assert.Equal(t, false, config.Route53Enabled)
assert.Equal(t, false, config.route53Enabled)
}

func TestResolveConfigWithProperRoute53Enabled(t *testing.T) {
// arrange
defer cleanup()
expected := predefinedConfig
expected.Route53Enabled = true
expected.route53Enabled = true
expected.Infoblox.Host = ""
expected.EdgeDNSType = DNSTypeRoute53
// act,assert
Expand All @@ -286,7 +285,7 @@ func TestResolveConfigWithoutRoute53(t *testing.T) {
// arrange
defer cleanup()
expected := predefinedConfig
expected.Route53Enabled = false
expected.route53Enabled = false
// act,assert
arrangeVariablesAndAssert(t, expected, assert.NoError, Route53EnabledKey)
}
Expand All @@ -302,7 +301,7 @@ func TestResolveConfigWithEmptyRoute53(t *testing.T) {
config, err := resolver.ResolveOperatorConfig()
// assert
assert.NoError(t, err)
assert.Equal(t, false, config.Route53Enabled)
assert.Equal(t, false, config.route53Enabled)
}

func TestResolveConfigWithEmptyEdgeDnsServer(t *testing.T) {
Expand Down Expand Up @@ -503,7 +502,7 @@ func TestRoute53IsEnabledAndInfobloxIsConfigured(t *testing.T) {
// arrange
defer cleanup()
expected := predefinedConfig
expected.Route53Enabled = true
expected.route53Enabled = true
expected.EdgeDNSType = DNSTypeRoute53 | DNSTypeInfoblox
expected.Infoblox.Host = "Infoblox.domain"
expected.Infoblox.Version = "0.0.1"
Expand All @@ -519,7 +518,7 @@ func TestRoute53IsDisabledAndInfobloxIsNotConfigured(t *testing.T) {
defer cleanup()
expected := predefinedConfig
expected.EdgeDNSType = DNSTypeNoEdgeDNS
expected.Route53Enabled = false
expected.route53Enabled = false
expected.Infoblox.Host = ""
// act,assert
// that's how our integration tests are running
Expand All @@ -530,7 +529,7 @@ func TestRoute53IsDisabledButInfobloxIsConfigured(t *testing.T) {
// arrange
defer cleanup()
expected := predefinedConfig
expected.Route53Enabled = false
expected.route53Enabled = false
expected.EdgeDNSType = DNSTypeInfoblox
expected.Infoblox.Host = "Infoblox.domain"
expected.Infoblox.Version = "0.0.1"
Expand All @@ -545,7 +544,7 @@ func TestRoute53IsEnabledButInfobloxIsNotConfigured(t *testing.T) {
// arrange
defer cleanup()
expected := predefinedConfig
expected.Route53Enabled = true
expected.route53Enabled = true
expected.EdgeDNSType = DNSTypeRoute53
expected.Infoblox.Host = ""
expected.Infoblox.Version = "0.0.1"
Expand All @@ -561,7 +560,7 @@ func TestInfobloxGridHostIsEmpty(t *testing.T) {
defer cleanup()
expected := predefinedConfig
expected.EdgeDNSType = DNSTypeRoute53
expected.Route53Enabled = true
expected.route53Enabled = true
expected.Infoblox.Host = ""
expected.Infoblox.Version = ""
expected.Infoblox.Port = 0
Expand Down Expand Up @@ -604,7 +603,7 @@ func TestInfobloxGridHostIsEmptyButInfobloxPropsAreFilled(t *testing.T) {
defer cleanup()
expected := predefinedConfig
expected.EdgeDNSType = DNSTypeRoute53
expected.Route53Enabled = true
expected.route53Enabled = true
expected.Infoblox.Host = ""
expected.Infoblox.Version = "0.0.1"
expected.Infoblox.Port = 443
Expand All @@ -619,7 +618,7 @@ func TestInfobloxGridHostIsUnset(t *testing.T) {
defer cleanup()
expected := predefinedConfig
expected.EdgeDNSType = DNSTypeNoEdgeDNS
expected.Route53Enabled = false
expected.route53Enabled = false
expected.Infoblox.Host = ""
expected.Infoblox.Version = "0.0.1"
expected.Infoblox.Port = 443
Expand All @@ -635,7 +634,7 @@ func TestInfobloxGridHostIsInvalid(t *testing.T) {
defer cleanup()
expected := predefinedConfig
expected.EdgeDNSType = DNSTypeInfoblox
expected.Route53Enabled = false
expected.route53Enabled = false
expected.Infoblox.Host = "dnfkjdnf kj"
expected.Infoblox.Version = "0.0.1"
expected.Infoblox.Port = 443
Expand Down Expand Up @@ -906,7 +905,7 @@ func configureEnvVar(config Config) {
_ = os.Setenv(EdgeDNSServerKey, config.EdgeDNSServer)
_ = os.Setenv(EdgeDNSZoneKey, config.EdgeDNSZone)
_ = os.Setenv(DNSZoneKey, config.DNSZone)
_ = os.Setenv(Route53EnabledKey, strconv.FormatBool(config.Route53Enabled))
_ = os.Setenv(Route53EnabledKey, strconv.FormatBool(config.route53Enabled))
_ = os.Setenv(InfobloxGridHostKey, config.Infoblox.Host)
_ = os.Setenv(InfobloxVersionKey, config.Infoblox.Version)
_ = os.Setenv(InfobloxPortKey, strconv.Itoa(config.Infoblox.Port))
Expand Down
Loading