瀏覽代碼

Merge branch 'master' of github.com:porter-dev/porter into 0.8.0-pod-events-managment

jnfrati 4 年之前
父節點
當前提交
da011b4a94

+ 4 - 12
.github/workflows/release.yaml

@@ -27,11 +27,8 @@ jobs:
         run: |
           cat >./dashboard/.env <<EOL
           NODE_ENV=production
-          API_SERVER=dashboard.getporter.dev
-          FULLSTORY_ORG_ID=${{secrets.FULLSTORY_ORG_ID}}
-          DISCORD_KEY=${{secrets.DISCORD_KEY}}
-          DISCORD_CID=${{secrets.DISCORD_CID}}
-          FEEDBACK_ENDPOINT=${{secrets.FEEDBACK_ENDPOINT}}
+          APPLICATION_CHART_REPO_URL=https://charts.getporter.dev
+          ADDON_CHART_REPO_URL=https://chart-addons.getporter.dev
           EOL
 
           cat ./dashboard/.env
@@ -62,13 +59,8 @@ jobs:
         run: |
           cat >./dashboard/.env <<EOL
           NODE_ENV=production
-          API_SERVER=dashboard.getporter.dev
-          FULLSTORY_ORG_ID=${{secrets.FULLSTORY_ORG_ID}}
-          DISCORD_KEY=${{secrets.DISCORD_KEY}}
-          DISCORD_CID=${{secrets.DISCORD_CID}}
-          FEEDBACK_ENDPOINT=${{secrets.FEEDBACK_ENDPOINT}}
-          POSTHOG_API_KEY=${{secrets.POSTHOG_API_KEY}}
-          POSTHOG_HOST=${{secrets.POSTHOG_HOST}}
+          APPLICATION_CHART_REPO_URL=https://charts.getporter.dev
+          ADDON_CHART_REPO_URL=https://chart-addons.getporter.dev
           EOL
       - name: Build and zip static folder
         run: |

+ 9 - 2
dashboard/src/components/porter-form/PorterFormContextProvider.tsx

@@ -30,6 +30,7 @@ interface ContextProps {
   onSubmit: () => void;
   dispatchAction: (event: PorterFormAction) => void;
   validationInfo: PorterFormValidationInfo;
+  getSubmitValues: () => PorterFormVariableList;
   isReadOnly?: boolean;
 }
 
@@ -376,7 +377,7 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
   using functions for each input to finalize the variables
   This can take care of things like appending units to strings
  */
-  const onSubmitWrapper = () => {
+  const getSubmitValues = () => {
     // we start off with a base list of the current variables for fields
     // that don't need any processing on top (for example: checkbox)
     // the assign here is important because that way state.variable isn't mutated
@@ -411,7 +412,12 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
       )
     );
     if (props.doDebug) console.log(Object.assign.apply({}, varList));
-    props.onSubmit(Object.assign.apply({}, varList));
+
+    return Object.assign.apply({}, varList);
+  };
+
+  const onSubmitWrapper = () => {
+    props.onSubmit(getSubmitValues());
   };
 
   if (props.doDebug) {
@@ -434,6 +440,7 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
           error: isValidated ? null : "Missing required fields",
         },
         onSubmit: onSubmitWrapper,
+        getSubmitValues,
       }}
     >
       {props.children}

+ 0 - 2
dashboard/src/components/porter-form/field-components/Input.tsx

@@ -50,8 +50,6 @@ const Input: React.FC<InputField> = ({
     return <></>;
   }
 
-  console.log(value);
-
   const curValue =
     settings?.type == "number"
       ? !isNaN(parseFloat(variables[variable]))

+ 3 - 1
dashboard/src/components/porter-form/field-components/KeyValueArray.tsx

@@ -132,7 +132,9 @@ const KeyValueArray: React.FC<Props> = (props) => {
     }
   };
 
-  const getProcessedValues = (objectArray: { key: string, value: string }[]): any => {
+  const getProcessedValues = (
+    objectArray: { key: string; value: string }[]
+  ): any => {
     let obj = {} as any;
     objectArray?.forEach(({ key, value }) => {
       obj[key] = value;

+ 31 - 34
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -253,7 +253,7 @@ const ExpandedChart: React.FC<Props> = (props) => {
 
     setSaveValueStatus("loading");
     getChartData(currentChart);
-    console.log("valuesYaml", valuesYaml)
+    console.log("valuesYaml", valuesYaml);
     try {
       await api.upgradeChartValues(
         "<token>",
@@ -699,11 +699,7 @@ const ExpandedChart: React.FC<Props> = (props) => {
         >
           {repository}
         </RepositoryName>
-        {
-          showRepoTooltip && (
-            <Tooltip>{repository}</Tooltip>
-          )
-        }
+        {showRepoTooltip && <Tooltip>{repository}</Tooltip>}
       </DeploymentImageContainer>
     );
   };
@@ -774,34 +770,35 @@ const ExpandedChart: React.FC<Props> = (props) => {
               latestVersion={currentChart.latest_version}
               upgradeVersion={handleUpgradeVersion}
             />
-            {
-              (isPreview || leftTabOptions.length > 0) && (
-                <BodyWrapper>
-                  <PorterFormWrapper
-                    formData={currentChart.form}
-                    valuesToOverride={{
-                      namespace: props.namespace,
-                      clusterId: currentCluster.id,
-                    }}
-                    renderTabContents={renderTabContents}
-                    isReadOnly={
-                      imageIsPlaceholder ||
-                      !isAuthorized("application", "", ["get", "update"])
-                    }
-                    onSubmit={onSubmit}
-                    rightTabOptions={rightTabOptions}
-                    leftTabOptions={leftTabOptions}
-                    color={isPreview ? "#f5cb42" : null}
-                    addendum={
-                      <TabButton onClick={toggleDevOpsMode} devOpsMode={devOpsMode}>
-                        <i className="material-icons">offline_bolt</i> DevOps Mode
-                      </TabButton>
-                    }
-                    saveValuesStatus={saveValuesStatus}
-                  />
-                </BodyWrapper>
-              )
-            }
+            {(isPreview || leftTabOptions.length > 0) && (
+              <BodyWrapper>
+                <PorterFormWrapper
+                  formData={currentChart.form}
+                  valuesToOverride={{
+                    namespace: props.namespace,
+                    clusterId: currentCluster.id,
+                  }}
+                  renderTabContents={renderTabContents}
+                  isReadOnly={
+                    imageIsPlaceholder ||
+                    !isAuthorized("application", "", ["get", "update"])
+                  }
+                  onSubmit={onSubmit}
+                  rightTabOptions={rightTabOptions}
+                  leftTabOptions={leftTabOptions}
+                  color={isPreview ? "#f5cb42" : null}
+                  addendum={
+                    <TabButton
+                      onClick={toggleDevOpsMode}
+                      devOpsMode={devOpsMode}
+                    >
+                      <i className="material-icons">offline_bolt</i> DevOps Mode
+                    </TabButton>
+                  }
+                  saveValuesStatus={saveValuesStatus}
+                />
+              </BodyWrapper>
+            )}
           </>
         )}
       </StyledExpandedChart>

+ 9 - 31
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -11,12 +11,10 @@ import { Context } from "shared/Context";
 import api from "shared/api";
 
 import SaveButton from "components/SaveButton";
-import Loading from "components/Loading";
 import TitleSection from "components/TitleSection";
-import JobList from "./jobs/JobList";
+import TempJobList from "./jobs/TempJobList";
 import SettingsSection from "./SettingsSection";
 import PorterFormWrapper from "components/porter-form/PorterFormWrapper";
-import { PlaceHolder } from "brace";
 import { withAuth, WithAuthProps } from "shared/auth/AuthorizationHoc";
 
 type PropsType = WithAuthProps & {
@@ -419,25 +417,6 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
   };
 
   renderTabContents = (currentTab: string, submitValues?: any) => {
-    let saveButton = (
-      <ButtonWrapper>
-        <SaveButton
-          onClick={() => this.handleSaveValues(submitValues, true)}
-          status={this.state.saveValuesStatus}
-          makeFlush={true}
-          clearPosition={true}
-          rounded={true}
-          statusPosition="right"
-        >
-          <i className="material-icons">play_arrow</i> Run Job
-        </SaveButton>
-      </ButtonWrapper>
-    );
-
-    if (!this.props.isAuthorized("job", "", ["get", "update", "create"])) {
-      saveButton = null;
-    }
-
     switch (currentTab) {
       case "jobs":
         if (this.state.imageIsPlaceholder) {
@@ -455,12 +434,12 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
         }
         return (
           <TabWrapper>
-            {saveButton}
-            <JobList
+            <TempJobList
+              handleSaveValues={this.handleSaveValues}
               jobs={this.state.jobs}
-              setJobs={(jobs: any) => {
-                this.setState({ jobs });
-              }}
+              setJobs={(jobs: any) => this.setState({ jobs })}
+              isAuthorized={this.props.isAuthorized}
+              saveValuesStatus={this.state.saveValuesStatus}
             />
           </TabWrapper>
         );
@@ -616,10 +595,9 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
                     this.state.imageIsPlaceholder ||
                     !this.props.isAuthorized("job", "", ["get", "update"])
                   }
-                  onSubmit={(formValues) => {
-                    console.log(formValues);
-                    this.handleSaveValues(formValues, false);
-                  }}
+                  onSubmit={(formValues) =>
+                    this.handleSaveValues(formValues, false)
+                  }
                   leftTabOptions={this.state.leftTabOptions}
                   rightTabOptions={this.state.rightTabOptions}
                   saveValuesStatus={this.state.saveValuesStatus}

+ 20 - 20
dashboard/src/main/home/cluster-dashboard/expanded-chart/RevisionSection.tsx

@@ -293,26 +293,26 @@ class RevisionSection extends Component<PropsType, StateType> {
       this.state.maxVersion === 0;
     return (
       <div>
-        {this.state.upgradeVersion &&
-              <Modal
-                onRequestClose={() => this.setState({ upgradeVersion: "" })}
-                width="500px"
-                height="450px"
-              >
-                <UpgradeChartModal 
-                  currentChart={this.props.chart}
-                  closeModal={() => {
-                    this.setState({ upgradeVersion: "" });
-                  }}
-                  onSubmit={() => {
-                    this.props.upgradeVersion(this.state.upgradeVersion, () => {
-                      this.setState({ loading: false });
-                    });
-                    this.setState({ upgradeVersion: "", loading: true });
-                  }}
-                />
-              </Modal>
-              }
+        {this.state.upgradeVersion && (
+          <Modal
+            onRequestClose={() => this.setState({ upgradeVersion: "" })}
+            width="500px"
+            height="450px"
+          >
+            <UpgradeChartModal
+              currentChart={this.props.chart}
+              closeModal={() => {
+                this.setState({ upgradeVersion: "" });
+              }}
+              onSubmit={() => {
+                this.props.upgradeVersion(this.state.upgradeVersion, () => {
+                  this.setState({ loading: false });
+                });
+                this.setState({ upgradeVersion: "", loading: true });
+              }}
+            />
+          </Modal>
+        )}
         <RevisionHeader
           showRevisions={this.props.showRevisions}
           isCurrent={isCurrent}

+ 55 - 0
dashboard/src/main/home/cluster-dashboard/expanded-chart/jobs/TempJobList.tsx

@@ -0,0 +1,55 @@
+import React, { useContext, useState } from "react";
+import styled from "styled-components";
+
+import { PorterFormContext } from "components/porter-form/PorterFormContextProvider";
+import JobList from "./JobList";
+import SaveButton from "components/SaveButton";
+
+interface Props {
+  isAuthorized: any;
+  saveValuesStatus: string;
+  setJobs: any;
+  jobs: any;
+  handleSaveValues: any;
+}
+
+/**
+ * Temporary functional component for allowing job rerun button to consume
+ * form context (until ExpandedJobChart is migrated to FC)
+ */
+const TempJobList: React.FC<Props> = (props) => {
+  const { getSubmitValues } = useContext(PorterFormContext);
+  const [searchInput, setSearchInput] = useState("");
+
+  let saveButton = (
+    <ButtonWrapper>
+      <SaveButton
+        onClick={() => props.handleSaveValues(getSubmitValues(), true)}
+        status={props.saveValuesStatus}
+        makeFlush={true}
+        clearPosition={true}
+        rounded={true}
+        statusPosition="right"
+      >
+        <i className="material-icons">play_arrow</i> Run Job
+      </SaveButton>
+    </ButtonWrapper>
+  );
+
+  if (!props.isAuthorized("job", "", ["get", "update", "create"])) {
+    saveButton = null;
+  }
+
+  return (
+    <>
+      {saveButton}
+      <JobList jobs={props.jobs} setJobs={props.setJobs} />
+    </>
+  );
+};
+
+export default TempJobList;
+
+const ButtonWrapper = styled.div`
+  margin: 5px 0 35px;
+`;

+ 4 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/ControllerTab.tsx

@@ -380,11 +380,11 @@ const ControllerTabFC: React.FunctionComponent<Props> = ({
             <div key={firstItem.replicaSetName + index}>
               <ReplicaSetContainer>
                 <ReplicaSetName>
-                  {
-                    firstItem?.revisionNumber && firstItem?.revisionNumber.toString() != "N/A" && (
+                  {firstItem?.revisionNumber &&
+                    firstItem?.revisionNumber.toString() != "N/A" && (
                       <Bold>Revision {firstItem.revisionNumber}:</Bold>
-                    )
-                  } {firstItem.replicaSetName}
+                    )}{" "}
+                  {firstItem.replicaSetName}
                 </ReplicaSetName>
               </ReplicaSetContainer>
               {mapPods(subArray)}

+ 21 - 23
dashboard/src/main/home/cluster-dashboard/expanded-chart/status/PodRow.tsx

@@ -38,28 +38,26 @@ const PodRow: React.FunctionComponent<PodRowProps> = ({
       >
         {pod?.name}
       </Name>
-      {
-        showTooltip && (
-          <Tooltip>
-            {pod?.name}
-            <Grey>Restart count: {pod.restartCount}</Grey>
-            <Grey>Created on: {pod.podAge}</Grey>
-          </Tooltip>
-        )
-      }
-
-        <Status>
-          <StatusColor status={podStatus} />
-          {podStatus}
-          {podStatus === "failed" && (
-            <CloseIcon
-              className="material-icons-outlined"
-              onClick={onDeleteClick}
-            >
-              close
-            </CloseIcon>
-          )}
-        </Status>
+      {showTooltip && (
+        <Tooltip>
+          {pod?.name}
+          <Grey>Restart count: {pod.restartCount}</Grey>
+          <Grey>Created on: {pod.podAge}</Grey>
+        </Tooltip>
+      )}
+
+      <Status>
+        <StatusColor status={podStatus} />
+        {podStatus}
+        {podStatus === "failed" && (
+          <CloseIcon
+            className="material-icons-outlined"
+            onClick={onDeleteClick}
+          >
+            close
+          </CloseIcon>
+        )}
+      </Status>
     </Tab>
   );
 };
@@ -218,4 +216,4 @@ const Name = styled.div`
   overflow-wrap: anywhere;
   -webkit-box-orient: vertical;
   -webkit-line-clamp: 2;
-`;
+`;

+ 2 - 2
dashboard/src/main/home/integrations/Integrations.tsx

@@ -39,6 +39,7 @@ const Integrations: React.FC<PropsType> = (props) => {
                 >
                   {integrationList[integration].label}
                 </TitleSection>
+                <Buffer />
                 <CreateIntegrationForm
                   integrationName={integration}
                   closeForm={() => {
@@ -101,8 +102,7 @@ const Icon = styled.img`
 `;
 
 const Flex = styled.div`
-  display: flex;
-  align-items: center;
+  width: 100%;
 
   > i {
     cursor: pointer;

+ 2 - 0
dashboard/src/main/home/integrations/create-integration/CreateIntegrationForm.tsx

@@ -1,5 +1,7 @@
 import React, { Component } from "react";
 
+import styled from "styled-components";
+
 import DockerHubForm from "./DockerHubForm";
 import GKEForm from "./GKEForm";
 import EKSForm from "./EKSForm";

+ 37 - 29
dashboard/src/main/home/modals/UpgradeChartModal.tsx

@@ -23,54 +23,62 @@ type StateType = {
 
 export default class UpgradeChartModal extends Component<PropsType, StateType> {
   state = {
-    notes: "Loading"
+    notes: "Loading",
   };
 
   componentDidMount() {
     // get the chart update notes from the api
-    let repoURL = process.env.ADDON_CHART_REPO_URL
-    let chartName = this.props.currentChart.chart.metadata.name.toLowerCase().trim()
+    let repoURL = process.env.ADDON_CHART_REPO_URL;
+    let chartName = this.props.currentChart.chart.metadata.name
+      .toLowerCase()
+      .trim();
 
     if (chartName == "web" || chartName == "worker") {
-        repoURL = process.env.APPLICATION_CHART_REPO_URL
+      repoURL = process.env.APPLICATION_CHART_REPO_URL;
     }
 
     api
-    .getTemplateUpgradeNotes("<token>", {
-        repo_url: repoURL,
-        prev_version: this.props.currentChart.chart.metadata.version,
-     }, {
-      name: chartName,
-      version: this.props.currentChart.latest_version,
-    })
-    .then((res) => {
-      if (!res.data.upgrade_notes || res.data.upgrade_notes.length == 0) {
-        this.setState({ notes: `
+      .getTemplateUpgradeNotes(
+        "<token>",
+        {
+          repo_url: repoURL,
+          prev_version: this.props.currentChart.chart.metadata.version,
+        },
+        {
+          name: chartName,
+          version: this.props.currentChart.latest_version,
+        }
+      )
+      .then((res) => {
+        if (!res.data.upgrade_notes || res.data.upgrade_notes.length == 0) {
+          this.setState({
+            notes: `
 ## Version ${this.props.currentChart.chart.metadata.version} -> ${this.props.currentChart.latest_version}
 No upgrade notes available. This update should be backwards-compatible. 
-        `})
+        `,
+          });
 
-        return
-      }
+          return;
+        }
 
-        let noteArr = res.data.upgrade_notes.map((note : any) => {
-            return `
+        let noteArr = res.data.upgrade_notes.map((note: any) => {
+          return `
 ## Version ${note.previous} -> ${note.target}
 ${note.note}
-            `
-        })
+            `;
+        });
 
-        this.setState({ notes: noteArr.join("\n")})
-    })
-    .catch((err) => console.log(err));
-}
+        this.setState({ notes: noteArr.join("\n") });
+      })
+      .catch((err) => console.log(err));
+  }
 
   renderContent() {
     if (this.state.notes == "Loading") {
-      return <Loading />
+      return <Loading />;
     }
 
-    return <Markdown>{this.state.notes}</Markdown>
+    return <Markdown>{this.state.notes}</Markdown>;
   }
 
   render() {
@@ -140,7 +148,7 @@ const StyledUpgradeChartModal = styled.div`
   overflow: hidden;
   border-radius: 6px;
   background: #202227;
-  font-size: 13px; 
-  line-height: 1.8em; 
+  font-size: 13px;
+  line-height: 1.8em;
   font-family: Work Sans, sans-serif;
 `;

+ 2 - 1
internal/integrations/ci/actions/actions.go

@@ -29,6 +29,7 @@ type GithubActions struct {
 
 	GithubConf           *oauth2.Config // one of these will let us authenticate
 	GithubAppID          int64
+	GithubAppSecretPath  string
 	GithubInstallationID uint
 
 	WebhookToken string
@@ -229,7 +230,7 @@ func (g *GithubActions) getClient() (*github.Client, error) {
 		http.DefaultTransport,
 		g.GithubAppID,
 		int64(g.GithubInstallationID),
-		"/porter/docker/github_app_private_key.pem")
+		g.GithubAppSecretPath)
 
 	if err != nil {
 		return nil, err

+ 1 - 0
server/api/deploy_handler.go

@@ -375,6 +375,7 @@ func (app *App) HandleUninstallTemplate(w http.ResponseWriter, r *http.Request)
 					ServerURL:              app.ServerConf.ServerURL,
 					GithubOAuthIntegration: gr,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],

+ 1 - 0
server/api/git_action_handler.go

@@ -159,6 +159,7 @@ func (app *App) createGitActionFromForm(
 		ServerURL:              app.ServerConf.ServerURL,
 		GithubOAuthIntegration: nil,
 		GithubAppID:            app.GithubAppConf.AppID,
+		GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 		GithubInstallationID:   form.GitRepoID,
 		GitRepoName:            repoSplit[1],
 		GitRepoOwner:           repoSplit[0],

+ 1 - 1
server/api/git_repo_handler.go

@@ -501,7 +501,7 @@ func (app *App) githubAppClientFromRequest(r *http.Request) (*github.Client, err
 		http.DefaultTransport,
 		app.GithubAppConf.AppID,
 		int64(installationID),
-		"/porter/docker/github_app_private_key.pem")
+		app.GithubAppConf.SecretPath)
 
 	if err != nil {
 		return nil, err

+ 2 - 0
server/api/release_handler.go

@@ -1102,6 +1102,7 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
 					GithubOAuthIntegration: gr,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,
@@ -1517,6 +1518,7 @@ func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request) {
 					GithubOAuthIntegration: gr,
 					GithubInstallationID:   gitAction.GithubInstallationID,
 					GithubAppID:            app.GithubAppConf.AppID,
+					GithubAppSecretPath:    app.GithubAppConf.SecretPath,
 					GitRepoName:            repoSplit[1],
 					GitRepoOwner:           repoSplit[0],
 					Repo:                   *app.Repo,