Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
related to (#170)
The primary purpose of this improvement is to read all k8gb input at one place, validate it and provide to GSLB in typed, well-formatted way. Depresolver is a single point of k8gb inputs now and fail-fast with proper error message if inputs are incorrect.
Inputs:
spec
config
Validations
We implement the new validator, applying various rules to each input.
Tests
75% coverage checking depresolver works as expected. Extensive coverage allow us to make safe refactoring.
Because I introduced new validation rules, I had to update controller_tests.
EdgeDNSType
Providing new computed property EdgeDNSType telling which configuration(s) loaded to depresolver. This allows us to write conditions like
which overall simplify logic and helps in case we provide EdgeDNS implementations by Factory
depresolver as single point of environment variables names
So we are not using names like "DNS_ZONE" directly. Instead, we use depresolver.DnsZone constant. I replaced variables in controller_tests while the DNS code will not access inputs directly. Will be part of following PR.
TODO:
Will follow in next PR (s). Thanks to validator, we can remove validations from GSLB logic and simplify code. Also, accessing depresolver instead of direct access environment variables will enhance code readability. We can more concentrate on DNS logic rather than checking inputs. It will require changes in the code that I postpone to the next PR, because this PR is too large.