aboutsummaryrefslogtreecommitdiff
path: root/middleware/kubernetes
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/kubernetes')
-rw-r--r--middleware/kubernetes/setup.go12
-rw-r--r--middleware/kubernetes/subzone.go48
-rw-r--r--middleware/kubernetes/subzone_test.go32
3 files changed, 7 insertions, 85 deletions
diff --git a/middleware/kubernetes/setup.go b/middleware/kubernetes/setup.go
index 4c6ba1247..1c77c11ec 100644
--- a/middleware/kubernetes/setup.go
+++ b/middleware/kubernetes/setup.go
@@ -68,14 +68,16 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
if c.Val() == "kubernetes" {
zones := c.RemainingArgs()
- if len(zones) == 0 {
+ if len(zones) != 0 {
+ k8s.Zones = zones
+ middleware.Zones(k8s.Zones).Normalize()
+ } else {
k8s.Zones = make([]string, len(c.ServerBlockKeys))
- copy(k8s.Zones, c.ServerBlockKeys)
+ for i := 0; i < len(c.ServerBlockKeys); i++ {
+ k8s.Zones[i] = middleware.Host(c.ServerBlockKeys[i]).Normalize()
+ }
}
- k8s.Zones = NormalizeZoneList(zones)
- middleware.Zones(k8s.Zones).Normalize()
-
if k8s.Zones == nil || len(k8s.Zones) < 1 {
return nil, errors.New("zone name must be provided for kubernetes middleware")
}
diff --git a/middleware/kubernetes/subzone.go b/middleware/kubernetes/subzone.go
deleted file mode 100644
index 6c4a79126..000000000
--- a/middleware/kubernetes/subzone.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package kubernetes
-
-import (
- "log"
-
- "github.com/miekg/dns"
-)
-
-// NormalizeZoneList filters the zones argument to remove
-// array items that conflict with other items in zones.
-// For example, providing the following zones array:
-// [ "a.b.c", "b.c", "a", "e.d.f", "a.b" ]
-// Returns:
-// [ "a.b.c", "a", "e.d.f", "a.b" ]
-// Zones filted out:
-// - "b.c" because "a.b.c" and "b.c" share the common top
-// level "b.c". First listed zone wins if there is a conflict.
-//
-// Note: This may prove to be too restrictive in practice.
-// Need to find counter-example use-cases.
-func NormalizeZoneList(zones []string) []string {
- filteredZones := []string{}
-
- for _, z := range zones {
- zoneConflict, _ := subzoneConflict(filteredZones, z)
- if zoneConflict {
- log.Printf("[WARN] new zone '%v' from Corefile conflicts with existing zones: %v\n Ignoring zone '%v'\n", z, filteredZones, z)
- } else {
- filteredZones = append(filteredZones, z)
- }
- }
-
- return filteredZones
-}
-
-// subzoneConflict returns true if name is a child or parent zone of
-// any element in zones. If conflicts exist, return the conflicting zones.
-func subzoneConflict(zones []string, name string) (bool, []string) {
- conflicts := []string{}
-
- for _, z := range zones {
- if dns.IsSubDomain(z, name) || dns.IsSubDomain(name, z) {
- conflicts = append(conflicts, z)
- }
- }
-
- return (len(conflicts) != 0), conflicts
-}
diff --git a/middleware/kubernetes/subzone_test.go b/middleware/kubernetes/subzone_test.go
deleted file mode 100644
index b1a9541b3..000000000
--- a/middleware/kubernetes/subzone_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package kubernetes
-
-import (
- "testing"
-)
-
-// List of configured zones to test against
-var confZones = []string{
- "a.b.c",
- "d",
-}
-
-// Map of zonename :: expected boolean result
-var examplesSubzoneConflict = map[string]bool{
- "a.b.c": true, // conflicts with zone "a.b.c"
- "b.c": true, // conflicts with zone "a.b.c"
- "c": true, // conflicts with zone "a.b.c"
- "e": false, // no conflict
- "a.b.c.e": false, // no conflict
- "a.b.c.d": true, // conflicts with zone "d"
- "": false,
-}
-
-func TestSubzoneConflict(t *testing.T) {
- for z, expected := range examplesSubzoneConflict {
- actual, conflicts := subzoneConflict(confZones, z)
-
- if actual != expected {
- t.Errorf("Expected conflict result '%v' for example '%v'. Instead got '%v'. Conflicting zones are: %v", expected, z, actual, conflicts)
- }
- }
-}
n Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/main.yml (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-04-26Update `@proload/core` (#3211)Gravatar Nate Moore 3-6/+6
2022-04-26Revert "fix: replace serialize-javascript & random-bytes with custom internal...Gravatar Nate Moore 7-565/+215
2022-04-26[ci] formatGravatar okikio 2-271/+315
2022-04-26fix: replace serialize-javascript & random-bytes with custom internal modulesGravatar Okiki 7-215/+521
2022-04-26[ci] release (#3182)create-astro@0.10.0astro@1.0.0-beta.18@astrojs/vercel@0.1.4@astrojs/tailwind@0.2.1@astrojs/svelte@0.1.2@astrojs/netlify@0.3.3Gravatar github-actions[bot] 54-146/+130
2022-04-26[ci] formatGravatar matthewp 1-1/+1
2022-04-26fix(vercel): `trailingSlash` fix for non-html pages (#3185)Gravatar Juan Martín Seery 2-29/+42
2022-04-26Prevent watcher from running during the build (#3207)Gravatar Matthew Phillips 2-0/+9
2022-04-26Fix lockfile (#3210)Gravatar Juan Martín Seery 1-6/+0
2022-04-26Add missing is:raw in AstroBuiltinAttributes (#3209)Gravatar Erika 2-0/+6
2022-04-26Feat: support `astro add` without npm installing (#3183)Gravatar Ben Holmes 6-30/+49
2022-04-26Add Astro attributes to svg elements (#3205)Gravatar Erika 2-1/+9
2022-04-26[ci] formatGravatar bholmesdev 2-9/+9
2022-04-26Feat: `create astro` add install step (#3190)Gravatar Ben Holmes 7-162/+299
2022-04-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-25fix(markdown): file.url fixes (#3198)Gravatar Juan Martín Seery 11-10/+149
2022-04-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-24add vite to licenseGravatar Fred K. Schott 2-24/+29
2022-04-24feat(markdown): Improved types (#3191)Gravatar Juan Martín Seery 3-6/+47
2022-04-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-04-23[ci] collect statsGravatar FredKSchott 1-0/+1