Răsfoiți Sursa

Merge branch 'master' of github.com:porter-dev/porter into stacks-improved-debug-flow-deploy

Feroze Mohideen 2 ani în urmă
părinte
comite
3043f95509

+ 1 - 1
api/server/handlers/namespace/create_stacks_env_group.go

@@ -48,13 +48,13 @@ func NewCreateStacksEnvGroupHandler(
 func (c *CreateStacksEnvGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	request := &types.CreateStacksEnvGroupRequest{}
 	ctx := r.Context()
+	cluster, _ := ctx.Value(types.ClusterScope).(*models.Cluster)
 	ctx, span := telemetry.NewSpan(ctx, "serve-create-env-group-stacks")
 	defer span.End()
 	if ok := c.DecodeAndValidate(w, r, request); !ok {
 		return
 	}
 	namespace := ctx.Value(types.NamespaceScope).(string)
-	cluster, _ := ctx.Value(types.ClusterScope).(*models.Cluster)
 
 	agent, err := c.GetAgent(r, cluster, namespace)
 	if err != nil {

+ 4 - 4
api/server/handlers/porter_app/create.go

@@ -514,11 +514,11 @@ func createPreDeployJobChart(
 
 func cloneEnvGroup(c *CreatePorterAppHandler, w http.ResponseWriter, r *http.Request, agent *kubernetes.Agent, envGroups []string, namespace string) {
 	for _, envGroupName := range envGroups {
-		cm, _, err := agent.GetLatestVersionedConfigMap(envGroupName, "default")
+		cm, _, err := agent.GetLatestVersionedConfigMap(envGroupName, "porter-env-group")
 		if err != nil {
 			if errors.Is(err, kubernetes.IsNotFoundError) {
 				c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
-					fmt.Errorf("error cloning env group: envgroup %s in namespace %s not found", envGroupName, "default"), http.StatusNotFound,
+					fmt.Errorf("error cloning env group: envgroup %s in namespace %s not found", envGroupName, "porter-env-group"), http.StatusNotFound,
 					"no config map found for envgroup",
 				))
 				return
@@ -527,11 +527,11 @@ func cloneEnvGroup(c *CreatePorterAppHandler, w http.ResponseWriter, r *http.Req
 			c.HandleAPIError(w, r, apierrors.NewErrInternal(err))
 			return
 		}
-		secret, _, err := agent.GetLatestVersionedSecret(envGroupName, "default")
+		secret, _, err := agent.GetLatestVersionedSecret(envGroupName, "porter-env-group")
 		if err != nil {
 			if errors.Is(err, kubernetes.IsNotFoundError) {
 				c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
-					fmt.Errorf("error cloning env group: envgroup %s in namespace %s not found", envGroupName, "default"), http.StatusNotFound,
+					fmt.Errorf("error cloning env group: envgroup %s in namespace %s not found", envGroupName, "porter-env-group"), http.StatusNotFound,
 					"no k8s secret found for envgroup",
 				))
 				return

+ 11 - 0
dashboard/src/components/CloudFormationForm.tsx

@@ -88,6 +88,17 @@ const CloudFormationForm: React.FC<Props> = ({
       if (!hasSentAWSNotif) {
         setHasSentAWSNotif(true);
         markStepStarted({ step: "aws-account-id-complete", account_id: accountId });
+        if (currentProject != null) {
+          try {
+            api.inviteAdmin(
+              "<token>",
+              {},
+              { project_id: currentProject.id }
+            );
+          } catch (err) {
+            console.log(err);
+          }
+        }
       }
     } else {
       setCurrentStep(0);

+ 29 - 41
dashboard/src/index.html

@@ -1,43 +1,31 @@
 <!DOCTYPE html>
 <html lang="en">
-  <head>
-    <title>Porter | Dashboard</title>
-    <link rel="icon" href="https://i.ibb.co/HnSk02f/ptr.png" />
-    <meta
-      name="description"
-      content="Kubernetes powered PaaS that runs in your own cloud."
-    />
-    <meta property="og:title" content="Porter" />
-    <meta
-      property="og:image"
-      content="https://i.ibb.co/52g2g7C/porter-wide.png"
-    />
-    <meta
-      property="og:description"
-      content="Kubernetes powered PaaS that runs in your own cloud."
-    />
-    <meta property="og:url" content="https://porter.run" />
-    <link
-      href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600"
-      rel="stylesheet"
-    />
-    <link href="https://fonts.cdnfonts.com/css/general-sans" rel="stylesheet">
-    <link
-      href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css"
-      rel="stylesheet"
-    />
-    <link
-      href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Round"
-      rel="stylesheet"
-    />
-    <!-- Coding languages icons -->
-    <link
-      rel="stylesheet"
-      href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.14.0/devicon.min.css"
-    />
-  </head>
-  <body>
-    <div id="output"></div>
-    <div id="modal-root"></div>
-  </body>
-</html>
+
+<head>
+  <title>Porter | Dashboard</title>
+  <link rel="icon" href="https://i.ibb.co/HnSk02f/ptr.png" />
+  <meta name="description" content="Kubernetes powered PaaS that runs in your own cloud." />
+  <meta property="og:title" content="Porter" />
+  <meta property="og:image" content="https://i.ibb.co/52g2g7C/porter-wide.png" />
+  <meta property="og:description" content="Kubernetes powered PaaS that runs in your own cloud." />
+  <meta property="og:url" content="https://porter.run" />
+  <link href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600" rel="stylesheet" />
+  <link href="https://fonts.cdnfonts.com/css/general-sans" rel="stylesheet">
+  <link href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css" rel="stylesheet" />
+  <link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Round"
+    rel="stylesheet" />
+  <!-- Coding languages icons -->
+  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.14.0/devicon.min.css" />
+
+  <script>
+    !function (t, e) { var o, n, p, r; e.__SV || (window.posthog = e, e._i = [], e.init = function (i, s, a) { function g(t, e) { var o = e.split("."); 2 == o.length && (t = t[o[0]], e = o[1]), t[e] = function () { t.push([e].concat(Array.prototype.slice.call(arguments, 0))) } } (p = t.createElement("script")).type = "text/javascript", p.async = !0, p.src = s.api_host + "/static/array.js", (r = t.getElementsByTagName("script")[0]).parentNode.insertBefore(p, r); var u = e; for (void 0 !== a ? u = e[a] = [] : a = "posthog", u.people = u.people || [], u.toString = function (t) { var e = "posthog"; return "posthog" !== a && (e += "." + a), t || (e += " (stub)"), e }, u.people.toString = function () { return u.toString(1) + ".people (stub)" }, o = "capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "), n = 0; n < o.length; n++)g(u, o[n]); e._i.push([i, s, a]) }, e.__SV = 1) }(document, window.posthog || []);
+    posthog.init('phc_Bna7PjZKfVnkjiDOHx6gUIuIbvWv4M8zsqxYxuRYVo4', { api_host: 'https://app.posthog.com' })
+  </script>
+</head>
+
+<body>
+  <div id="output"></div>
+  <div id="modal-root"></div>
+</body>
+
+</html>

+ 6 - 9
dashboard/src/main/home/app-dashboard/expanded-app/ExpandedApp.tsx

@@ -98,8 +98,6 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
     false
   );
 
-  const [bannerLoading, setBannerLoading] = useState<boolean>(false);
-
   const [showRevisions, setShowRevisions] = useState<boolean>(false);
   const [showDeleteOverlay, setShowDeleteOverlay] = useState<boolean>(false);
 
@@ -142,7 +140,6 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
 
   // this method fetches and reconstructs the porter yaml as well as the DB info (stored in PorterApp)
   const getPorterApp = async ({ revision }: { revision: number }) => {
-    setBannerLoading(true);
     setIsLoading(true);
     const { appName } = props.match.params as any;
     try {
@@ -206,7 +203,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
           {},
           {
             id: currentProject.id,
-            namespace: "default",
+            namespace: "porter-env-group",
             cluster_id: currentCluster.id,
           }
         )
@@ -323,7 +320,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
           {
             project_id: currentProject.id,
             cluster_id: currentCluster.id,
-            namespace: "default",
+            namespace: "porter-env-group",
           }
         );
       });
@@ -392,7 +389,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
           {
             project_id: currentProject.id,
             cluster_id: currentCluster.id,
-            namespace: "default",
+            namespace: "porter-env-group",
           }
         );
       });
@@ -416,7 +413,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
           {
             project_id: currentProject.id,
             cluster_id: currentCluster.id,
-            namespace: "default",
+            namespace: "porter-env-group",
           }
         );
       }
@@ -882,7 +879,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
           ) : (
             <>
               {!workflowCheckPassed ? (
-                bannerLoading ? (
+                isLoading ? (
                   <Banner>
                     <Loading />
                   </Banner>
@@ -897,7 +894,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
                   />
                 )
               ) : !hasBuiltImage ? (
-                bannerLoading ? (
+                isLoading ? (
                   <Banner>
                     <Loading />
                   </Banner>

+ 2 - 2
dashboard/src/main/home/app-dashboard/expanded-app/env-vars/EnvGroupModal.tsx

@@ -69,7 +69,7 @@ const EnvGroupModal: React.FC<Props> = ({
           {},
           {
             id: currentProject.id,
-            namespace: "default",
+            namespace: "porter-env-group",
             cluster_id: currentCluster.id,
           }
         )
@@ -136,7 +136,7 @@ const EnvGroupModal: React.FC<Props> = ({
         {
           id: currentProject.id,
           cluster_id: currentCluster.id,
-          namespace: "default",
+          namespace: "porter-env-group",
         }
       );
       setCloneSuccess(true);

+ 1 - 1
dashboard/src/main/home/app-dashboard/expanded-app/env-vars/EnvVariablesTab.tsx

@@ -58,7 +58,7 @@ export const EnvVariablesTab: React.FC<EnvVariablesTabProps> = ({
           {},
           {
             id: currentProject.id,
-            namespace: "default",
+            namespace: "porter-env-group",
             cluster_id: currentCluster.id,
           }
         )

+ 2 - 2
dashboard/src/main/home/app-dashboard/new-app-flow/NewAppFlow.tsx

@@ -390,7 +390,7 @@ const NewAppFlow: React.FC<Props> = ({ ...props }) => {
             {
               project_id: currentProject.id,
               cluster_id: currentCluster.id,
-              namespace: "default",
+              namespace: "porter-env-group",
             }
           );
         });
@@ -417,7 +417,7 @@ const NewAppFlow: React.FC<Props> = ({ ...props }) => {
             {
               project_id: currentProject.id,
               cluster_id: currentCluster.id,
-              namespace: "default",
+              namespace: "porter-env-group",
             }
           );
         }

+ 2 - 2
dashboard/src/main/home/cluster-dashboard/DashboardRouter.tsx

@@ -107,9 +107,9 @@ const DashboardRouter: React.FC<Props> = ({
   }, [currentCluster]);
 
   useEffect(() => {
-    let { currentNamespace } = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "default" : props.match?.params as any;
+    let { currentNamespace } = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "porter-env-group" : props.match?.params as any;
     if (!currentNamespace) {
-      currentNamespace = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "default" : getQueryParam(props, "namespace");
+      currentNamespace = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "porter-env-group" : getQueryParam(props, "namespace");
     }
     setSortType("Newest");
     setCurrentChart(null);

+ 21 - 1
dashboard/src/main/home/cluster-dashboard/env-groups/CreateEnvGroup.tsx

@@ -55,6 +55,26 @@ export default class CreateEnvGroup extends Component<PropsType, StateType> {
 
     let envVariables = this.state.envVariables;
 
+    if (this.context.currentProject.simplified_view_enabled) {
+      api
+        .createNamespace(
+          "<token>",
+          {
+            name: "porter-env-group",
+          },
+          {
+            id: this.context.currentProject.id,
+            cluster_id: this.props.currentCluster.id,
+          }
+        )
+        .catch((error) => {
+          if (error.response && error.response.status === 412) {
+            console.log("Ignoring known 412 error");
+          } else {
+            console.error(error);
+          }
+        });
+    }
     envVariables
       .filter((envVar: KeyValueType, index: number, self: KeyValueType[]) => {
         // remove any collisions that are marked as deleted and are duplicates
@@ -95,7 +115,7 @@ export default class CreateEnvGroup extends Component<PropsType, StateType> {
         {
           id: this.context.currentProject.id,
           cluster_id: this.props.currentCluster.id,
-          namespace: this.state.selectedNamespace,
+          namespace: this.context.currentProject.simplified_view_enabled ? "porter-env-group" : this.state.selectedNamespace,
         }
       )
       .then((res) => {

+ 4 - 4
dashboard/src/main/home/cluster-dashboard/env-groups/EnvGroupDashboard.tsx

@@ -50,7 +50,7 @@ const EnvGroupDashboard = (props: PropsType) => {
   const setNamespace = (namespace: string) => {
     setState((state) => ({ ...state, namespace }));
     pushQueryParams(props, {
-      namespace: currentProject.simplified_view_enabled ? ("default") : (namespace ?? "ALL"),
+      namespace: currentProject.simplified_view_enabled ? ("porter-env-group") : (namespace ?? "ALL"),
     });
   };
 
@@ -109,7 +109,7 @@ const EnvGroupDashboard = (props: PropsType) => {
               <Spacer inline width="10px" />
               {!currentProject.simplified_view_enabled && <NamespaceSelector
                 setNamespace={setNamespace}
-                namespace={currentProject.simplified_view_enabled ? "default" : state.namespace}
+                namespace={currentProject.simplified_view_enabled ? "porter-env-group" : state.namespace}
               />}
             </SortFilterWrapper>
             <Flex>
@@ -123,7 +123,7 @@ const EnvGroupDashboard = (props: PropsType) => {
 
           <EnvGroupList
             currentCluster={props.currentCluster}
-            namespace={currentProject?.simplified_view_enabled ? "default" : state.namespace}
+            namespace={currentProject?.simplified_view_enabled ? "porter-env-group" : state.namespace}
             sortType={state.sortType}
             setExpandedEnvGroup={setExpandedEnvGroup}
           />
@@ -137,7 +137,7 @@ const EnvGroupDashboard = (props: PropsType) => {
       return (
         <ExpandedEnvGroup
           isAuthorized={props.isAuthorized}
-          namespace={currentProject?.simplified_view_enabled ? "default" : (state.expandedEnvGroup?.namespace || state.namespace)}
+          namespace={currentProject?.simplified_view_enabled ? "porter-env-group" : (state.expandedEnvGroup?.namespace || state.namespace)}
           currentCluster={props.currentCluster}
           envGroup={state.expandedEnvGroup}
           closeExpanded={() => closeExpanded()}

+ 1 - 2
dashboard/src/main/home/cluster-dashboard/env-groups/ExpandedEnvGroup.tsx

@@ -118,7 +118,6 @@ export const ExpandedEnvGroupFC = ({
       { value: "settings", label: "Settings" },
     ];
   }, [currentEnvGroup]);
-
   const populateEnvGroup = async () => {
     try {
       const populatedEnvGroup = await api
@@ -274,7 +273,7 @@ export const ExpandedEnvGroupFC = ({
                   {
                     id: currentProject.id,
                     cluster_id: currentCluster.id,
-                    namespace: "default",
+                    namespace: "porter-env-group",
                   }
                 );
               }

+ 3 - 3
dashboard/src/main/home/cluster-dashboard/env-groups/ExpandedEnvGroupDashboard.tsx

@@ -21,7 +21,7 @@ type PropsType = RouteComponentProps &
   };
 
 const EnvGroupDashboard = (props: PropsType) => {
-  const namespace = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "default" : getQueryParam(props, "namespace");
+  const namespace = (currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "porter-env-group" : getQueryParam(props, "namespace");
   const params = useParams<{ name: string }>();
   const { currentProject } = useContext(Context);
   const [expandedEnvGroup, setExpandedEnvGroup] = useState<any>();
@@ -49,7 +49,7 @@ const EnvGroupDashboard = (props: PropsType) => {
           {},
           {
             id: currentProject.id,
-            namespace: currentProject?.simplified_view_enabled ? "default" : namespace,
+            namespace: currentProject?.simplified_view_enabled ? "porter-env-group" : namespace,
             cluster_id: props.currentCluster.id,
           }
         );
@@ -97,7 +97,7 @@ const EnvGroupDashboard = (props: PropsType) => {
     return (
       <ExpandedEnvGroup
         isAuthorized={props.isAuthorized}
-        namespace={(currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "default" : expandedEnvGroup?.namespace ?? namespace}
+        namespace={(currentProject?.simplified_view_enabled && currentProject?.capi_provisioner_enabled) ? "porter-env-group" : expandedEnvGroup?.namespace ?? namespace}
         currentCluster={props.currentCluster}
         envGroup={expandedEnvGroup}
         closeExpanded={() => props.history.push("/env-groups")}

+ 0 - 5
dashboard/src/main/home/cluster-dashboard/stacks/Dashboard.tsx

@@ -19,17 +19,12 @@ const Dashboard = () => {
   const { getQueryParam, pushQueryParams } = useRouting();
 
   const handleNamespaceChange = (namespace: string) => {
-    console.log("HERE")
-    console.log(namespace)
     setCurrentNamespace(namespace);
     pushQueryParams({ namespace });
   };
 
   useEffect(() => {
     const newNamespace = getQueryParam("namespace");
-    console.log("HERE")
-    console.log(newNamespace)
-
     if (newNamespace !== currentNamespace) {
       setCurrentNamespace(newNamespace);
     }

+ 1 - 1
dashboard/src/main/home/modals/LoadEnvGroupModal.tsx

@@ -115,7 +115,7 @@ export default class LoadEnvGroupModal extends Component<PropsType, StateType> {
   };
 
   componentDidMount() {
-    if (Array.isArray(this.props.availableEnvGroups)) {
+    if (Array.isArray(this.props.availableEnvGroups) && !this.context.currentProject.stacks_enabled) {
       this.setState({
         envGroups: this.props.availableEnvGroups,
         loading: false,