Просмотр исходного кода

support all as a namespace option

Alexander Belanger 4 лет назад
Родитель
Сommit
489894ab54

+ 5 - 0
api/server/authz/cluster.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"fmt"
 	"net/http"
+	"strings"
 
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
 	"github.com/porter-dev/porter/api/server/shared/config"
@@ -142,6 +143,10 @@ func (d *OutOfClusterAgentGetter) GetHelmAgent(r *http.Request, cluster *models.
 		namespace = nsPolicy.Resource.Name
 	}
 
+	if strings.ToLower(namespace) == "all" {
+		namespace = ""
+	}
+
 	helmAgent, err := helm.GetAgentFromK8sAgent("secret", namespace, d.config.Logger, k8sAgent)
 
 	if err != nil {

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/NamespaceSelector.tsx

@@ -38,7 +38,7 @@ export default class NamespaceSelector extends Component<PropsType, StateType> {
       .then((res) => {
         if (this._isMounted) {
           let namespaceOptions: { label: string; value: string }[] = [
-            { label: "All", value: "" },
+            { label: "All", value: "ALL" },
           ];
 
           // Set namespace from URL if specified
@@ -46,7 +46,7 @@ export default class NamespaceSelector extends Component<PropsType, StateType> {
           let urlParams = new URLSearchParams(queryString);
           let urlNamespace = urlParams.get("namespace");
           if (urlNamespace === "ALL") {
-            urlNamespace = "";
+            urlNamespace = "all";
           }
 
           let defaultNamespace = "default";
@@ -77,7 +77,7 @@ export default class NamespaceSelector extends Component<PropsType, StateType> {
       })
       .catch((err) => {
         if (this._isMounted) {
-          this.setState({ namespaceOptions: [{ label: "All", value: "" }] });
+          this.setState({ namespaceOptions: [{ label: "All", value: "ALL" }] });
         }
       });
   };