diff --git a/api/server/handlers/deployment_target/create.go b/api/server/handlers/deployment_target/create.go
index 77e978237d..0741716fbf 100644
--- a/api/server/handlers/deployment_target/create.go
+++ b/api/server/handlers/deployment_target/create.go
@@ -71,12 +71,24 @@ func (c *CreateDeploymentTargetHandler) ServeHTTP(w http.ResponseWriter, r *http
name = request.Selector
}
+ var metadata *porterv1.DeploymentTargetMeta
+ if request.Metadata.PullRequest.Repository != "" {
+ metadata = &porterv1.DeploymentTargetMeta{
+ PullRequest: &porterv1.PullRequest{
+ Number: int64(request.Metadata.PullRequest.Number),
+ Repository: request.Metadata.PullRequest.Repository,
+ HeadRef: request.Metadata.PullRequest.HeadRef,
+ },
+ }
+ }
+
createReq := connect.NewRequest(&porterv1.CreateDeploymentTargetRequest{
ProjectId: int64(project.ID),
ClusterId: int64(clusterId),
Name: name,
Namespace: name,
IsPreview: request.Preview,
+ Metadata: metadata,
})
ccpResp, err := c.Config().ClusterControlPlaneClient.CreateDeploymentTarget(ctx, createReq)
diff --git a/api/types/deployment_target.go b/api/types/deployment_target.go
index b98b343ea7..5b62d0571c 100644
--- a/api/types/deployment_target.go
+++ b/api/types/deployment_target.go
@@ -28,6 +28,21 @@ type CreateDeploymentTargetRequest struct {
Preview bool `json:"preview"`
// required if using the project-scoped endpoint
ClusterId uint `json:"cluster_id"`
+ // optional metadata field
+ Metadata Metadata `json:"metadata,omitempty"`
+}
+
+// Metadata is a DB-level representation of the metadata field in a deployment target
+type Metadata struct {
+ PullRequest TargetPullRequest `json:"pull_request"`
+}
+
+// TargetPullRequest represents a pull request in the metadata field of a deployment target
+type TargetPullRequest struct {
+ Repository string `json:"repository"`
+ Number int `json:"number"`
+ Title string `json:"title"`
+ HeadRef string `json:"head_ref"`
}
// CreateDeploymentTargetResponse is the response object for the /deployment-targets POST endpoint
diff --git a/cli/cmd/v2/apply.go b/cli/cmd/v2/apply.go
index dc9f5165f5..916547fee7 100644
--- a/cli/cmd/v2/apply.go
+++ b/cli/cmd/v2/apply.go
@@ -81,18 +81,19 @@ func Apply(ctx context.Context, inp ApplyInput) error {
return errors.New("cluster must be set")
}
- deploymentTargetID, err := deploymentTargetFromConfig(ctx, client, cliConf.Project, cliConf.Cluster, inp.PreviewApply)
- if err != nil {
- return fmt.Errorf("error getting deployment target from config: %w", err)
- }
-
var prNumber int
prNumberEnv := os.Getenv("PORTER_PR_NUMBER")
if prNumberEnv != "" {
- prNumber, err = strconv.Atoi(prNumberEnv)
+ parsedPRInt, err := strconv.Atoi(prNumberEnv)
if err != nil {
return fmt.Errorf("error parsing PORTER_PR_NUMBER to int: %w", err)
}
+ prNumber = parsedPRInt
+ }
+
+ deploymentTargetID, err := deploymentTargetFromConfig(ctx, client, cliConf.Project, cliConf.Cluster, inp.PreviewApply, prNumber)
+ if err != nil {
+ return fmt.Errorf("error getting deployment target from config: %w", err)
}
porterYamlExists := len(inp.PorterYamlPath) != 0
@@ -343,7 +344,7 @@ func commitSHAFromEnv() string {
return commitSHA
}
-func deploymentTargetFromConfig(ctx context.Context, client api.Client, projectID, clusterID uint, previewApply bool) (string, error) {
+func deploymentTargetFromConfig(ctx context.Context, client api.Client, projectID, clusterID uint, previewApply bool, prNumber int) (string, error) {
var deploymentTargetID string
if os.Getenv("PORTER_DEPLOYMENT_TARGET_ID") != "" {
@@ -375,11 +376,25 @@ func deploymentTargetFromConfig(ctx context.Context, client api.Client, projectI
return deploymentTargetID, errors.New("branch name is empty. Please run apply in a git repository with access to the git CLI")
}
+ var repository string
+ if os.Getenv("PORTER_REPO_NAME") != "" {
+ repository = os.Getenv("PORTER_REPO_NAME")
+ } else if os.Getenv("GITHUB_REPOSITORY") != "" {
+ repository = os.Getenv("GITHUB_REPOSITORY")
+ }
+
targetResp, err := client.CreateDeploymentTarget(ctx, projectID, &types.CreateDeploymentTargetRequest{
Selector: "",
Name: branchName,
Preview: true,
ClusterId: clusterID,
+ Metadata: types.Metadata{
+ PullRequest: types.TargetPullRequest{
+ Repository: repository,
+ Number: prNumber,
+ HeadRef: branchName,
+ },
+ },
})
if err != nil {
return deploymentTargetID, fmt.Errorf("error calling create deployment target endpoint: %w", err)
diff --git a/dashboard/src/assets/git-compare.svg b/dashboard/src/assets/git-compare.svg
new file mode 100644
index 0000000000..7ccb5ef61a
--- /dev/null
+++ b/dashboard/src/assets/git-compare.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/dashboard/src/lib/hooks/useAddon.ts b/dashboard/src/lib/hooks/useAddon.ts
index 78f7ebac3d..f5d37fb043 100644
--- a/dashboard/src/lib/hooks/useAddon.ts
+++ b/dashboard/src/lib/hooks/useAddon.ts
@@ -139,7 +139,7 @@ export const useAddonList = ({
"monitoring",
"porter-agent-system",
"external-secrets",
- "infisical-operator"
+ "infisical"
].includes(a.namespace ?? "");
});
},
diff --git a/dashboard/src/main/home/add-on-dashboard/legacy_AddOnDashboard.tsx b/dashboard/src/main/home/add-on-dashboard/legacy_AddOnDashboard.tsx
index 6432d9f0d8..d335d0f5a7 100644
--- a/dashboard/src/main/home/add-on-dashboard/legacy_AddOnDashboard.tsx
+++ b/dashboard/src/main/home/add-on-dashboard/legacy_AddOnDashboard.tsx
@@ -50,7 +50,7 @@ export const RestrictedNamespaces = [
"monitoring",
"porter-agent-system",
"external-secrets",
- "infisical-operator"
+ "infisical",
];
const templateBlacklist = ["web", "worker", "job", "umbrella"];
diff --git a/dashboard/src/main/home/app-dashboard/new-app-flow/utils.ts b/dashboard/src/main/home/app-dashboard/new-app-flow/utils.ts
index e7be71bd99..0262e51970 100644
--- a/dashboard/src/main/home/app-dashboard/new-app-flow/utils.ts
+++ b/dashboard/src/main/home/app-dashboard/new-app-flow/utils.ts
@@ -24,7 +24,7 @@ export const getGithubAction = (
stackName: string,
branchName: string,
porterYamlPath: string = "porter.yaml",
- deploymentTargetId: string = "",
+ deploymentTargetId: string = ""
): string => {
return `on:
push:
@@ -52,7 +52,11 @@ jobs:
PORTER_STACK_NAME: ${stackName}
PORTER_TAG: \${{ steps.vars.outputs.sha_short }}
PORTER_TOKEN: \${{ secrets.PORTER_STACK_${projectID}_${clusterId} }}
- ${deploymentTargetId ? `PORTER_DEPLOYMENT_TARGET_ID: ${deploymentTargetId}` : ""}`;
+ ${
+ deploymentTargetId
+ ? `PORTER_DEPLOYMENT_TARGET_ID: ${deploymentTargetId}`
+ : ""
+ }`;
};
export const getPreviewGithubAction = ({
@@ -67,7 +71,7 @@ export const getPreviewGithubAction = ({
appName: string;
branch: string;
porterYamlPath?: string;
-}) => {
+}): string => {
return `"on":
pull_request:
branches:
@@ -101,5 +105,6 @@ jobs:
PORTER_STACK_NAME: ${appName}
PORTER_TAG: \${{ steps.vars.outputs.sha_short }}
PORTER_TOKEN: \${{ secrets.PORTER_STACK_${projectId}_${clusterId} }}
- PORTER_PR_NUMBER: \${{ github.event.number }}`;
+ PORTER_PR_NUMBER: \${{ github.event.number }}
+ PORTER_REPO_NAME: \${{ github.event.repository.name }}`;
};
diff --git a/dashboard/src/main/home/cluster-dashboard/preview-environments/v2/ConfigurableAppList.tsx b/dashboard/src/main/home/cluster-dashboard/preview-environments/v2/ConfigurableAppList.tsx
index 93e5946925..63fa08cc4a 100644
--- a/dashboard/src/main/home/cluster-dashboard/preview-environments/v2/ConfigurableAppList.tsx
+++ b/dashboard/src/main/home/cluster-dashboard/preview-environments/v2/ConfigurableAppList.tsx
@@ -24,10 +24,6 @@ export const ConfigurableAppList: React.FC = () => {
clusterId: currentCluster?.id ?? 0,
});
- if (status === "loading") {
- return