Ver Fonte

Bashing stacks bugs (#2995)

Feroze Mohideen há 3 anos atrás
pai
commit
e90d7275d2

+ 7 - 0
api/server/handlers/stacks/create_porter_app.go

@@ -84,6 +84,13 @@ func (c *CreatePorterAppHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
 	if shouldCreate || request.OverrideRelease {
 		releaseValues = nil
 		releaseDependencies = nil
+
+		// this is required because when the front-end sends an update request with overrideRelease=true, it is unable to
+		// get the image info from the release. unless it is explicitly provided in the request, we avoid overwriting it
+		// by attempting to get the image info from the release
+		if imageInfo.Repository == "" || imageInfo.Tag == "" {
+			imageInfo = attemptToGetImageInfoFromRelease(helmRelease.Config)
+		}
 	} else {
 		releaseValues = helmRelease.Config
 		releaseDependencies = helmRelease.Chart.Metadata.Dependencies

+ 16 - 2
api/server/handlers/stacks/parse.go

@@ -304,8 +304,8 @@ func convertMap(m interface{}) interface{} {
 	return m
 }
 
-func CopyEnv(env map[string]string) map[string]string {
-	envCopy := make(map[string]string)
+func CopyEnv(env map[string]string) map[string]interface{} {
+	envCopy := make(map[string]interface{})
 	if env == nil {
 		return envCopy
 	}
@@ -451,3 +451,17 @@ func getChartTypeFromHelmName(name string) string {
 	}
 	return ""
 }
+
+func attemptToGetImageInfoFromRelease(values map[string]interface{}) types.ImageInfo {
+	imageInfo := types.ImageInfo{}
+	if imageVal, ok := values["global"].(map[string]interface{})["image"]; ok {
+		imageMap := imageVal.(map[string]interface{})
+		if repo, ok := imageMap["repository"]; ok {
+			imageInfo.Repository = repo.(string)
+		}
+		if tag, ok := imageMap["tag"]; ok {
+			imageInfo.Tag = tag.(string)
+		}
+	}
+	return imageInfo
+}

+ 2 - 5
dashboard/src/main/home/app-dashboard/expanded-app/BuildSettingsTabStack.tsx

@@ -149,7 +149,7 @@ const BuildSettingsTabStack: React.FC<Props> = ({
         }
         setCurrentError(
           'The workflow is still running. You can "Save" the current build settings for the next workflow run and view the current status of the workflow here: ' +
-            tmpError.response.data
+          tmpError.response.data
         );
         return;
       }
@@ -174,9 +174,6 @@ const BuildSettingsTabStack: React.FC<Props> = ({
     }
   };
   const saveConfig = async () => {
-    console.log(appData);
-    console.log(appData.app.dockerfile);
-    console.log(buildView);
     try {
       await updatePorterApp({
         repo_name: appData.app.repo_name,
@@ -349,7 +346,7 @@ const StyledAdvancedBuildSettings = styled.div`
     cursor: pointer;
     border-radius: 20px;
     transform: ${(props: { showSettings: boolean; isCurrent: boolean }) =>
-      props.showSettings ? "" : "rotate(-90deg)"};
+    props.showSettings ? "" : "rotate(-90deg)"};
   }
 `;
 const StyledSourceBox = styled.div`

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

@@ -285,7 +285,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
       const porterYamlToJson = parsedData as PorterJson;
       return porterYamlToJson;
     } catch (err) {
-      console.log(err);
+      // TODO: handle error
     }
   };
 
@@ -694,7 +694,7 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
                     shouldUpdate={
                       appData.chart.latest_version &&
                       appData.chart.latest_version !==
-                        appData.chart.chart.metadata.version
+                      appData.chart.chart.metadata.version
                     }
                     latestVersion={appData.chart.latest_version}
                     upgradeVersion={appUpgradeVersion}
@@ -708,34 +708,34 @@ const ExpandedApp: React.FC<Props> = ({ ...props }) => {
                   appData.app.git_repo_id
                     ? hasBuiltImage
                       ? [
-                          { label: "Logs", value: "logs" },
-                          { label: "Overview", value: "overview" },
-                          {
-                            label: "Environment variables",
-                            value: "environment-variables",
-                          },
-                          { label: "Build settings", value: "build-settings" },
-                          { label: "Settings", value: "settings" },
-                        ]
-                      : [
-                          { label: "Overview", value: "overview" },
-                          {
-                            label: "Environment variables",
-                            value: "environment-variables",
-                          },
-                          { label: "Build settings", value: "build-settings" },
-                          { label: "Settings", value: "settings" },
-                        ]
-                    : [
                         { label: "Overview", value: "overview" },
-                        { label: "Events", value: "events" },
                         { label: "Logs", value: "logs" },
                         {
                           label: "Environment variables",
                           value: "environment-variables",
                         },
+                        { label: "Build settings", value: "build-settings" },
+                        { label: "Settings", value: "settings" },
+                      ]
+                      : [
+                        { label: "Overview", value: "overview" },
+                        {
+                          label: "Environment variables",
+                          value: "environment-variables",
+                        },
+                        { label: "Build settings", value: "build-settings" },
                         { label: "Settings", value: "settings" },
                       ]
+                    : [
+                      { label: "Overview", value: "overview" },
+                      { label: "Events", value: "events" },
+                      { label: "Logs", value: "logs" },
+                      {
+                        label: "Environment variables",
+                        value: "environment-variables",
+                      },
+                      { label: "Settings", value: "settings" },
+                    ]
                 }
                 currentTab={tab}
                 setCurrentTab={(tab: string) => {

+ 3 - 3
dashboard/src/main/home/app-dashboard/new-app-flow/AdvancedBuildSettings.tsx

@@ -42,7 +42,7 @@ const AdvancedBuildSettings: React.FC<AdvancedBuildSettingsProps> = (props) => {
   const [showSettings, setShowSettings] = useState<boolean>(props.showSettings);
   const buildView = props.setBuildView(props.buildView || "buildpacks");
 
-  useEffect(() => {}, [props.buildView]);
+  useEffect(() => { }, [props.buildView]);
   const createDockerView = () => {
     // props.setBuildConfig({});
     return (
@@ -126,7 +126,7 @@ export default AdvancedBuildSettings;
 
 const StyledAdvancedBuildSettings = styled.div`
   color: ${({ showSettings }) => (showSettings ? "white" : "#aaaabb")};
-  background: #26292e;
+  background: ${({ theme }) => theme.fg};
   border: 1px solid #494b4f;
   :hover {
     border: 1px solid #7a7b80;
@@ -151,7 +151,7 @@ const StyledAdvancedBuildSettings = styled.div`
     cursor: pointer;
     border-radius: 20px;
     transform: ${(props: { showSettings: boolean; isCurrent: boolean }) =>
-      props.showSettings ? "" : "rotate(-90deg)"};
+    props.showSettings ? "" : "rotate(-90deg)"};
   }
 `;