Skip to content

Commit

Permalink
Merge pull request #1 from Megum1n/gloo-multiple-namespaces-2
Browse files Browse the repository at this point in the history
Change variable type and description
  • Loading branch information
megum1n committed Jun 23, 2023
2 parents 63c826f + 028656d commit 708141d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func main() {
CFUsername: cfg.CFUsername,
CFPassword: cfg.CFPassword,
ContourLoadBalancerService: cfg.ContourLoadBalancerService,
GlooNamespace: cfg.GlooNamespace,
GlooNamespaces: cfg.GlooNamespaces,
SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion,
RequestTimeout: cfg.RequestTimeout,
DefaultTargets: cfg.DefaultTargets,
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Config struct {
RequestTimeout time.Duration
DefaultTargets []string
ContourLoadBalancerService string
GlooNamespace string
GlooNamespaces []string
SkipperRouteGroupVersion string
Sources []string
Namespace string
Expand Down Expand Up @@ -207,7 +207,7 @@ var defaultConfig = &Config{
RequestTimeout: time.Second * 30,
DefaultTargets: []string{},
ContourLoadBalancerService: "heptio-contour/contour",
GlooNamespace: "gloo-system",
GlooNamespaces: []string{"gloo-system"},
SkipperRouteGroupVersion: "zalando.org/v1",
Sources: nil,
Namespace: "",
Expand Down Expand Up @@ -398,7 +398,7 @@ func (cfg *Config) ParseFlags(args []string) error {
app.Flag("contour-load-balancer", "The fully-qualified name of the Contour load balancer service. (default: heptio-contour/contour)").Default("heptio-contour/contour").StringVar(&cfg.ContourLoadBalancerService)

// Flags related to Gloo
app.Flag("gloo-namespace", "Coma separated list of gloo namespaces. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespace)
app.Flag("gloo-namespace", "Set Gloo Proxy namespace; specify multiple times for multiple namespaces. (default: gloo-system)").Default("gloo-system").StringsVar(&cfg.GlooNamespaces)

// Flags related to Skipper RouteGroup
app.Flag("skipper-routegroup-groupversion", "The resource version for skipper routegroup").Default(source.DefaultRoutegroupVersion).StringVar(&cfg.SkipperRouteGroupVersion)
Expand Down
9 changes: 5 additions & 4 deletions pkg/apis/externaldns/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
KubeConfig: "",
RequestTimeout: time.Second * 30,
ContourLoadBalancerService: "heptio-contour/contour",
GlooNamespace: "gloo-system",
GlooNamespaces: []string{"gloo-system"},
SkipperRouteGroupVersion: "zalando.org/v1",
Sources: []string{"service"},
Namespace: "",
Expand Down Expand Up @@ -136,7 +136,7 @@ var (
KubeConfig: "/some/path",
RequestTimeout: time.Second * 77,
ContourLoadBalancerService: "heptio-contour-other/contour-other",
GlooNamespace: "gloo-not-system,gloo-second-system",
GlooNamespaces: []string{"gloo-not-system", "gloo-second-system"},
SkipperRouteGroupVersion: "zalando.org/v2",
Sources: []string{"service", "ingress", "connector"},
Namespace: "namespace",
Expand Down Expand Up @@ -266,7 +266,8 @@ func TestParseFlags(t *testing.T) {
"--kubeconfig=/some/path",
"--request-timeout=77s",
"--contour-load-balancer=heptio-contour-other/contour-other",
"--gloo-namespace=gloo-not-system,gloo-second-system",
"--gloo-namespace=gloo-not-system",
"--gloo-namespace=gloo-second-system",
"--skipper-routegroup-groupversion=zalando.org/v2",
"--source=service",
"--source=ingress",
Expand Down Expand Up @@ -391,7 +392,7 @@ func TestParseFlags(t *testing.T) {
"EXTERNAL_DNS_KUBECONFIG": "/some/path",
"EXTERNAL_DNS_REQUEST_TIMEOUT": "77s",
"EXTERNAL_DNS_CONTOUR_LOAD_BALANCER": "heptio-contour-other/contour-other",
"EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system,gloo-second-system",
"EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system\ngloo-second-system",
"EXTERNAL_DNS_SKIPPER_ROUTEGROUP_GROUPVERSION": "zalando.org/v2",
"EXTERNAL_DNS_SOURCE": "service\ningress\nconnector",
"EXTERNAL_DNS_NAMESPACE": "namespace",
Expand Down
5 changes: 3 additions & 2 deletions source/gloo_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ type glooSource struct {
}

// NewGlooSource creates a new glooSource with the given config
func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, glooNamespaces string) (Source, error) {
func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface,
glooNamespaces []string) (Source, error) {
return &glooSource{
dynamicKubeClient,
kubeClient,
strings.Split(glooNamespaces, ","),
glooNamespaces,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion source/gloo_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestGlooSource(t *testing.T) {
proxyGVR: "ProxyList",
})

source, err := NewGlooSource(fakeDynamicClient, fakeKubernetesClient, defaultGlooNamespace)
source, err := NewGlooSource(fakeDynamicClient, fakeKubernetesClient, []string{defaultGlooNamespace})
assert.NoError(t, err)
assert.NotNil(t, source)

Expand Down
4 changes: 2 additions & 2 deletions source/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Config struct {
CFUsername string
CFPassword string
ContourLoadBalancerService string
GlooNamespace string
GlooNamespaces []string
SkipperRouteGroupVersion string
RequestTimeout time.Duration
DefaultTargets []string
Expand Down Expand Up @@ -288,7 +288,7 @@ func BuildWithConfig(ctx context.Context, source string, p ClientGenerator, cfg
if err != nil {
return nil, err
}
return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespace)
return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespaces)
case "openshift-route":
ocpClient, err := p.OpenShiftClient()
if err != nil {
Expand Down

0 comments on commit 708141d

Please sign in to comment.