Skip to content

Commit

Permalink
Merge branch 'master' of github.com:porter-dev/porter into app-v2-ui-…
Browse files Browse the repository at this point in the history
…cleanup
  • Loading branch information
Justin Rhee authored and Justin Rhee committed Sep 21, 2023
2 parents db24c42 + 62da923 commit 6ba025f
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 279 deletions.
48 changes: 31 additions & 17 deletions api/server/handlers/environment_groups/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (c *ListEnvironmentGroupsHandler) ServeHTTP(w http.ResponseWriter, r *http.
ctx, span := telemetry.NewSpan(r.Context(), "serve-list-env-groups")
defer span.End()

project, _ := ctx.Value(types.ProjectScope).(*models.Project)
cluster, _ := ctx.Value(types.ClusterScope).(*models.Cluster)

agent, err := c.GetAgent(r, cluster, "")
Expand Down Expand Up @@ -84,26 +85,39 @@ func (c *ListEnvironmentGroupsHandler) ServeHTTP(w http.ResponseWriter, r *http.
return
}

applications, err := environmentgroups.LinkedApplications(ctx, agent, latestVersion.Name)
if err != nil {
err = telemetry.Error(ctx, span, err, "unable to get linked applications")
c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
return
}
var linkedApplications []string
if !project.GetFeatureFlag(models.ValidateApplyV2, c.Config().LaunchDarklyClient) {
applications, err := environmentgroups.LinkedApplications(ctx, agent, latestVersion.Name, true)
if err != nil {
err = telemetry.Error(ctx, span, err, "unable to get linked applications")
c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
return
}

applicationSetForEnvGroup := make(map[string]struct{})
for _, app := range applications {
if app.Namespace == "" {
continue
applicationSetForEnvGroup := make(map[string]struct{})
for _, app := range applications {
if app.Namespace == "" {
continue
}
if _, ok := applicationSetForEnvGroup[app.Namespace]; !ok {
applicationSetForEnvGroup[app.Namespace] = struct{}{}
}
}
if _, ok := applicationSetForEnvGroup[app.Namespace]; !ok {
applicationSetForEnvGroup[app.Namespace] = struct{}{}
for appNamespace := range applicationSetForEnvGroup {
porterAppName := strings.TrimPrefix(appNamespace, "porter-stack-")
linkedApplications = append(linkedApplications, porterAppName)
}
} else {
applications, err := environmentgroups.LinkedApplications(ctx, agent, latestVersion.Name, false)
if err != nil {
err = telemetry.Error(ctx, span, err, "unable to get linked applications")
c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
return
}

for _, app := range applications {
linkedApplications = append(linkedApplications, app.Name)
}
}
var linkedApplications []string
for appNamespace := range applicationSetForEnvGroup {
porterAppName := strings.TrimPrefix(appNamespace, "porter-stack-")
linkedApplications = append(linkedApplications, porterAppName)
}

secrets := make(map[string]string)
Expand Down
Binary file added dashboard/src/assets/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6ba025f

Please sign in to comment.