Skip to content

Commit

Permalink
Refactoring: constant for "hostedzone:" (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWeindel authored and mandelsoft committed Feb 18, 2019
1 parent fc17227 commit 35767e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
10 changes: 7 additions & 3 deletions pkg/dns/provider/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ package provider
Standard options a DNS Reconciler should offer
*/

const OPT_IDENTIFIER = "identifier"
const OPT_DRYRUN = "dry-run"
const OPT_TTL = "ttl"
const (
OPT_IDENTIFIER = "identifier"
OPT_DRYRUN = "dry-run"
OPT_TTL = "ttl"

HOSTEDZONE_PREFIX = "hostedzone:"
)
5 changes: 3 additions & 2 deletions pkg/dns/provider/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package provider

import (
"time"

"github.com/gardener/external-dns-management/pkg/crds"
"github.com/gardener/external-dns-management/pkg/dns/source"
"time"

"github.com/gardener/controller-manager-library/pkg/controllermanager/controller"
"github.com/gardener/controller-manager-library/pkg/controllermanager/controller/reconcile"
Expand Down Expand Up @@ -64,7 +65,7 @@ func DNSController(name string, factory DNSHandlerFactory) controller.Configurat
controller.NewResourceKey(api.GroupName, api.DNSProviderKind),
controller.NewResourceKey("core", "Secret"),
).
WorkerPool("dns", 1, 30*time.Second).CommandMatchers(utils.NewStringGlobMatcher("hostedzone:*"))
WorkerPool("dns", 1, 30*time.Second).CommandMatchers(utils.NewStringGlobMatcher(HOSTEDZONE_PREFIX + "*"))
}

type reconciler struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/dns/provider/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (this *state) getZoneForName(hostname string) (string, int) {
}

func (this *state) triggerHostedZone(name string) {
cmd := "hostedzone:" + name
cmd := HOSTEDZONE_PREFIX + name
if this.controller.IsReady() {
this.controller.EnqueueCommand(cmd)
} else {
Expand All @@ -408,8 +408,8 @@ func (this *state) triggerKey(key resources.ClusterObjectKey) {
}

func (this *state) DecodeZoneCommand(name string) string {
if strings.HasPrefix(name, "hostedzone:") {
return name[len("hostedzone:"):]
if strings.HasPrefix(name, HOSTEDZONE_PREFIX) {
return name[len(HOSTEDZONE_PREFIX):]
}
return ""
}
Expand Down

0 comments on commit 35767e7

Please sign in to comment.