浏览代码

patch GCP build repo name (#4501)

d-g-town 2 年之前
父节点
当前提交
f31144c561
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      cli/cmd/v2/build.go

+ 9 - 0
cli/cmd/v2/build.go

@@ -71,8 +71,17 @@ func build(ctx context.Context, client api.Client, inp buildInput) buildOutput {
 		output.Error = errors.New("must specify a registry url")
 		return output
 	}
+
 	repositoryURL := strings.TrimPrefix(inp.RepositoryURL, "https://")
 
+	// this should catch the following v1 GCP repo format:
+	// us-central1-docker.pkg.dev/GCP_PROJECT/porter-PORTER_PROJECT/APP_NAME-porter-stack-APP_NAME/APP_NAME-porter-stack-APP_NAME
+	// and convert it to:
+	// us-central1-docker.pkg.dev/GCP_PROJECT/porter-PORTER_PROJECT/APP_NAME
+	if splits := strings.Split(repositoryURL, "porter-stack"); len(splits) == 3 {
+		repositoryURL = strings.TrimSuffix(splits[0], "-")
+	}
+
 	err := createImageRepositoryIfNotExists(ctx, client, projectID, repositoryURL)
 	if err != nil {
 		output.Error = fmt.Errorf("error creating image repository: %w", err)