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

Merge branch 'master' of github.com:porter-dev/porter into nico/new-onboarding-flow

jnfrati 4 лет назад
Родитель
Сommit
e82542c45c

+ 1 - 0
.github/workflows/production.yaml

@@ -30,6 +30,7 @@ jobs:
           cat >./dashboard/.env <<EOL
           NODE_ENV=production
           API_SERVER=dashboard.getporter.dev
+          COHERE_API_KEY=${{secrets.COHERE_API_KEY}}
           DISCORD_KEY=${{secrets.DISCORD_KEY}}
           DISCORD_CID=${{secrets.DISCORD_CID}}
           FEEDBACK_ENDPOINT=${{secrets.FEEDBACK_ENDPOINT}}

+ 32 - 0
api/server/handlers/release/get.go

@@ -3,12 +3,14 @@ package release
 import (
 	"net/http"
 
+	semver "github.com/Masterminds/semver/v3"
 	"github.com/porter-dev/porter/api/server/authz"
 	"github.com/porter-dev/porter/api/server/handlers"
 	"github.com/porter-dev/porter/api/server/shared"
 	"github.com/porter-dev/porter/api/server/shared/apierrors"
 	"github.com/porter-dev/porter/api/server/shared/config"
 	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/internal/helm/loader"
 	"github.com/porter-dev/porter/internal/models"
 	"github.com/porter-dev/porter/internal/templater/parser"
 	"gorm.io/gorm"
@@ -53,6 +55,36 @@ func (c *ReleaseGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	} else if err != gorm.ErrRecordNotFound {
 		c.HandleAPIError(w, r, apierrors.NewErrInternal(err))
 		return
+	} else {
+		res.PorterRelease = &types.PorterRelease{}
+	}
+
+	// detect if Porter application chart and attempt to get the latest version
+	// from chart repo
+	cache := c.Config().URLCache
+	chartRepoURL, foundFirst := cache.GetURL(helmRelease.Chart.Metadata.Name)
+
+	if !foundFirst {
+		cache.Update()
+
+		chartRepoURL, _ = cache.GetURL(helmRelease.Chart.Metadata.Name)
+	}
+
+	if chartRepoURL != "" {
+		repoIndex, err := loader.LoadRepoIndexPublic(chartRepoURL)
+
+		if err == nil {
+			porterChart := loader.FindPorterChartInIndexList(repoIndex, res.Chart.Metadata.Name)
+			res.LatestVersion = res.Chart.Metadata.Version
+
+			// set latest version to the greater of porterChart.Versions and res.Chart.Metadata.Version
+			porterChartVersion, porterChartErr := semver.NewVersion(porterChart.Versions[0])
+			currChartVersion, currChartErr := semver.NewVersion(res.Chart.Metadata.Version)
+
+			if currChartErr == nil && porterChartErr == nil && porterChartVersion.GreaterThan(currChartVersion) {
+				res.LatestVersion = porterChart.Versions[0]
+			}
+		}
 	}
 
 	// look for the form using the dynamic client

+ 1 - 0
api/types/release.go

@@ -17,6 +17,7 @@ type Release struct {
 type PorterRelease struct {
 	ID              uint             `json:"id"`
 	WebhookToken    string           `json:"webhook_token"`
+	LatestVersion   string           `json:"latest_version"`
 	GitActionConfig *GitActionConfig `json:"git_action_config,omitempty"`
 	ImageRepoURI    string           `json:"image_repo_uri"`
 }

+ 5 - 0
dashboard/package-lock.json

@@ -5032,6 +5032,11 @@
       "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
       "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
     },
+    "cohere-js": {
+      "version": "1.0.19",
+      "resolved": "https://registry.npmjs.org/cohere-js/-/cohere-js-1.0.19.tgz",
+      "integrity": "sha512-2XVX2LUKHjbJ4GCsnizXnAVHZfq9RM1RmHl8zE4G2ORdXmDpzSx5i0UIj/0GZ3AwjKIlYsrGA4kdCGT+WapjPQ=="
+    },
     "collection-visit": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",

+ 1 - 0
dashboard/package.json

@@ -21,6 +21,7 @@
     "axios": "^0.20.0",
     "brace": "^0.11.1",
     "clipboard": "^2.0.8",
+    "cohere-js": "^1.0.19",
     "core-js": "^3.16.1",
     "d3-array": "^2.11.0",
     "d3-time-format": "^3.0.0",

+ 36 - 0
dashboard/src/index.html

@@ -3,6 +3,42 @@
   <head>
     <title>Porter | Dashboard</title>
 
+    <script>
+      !(function () {
+        var e = (window.Cohere = window.Cohere || []);
+        if (e.invoked) console.error("Tried to load Cohere twice");
+        else {
+          (e.invoked = !0),
+            (e.snippet = "0.2"),
+            (e.methods = [
+              "init",
+              "identify",
+              "stop",
+              "showCode",
+              "getSessionUrl",
+              "makeCall",
+              "addCallStatusListener",
+              "removeCallStatusListener",
+              "widget",
+            ]),
+            e.methods.forEach(function (o) {
+              e[o] = function () {
+                var t = Array.prototype.slice.call(arguments);
+                t.unshift(o), e.push(t);
+              };
+            });
+          var o = document.createElement("script");
+          (o.type = "text/javascript"),
+            (o.async = !0),
+            (o.src = "https://static.cohere.so/main.js"),
+            (o.crossOrigin = "anonymous");
+          var t = document.getElementsByTagName("script")[0];
+          t.parentNode.insertBefore(o, t);
+        }
+      })();
+      window.Cohere.init("_A-2HNgriISqaQq4yzTxM8V-");
+    </script>
+
     <script>
       !(function () {
         var analytics = (window.analytics = window.analytics || []);

+ 10 - 0
dashboard/src/main/Main.tsx

@@ -3,6 +3,9 @@ import { Route, Redirect, Switch } from "react-router-dom";
 
 import api from "shared/api";
 import { Context } from "shared/Context";
+import Cohere from "cohere-js";
+
+Cohere.init(process.env.COHERE_API_KEY);
 
 import ResetPasswordInit from "./auth/ResetPasswordInit";
 import ResetPasswordFinalize from "./auth/ResetPasswordFinalize";
@@ -42,6 +45,13 @@ export default class Main extends Component<PropsType, StateType> {
       .checkAuth("", {}, {})
       .then((res) => {
         if (res && res?.data) {
+          Cohere.identify(
+            res?.data?.id, 
+            {
+              displayName: res?.data?.email,
+              email: res?.data?.email, 
+            }
+          );
           setUser(res?.data?.id, res?.data?.email);
           this.setState({
             isLoggedIn: true,

+ 1 - 5
dashboard/src/main/home/NoClusterPlaceholder.tsx

@@ -25,11 +25,7 @@ class NoClusterPlaceholder extends Component<PropsType, StateType> {
         <br />
         <br />
         1. If you're deploying from a repo{" "}
-        <A
-          onClick={() =>
-            window.open(`/api/oauth/projects/${currentProject.id}/github`)
-          }
-        >
+        <A href={"/api/integrations/github-app/oauth"}>
           link your GitHub account
         </A>
         <br />

+ 1 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -608,14 +608,13 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
       await api.upgradeChartValues(
         "<token>",
         {
-          namespace: currentChart.namespace,
-          storage: StorageType.Secret,
           values: valuesYaml,
           version: version,
         },
         {
           id: this.context.currentProject.id,
           name: currentChart.name,
+          namespace: currentChart.namespace,
           cluster_id: this.context.currentCluster.id,
         }
       );

+ 1 - 1
dashboard/src/main/home/launch/Launch.tsx

@@ -325,7 +325,7 @@ class Templates extends Component<PropsType, StateType> {
         <TemplatesWrapper>
           <TitleSection>
             Launch
-            <a href="https://docs.getporter.dev/docs/add-ons" target="_blank">
+            <a href="https://docs.porter.run/docs/applications" target="_blank">
               <i className="material-icons">help_outline</i>
             </a>
           </TitleSection>

+ 1 - 1
dashboard/src/main/home/launch/launch-flow/SourcePage.tsx

@@ -275,7 +275,7 @@ class SourcePage extends Component<PropsType, StateType> {
         <Helper>
           Learn more about
           <Highlight
-            href="https://docs.getporter.dev/docs/add-ons"
+            href="https://docs.porter.run/docs/applications"
             target="_blank"
           >
             deploying services to Porter