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

use correct GAR image URI during launch flow

Mohammed Nafees 3 лет назад
Родитель
Сommit
dfb32c9e3e
2 измененных файлов с 11 добавлено и 7 удалено
  1. 6 7
      cli/cmd/connect/gar.go
  2. 5 0
      dashboard/src/main/home/launch/launch-flow/LaunchFlow.tsx

+ 6 - 7
cli/cmd/connect/gar.go

@@ -3,7 +3,6 @@ package connect
 import (
 	"context"
 	"fmt"
-	"io/ioutil"
 	"os"
 
 	"github.com/fatih/color"
@@ -23,8 +22,8 @@ func GAR(
 		return 0, fmt.Errorf("no project set, please run porter config set-project")
 	}
 
-	keyFileLocation, err := utils.PromptPlaintext(fmt.Sprintf(`Please provide the full path to a service account key file.
-Key file location: `))
+	keyFileLocation, err := utils.PromptPlaintext(`Please provide the full path to a service account key file.
+Key file location: `)
 
 	if err != nil {
 		return 0, err
@@ -33,7 +32,7 @@ Key file location: `))
 	// attempt to read the key file location
 	if info, err := os.Stat(keyFileLocation); !os.IsNotExist(err) && !info.IsDir() {
 		// read the file
-		bytes, err := ioutil.ReadFile(keyFileLocation)
+		bytes, err := os.ReadFile(keyFileLocation)
 
 		if err != nil {
 			return 0, err
@@ -54,8 +53,8 @@ Key file location: `))
 
 		color.New(color.FgGreen).Printf("created gcp integration with id %d\n", integration.ID)
 
-		region, err := utils.PromptPlaintext(fmt.Sprintf(`Please enter the artifact registry region. For example, us-central-1.
-Artifact registry region: `))
+		region, err := utils.PromptPlaintext(`Please enter the artifact registry region. For example, us-central1.
+Artifact registry region: `)
 
 		if err != nil {
 			return 0, err
@@ -63,7 +62,7 @@ Artifact registry region: `))
 
 		// create the registry
 		// query for registry name
-		regName, err := utils.PromptPlaintext(fmt.Sprintf(`Give this registry a name: `))
+		regName, err := utils.PromptPlaintext("Give this registry a name: ")
 
 		if err != nil {
 			return 0, err

+ 5 - 0
dashboard/src/main/home/launch/launch-flow/LaunchFlow.tsx

@@ -78,6 +78,11 @@ const LaunchFlow: React.FC<PropsType> = (props) => {
       imageRepoUri = selectedRegistry?.url;
     }
 
+    // Customize image repo URI for GAR
+    if (imageRepoUri.includes("pkg.dev")) {
+      imageRepoUri = `${imageRepoUri}/${templateName}-${selectedNamespace}`;
+    }
+
     if (actionConfig.kind === "github") {
       return {
         kind: "github",