Skip to content

Commit

Permalink
Merge pull request #85 from akamai/dns_maint
Browse files Browse the repository at this point in the history
filterZoneCreate check upper case Type
  • Loading branch information
edglynes authored Apr 26, 2020
2 parents 1753fe4 + 6f430d3 commit 8db108f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions configdns-v2/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"reflect"
"sync"
"strings"
)

var (
Expand Down Expand Up @@ -482,6 +483,7 @@ func (zone *ZoneCreate) Delete(zonequerystring ZoneQueryString) error {

func filterZoneCreate(zone *ZoneCreate) map[string]interface{} {

zoneType := strings.ToUpper(zone.Type)
filteredZone := make(map[string]interface{})
zoneElems := reflect.ValueOf(zone).Elem()
for i := 0; i < zoneElems.NumField(); i++ {
Expand All @@ -490,23 +492,23 @@ func filterZoneCreate(zone *ZoneCreate) map[string]interface{} {
varValue := zoneElems.Field(i).Interface()
switch varName {
case "Target":
if zone.Type == "ALIAS" {
if zoneType == "ALIAS" {
filteredZone[varLower] = varValue
}
case "TsigKey":
if zone.Type == "SECONDARY" {
if zoneType == "SECONDARY" {
filteredZone[varLower] = varValue
}
case "Masters":
if zone.Type == "SECONDARY" {
if zoneType == "SECONDARY" {
filteredZone[varLower] = varValue
}
case "SignAndServe":
if zone.Type != "ALIAS" {
if zoneType != "ALIAS" {
filteredZone[varLower] = varValue
}
case "SignAndServeAlgorithm":
if zone.Type != "ALIAS" {
if zoneType != "ALIAS" {
filteredZone[varLower] = varValue
}
default:
Expand Down

0 comments on commit 8db108f

Please sign in to comment.