This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 53f26c1b feat: delete "app_namespaces" param (#1429)
53f26c1b is described below

commit 53f26c1b5c078b39b448f8adb7db27e662f5bd51
Author: cmssczy <[email protected]>
AuthorDate: Fri Nov 4 04:26:33 2022 +0800

    feat: delete "app_namespaces" param (#1429)
---
 cmd/ingress/ingress.go    |  4 ----
 conf/config-default.yaml  |  3 ---
 pkg/config/config.go      | 21 ---------------------
 pkg/config/config_test.go |  2 --
 4 files changed, 30 deletions(-)

diff --git a/cmd/ingress/ingress.go b/cmd/ingress/ingress.go
index 941359b2..c2c9dc74 100644
--- a/cmd/ingress/ingress.go
+++ b/cmd/ingress/ingress.go
@@ -175,7 +175,6 @@ For example, no available LB exists in the bare metal 
environment.`)
        cmd.PersistentFlags().BoolVar(&cfg.EnableProfiling, "enable-profiling", 
true, "enable profiling via web interface host:port/debug/pprof")
        cmd.PersistentFlags().StringVar(&cfg.Kubernetes.Kubeconfig, 
"kubeconfig", "", "Kubernetes configuration file (by default in-cluster 
configuration will be used)")
        
cmd.PersistentFlags().DurationVar(&cfg.Kubernetes.ResyncInterval.Duration, 
"resync-interval", time.Minute, "the controller resync (with Kubernetes) 
interval, the minimum resync interval is 30s")
-       cmd.PersistentFlags().StringSliceVar(&cfg.Kubernetes.AppNamespaces, 
"app-namespace", []string{config.NamespaceAll}, "namespaces that controller 
will watch for resources.")
        cmd.PersistentFlags().StringSliceVar(&cfg.Kubernetes.NamespaceSelector, 
"namespace-selector", []string{""}, "labels that controller used to select 
namespaces which will watch for resources")
        cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressClass, 
"ingress-class", config.IngressClass, "the class of an Ingress object is set 
using the field IngressClassName in Kubernetes clusters version v1.18.0 or 
higher or the annotation \"kubernetes.io/ingress.class\" (deprecated)")
        cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ElectionID, 
"election-id", config.IngressAPISIXLeader, "election id used for campaign the 
controller leader")
@@ -189,8 +188,5 @@ For example, no available LB exists in the bare metal 
environment.`)
        
cmd.PersistentFlags().DurationVar(&cfg.ApisixResourceSyncInterval.Duration, 
"apisix-resource-sync-interval", 300*time.Second, "interval between syncs in 
seconds. Default value is 300s.")
        cmd.PersistentFlags().StringVar(&cfg.PluginMetadataConfigMap, 
"plugin-metadata-cm", "plugin-metadata-config-map", "ConfigMap name of plugin 
metadata.")
 
-       if err := cmd.PersistentFlags().MarkDeprecated("app-namespace", "use 
namespace-selector instead"); err != nil {
-               dief("failed to mark `app-namespace` as deprecated: %s", err)
-       }
        return cmd
 }
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index e80d4a59..bd861e90 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -57,9 +57,6 @@ kubernetes:
   resync_interval: "6h"                # how long should 
apisix-ingress-controller
                                        # re-synchronizes with Kubernetes, 
default is 6h,
                                        # and the minimal resync interval is 
30s.
-  app_namespaces: ["*"]                # namespace list that controller will 
watch for resources,
-                                       # by default all namespaces 
(represented by "*") are watched.
-                                       # The `app_namespace` is deprecated, 
using `namespace_selector` instead since version 1.4.0
   namespace_selector: [""]             # namespace_selector represent basis 
for selecting managed namespaces.
                                        # the field is support since version 
1.4.0
                                        # For example, 
"apisix.ingress=watching", so ingress will watching the namespaces which labels 
"apisix.ingress=watching"
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 5daa6ae6..01c8c8df 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -26,15 +26,12 @@ import (
        "time"
 
        "gopkg.in/yaml.v2"
-       v1 "k8s.io/api/core/v1"
        "k8s.io/apimachinery/pkg/util/validation"
 
        "github.com/apache/apisix-ingress-controller/pkg/types"
 )
 
 const (
-       // NamespaceAll represents all namespaces.
-       NamespaceAll = "*"
        // IngressAPISIXLeader is the default election id for the controller
        // leader election.
        IngressAPISIXLeader = "ingress-apisix-leader"
@@ -96,7 +93,6 @@ type Config struct {
 type KubernetesConfig struct {
        Kubeconfig          string             `json:"kubeconfig" 
yaml:"kubeconfig"`
        ResyncInterval      types.TimeDuration `json:"resync_interval" 
yaml:"resync_interval"`
-       AppNamespaces       []string           `json:"app_namespaces" 
yaml:"app_namespaces"`
        NamespaceSelector   []string           `json:"namespace_selector" 
yaml:"namespace_selector"`
        ElectionID          string             `json:"election_id" 
yaml:"election_id"`
        IngressClass        string             `json:"ingress_class" 
yaml:"ingress_class"`
@@ -138,7 +134,6 @@ func NewDefaultConfig() *Config {
                Kubernetes: KubernetesConfig{
                        Kubeconfig:          "", // Use in-cluster 
configurations.
                        ResyncInterval:      types.TimeDuration{Duration: 6 * 
time.Hour},
-                       AppNamespaces:       []string{v1.NamespaceAll},
                        ElectionID:          IngressAPISIXLeader,
                        IngressClass:        IngressClass,
                        IngressVersion:      IngressNetworkingV1,
@@ -205,7 +200,6 @@ func (cfg *Config) Validate() error {
        default:
                return errors.New("unsupported ingress version")
        }
-       cfg.Kubernetes.AppNamespaces = 
purifyAppNamespaces(cfg.Kubernetes.AppNamespaces)
        ok, err := cfg.verifyNamespaceSelector()
        if !ok {
                return err
@@ -213,21 +207,6 @@ func (cfg *Config) Validate() error {
        return nil
 }
 
-func purifyAppNamespaces(namespaces []string) []string {
-       exists := make(map[string]struct{})
-       var ultimate []string
-       for _, ns := range namespaces {
-               if ns == NamespaceAll {
-                       return []string{v1.NamespaceAll}
-               }
-               if _, ok := exists[ns]; !ok {
-                       ultimate = append(ultimate, ns)
-                       exists[ns] = struct{}{}
-               }
-       }
-       return ultimate
-}
-
 func (cfg *Config) verifyNamespaceSelector() (bool, error) {
        labels := cfg.Kubernetes.NamespaceSelector
        // default is [""]
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 1625b595..594dcfce 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -45,7 +45,6 @@ func TestNewConfigFromFile(t *testing.T) {
                Kubernetes: KubernetesConfig{
                        ResyncInterval: types.TimeDuration{Duration: time.Hour},
                        Kubeconfig:     "/path/to/foo/baz",
-                       AppNamespaces:  []string{""},
                        ElectionID:     "my-election-id",
                        IngressClass:   IngressClass,
                        IngressVersion: IngressNetworkingV1,
@@ -134,7 +133,6 @@ func TestConfigWithEnvVar(t *testing.T) {
                Kubernetes: KubernetesConfig{
                        ResyncInterval: types.TimeDuration{Duration: time.Hour},
                        Kubeconfig:     "",
-                       AppNamespaces:  []string{""},
                        ElectionID:     "my-election-id",
                        IngressClass:   IngressClass,
                        IngressVersion: IngressNetworkingV1,

Reply via email to