Przeglądaj źródła

fix merge conflicts

Alexander Belanger 4 lat temu
rodzic
commit
a2f68d81cf

+ 42 - 0
api/server/handlers/project/get_policy.go

@@ -0,0 +1,42 @@
+package project
+
+import (
+	"github.com/porter-dev/porter/api/server/authz/policy"
+	"github.com/porter-dev/porter/api/server/shared/apierrors"
+	"net/http"
+
+	"github.com/porter-dev/porter/api/server/handlers"
+	"github.com/porter-dev/porter/api/server/shared"
+	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/internal/models"
+)
+
+type ProjectGetPolicyHandler struct {
+	handlers.PorterHandlerWriter
+}
+
+func NewProjectGetPolicyHandler(
+	config *shared.Config,
+	writer shared.ResultWriter,
+) *ProjectGetPolicyHandler {
+	return &ProjectGetPolicyHandler{
+		PorterHandlerWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
+	}
+}
+
+func (p *ProjectGetPolicyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+	user, _ := r.Context().Value(types.UserScope).(*models.User)
+	proj, _ := r.Context().Value(types.ProjectScope).(*models.Project)
+
+	policyDocLoader := policy.NewBasicPolicyDocumentLoader(p.Config().Repo.Project())
+
+	policyDocs, err := policyDocLoader.LoadPolicyDocuments(user.ID, proj.ID)
+
+	if err != nil {
+		p.HandleAPIError(w, apierrors.NewErrInternal(err))
+	}
+
+	var res types.GetProjectPolicyResponse = policyDocs
+
+	p.WriteResult(w, res)
+}

+ 44 - 0
api/server/handlers/project/list_infra.go

@@ -0,0 +1,44 @@
+package project
+
+import (
+	"net/http"
+
+	"github.com/porter-dev/porter/api/server/handlers"
+	"github.com/porter-dev/porter/api/server/shared"
+	"github.com/porter-dev/porter/api/server/shared/apierrors"
+	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/internal/models"
+)
+
+type ProjectListInfraHandler struct {
+	handlers.PorterHandlerWriter
+}
+
+func NewProjectListInfraHandler(
+	config *shared.Config,
+	writer shared.ResultWriter,
+) *ProjectListInfraHandler {
+	return &ProjectListInfraHandler{
+		PorterHandlerWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
+	}
+}
+
+func (p *ProjectListInfraHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+	proj, _ := r.Context().Value(types.ProjectScope).(*models.Project)
+
+	infras, err := p.Repo().Infra().ListInfrasByProjectID(proj.ID)
+
+	if err != nil {
+		p.HandleAPIError(w, apierrors.NewErrInternal(err))
+	}
+
+	infraList := make([]*types.Infra, 0)
+
+	for _, infra := range infras {
+		infraList = append(infraList, infra.ToInfraType())
+	}
+
+	var res types.ListProjectInfraResponse = infraList
+
+	p.WriteResult(w, res)
+}

+ 54 - 0
api/server/router/namespace.go

@@ -0,0 +1,54 @@
+package router
+
+import (
+	"github.com/go-chi/chi"
+	"github.com/porter-dev/porter/api/server/shared"
+	"github.com/porter-dev/porter/api/types"
+)
+
+func NewNamespaceScopedRegisterer(children ...*Registerer) *Registerer {
+	return &Registerer{
+		GetRoutes: GetNamespaceScopedRoutes,
+		Children:  children,
+	}
+}
+
+func GetNamespaceScopedRoutes(
+	r chi.Router,
+	config *shared.Config,
+	basePath *types.Path,
+	factory shared.APIEndpointFactory,
+	children ...*Registerer,
+) []*Route {
+	routes, projPath := getNamespaceRoutes(r, config, basePath, factory)
+
+	if len(children) > 0 {
+		r.Route(projPath.RelativePath, func(r chi.Router) {
+			for _, child := range children {
+				childRoutes := child.GetRoutes(r, config, basePath, factory, child.Children...)
+
+				routes = append(routes, childRoutes...)
+			}
+		})
+	}
+
+	return routes
+}
+
+func getNamespaceRoutes(
+	r chi.Router,
+	config *shared.Config,
+	basePath *types.Path,
+	factory shared.APIEndpointFactory,
+) ([]*Route, *types.Path) {
+	relPath := "/namespaces/{namespace}"
+
+	newPath := &types.Path{
+		Parent:       basePath,
+		RelativePath: relPath,
+	}
+
+	routes := make([]*Route, 0)
+
+	return routes, newPath
+}

+ 54 - 0
api/server/router/project.go

@@ -79,6 +79,60 @@ func getProjectRoutes(
 		Router:   r,
 	})
 
+	// GET /api/projects/{project_id}/policy -> project.NewProjectGetPolicyHandler
+	getPolicyEndpoint := factory.NewAPIEndpoint(
+		&types.APIRequestMetadata{
+			Verb:   types.APIVerbGet,
+			Method: types.HTTPVerbGet,
+			Path: &types.Path{
+				Parent:       basePath,
+				RelativePath: relPath + "/policy",
+			},
+			Scopes: []types.PermissionScope{
+				types.UserScope,
+				types.ProjectScope,
+			},
+		},
+	)
+
+	getPolicyHandler := project.NewProjectGetPolicyHandler(
+		config,
+		factory.GetResultWriter(),
+	)
+
+	routes = append(routes, &Route{
+		Endpoint: getPolicyEndpoint,
+		Handler:  getPolicyHandler,
+		Router:   r,
+	})
+
+	// GET /api/projects/{project_id}/infra -> project.NewListProjectInfraHandler
+	listInfraEndpoint := factory.NewAPIEndpoint(
+		&types.APIRequestMetadata{
+			Verb:   types.APIVerbGet,
+			Method: types.HTTPVerbGet,
+			Path: &types.Path{
+				Parent:       basePath,
+				RelativePath: relPath + "/infra",
+			},
+			Scopes: []types.PermissionScope{
+				types.UserScope,
+				types.ProjectScope,
+			},
+		},
+	)
+
+	listInfraHandler := project.NewProjectListInfraHandler(
+		config,
+		factory.GetResultWriter(),
+	)
+
+	routes = append(routes, &Route{
+		Endpoint: listInfraEndpoint,
+		Handler:  listInfraHandler,
+		Router:   r,
+	})
+
 	// GET /api/projects/{project_id}/clusters -> cluster.NewClusterListHandler
 	listClusterEndpoint := factory.NewAPIEndpoint(
 		&types.APIRequestMetadata{

+ 3 - 2
api/server/router/release.go

@@ -42,7 +42,7 @@ func getReleaseRoutes(
 	basePath *types.Path,
 	factory shared.APIEndpointFactory,
 ) ([]*Route, *types.Path) {
-	relPath := "/releases/{namespace}/{name}/{version}"
+	relPath := "/releases/{name}/{version}"
 
 	newPath := &types.Path{
 		Parent:       basePath,
@@ -51,7 +51,7 @@ func getReleaseRoutes(
 
 	routes := make([]*Route, 0)
 
-	// GET /api/projects/{project_id}/clusters/{cluster_id}/releases/{namespace}/{name}/{version} -> release.NewReleaseGetHandler
+	// GET /api/projects/{project_id}/clusters/{cluster_id}/namespaces/{namespace}/releases/{name}/{version} -> release.NewReleaseGetHandler
 	getEndpoint := factory.NewAPIEndpoint(
 		&types.APIRequestMetadata{
 			Verb:   types.APIVerbGet,
@@ -64,6 +64,7 @@ func getReleaseRoutes(
 				types.UserScope,
 				types.ProjectScope,
 				types.ClusterScope,
+				types.NamespaceScope,
 				types.ReleaseScope,
 			},
 		},

+ 2 - 1
api/server/router/router.go

@@ -21,7 +21,8 @@ func NewAPIRouter(config *shared.Config) *chi.Mux {
 	baseRegisterer := NewBaseRegisterer()
 
 	releaseRegisterer := NewReleaseScopedRegisterer()
-	clusterRegisterer := NewClusterScopedRegisterer(releaseRegisterer)
+	namespaceRegisterer := NewNamespaceScopedRegisterer(releaseRegisterer)
+	clusterRegisterer := NewClusterScopedRegisterer(namespaceRegisterer)
 	registryRegisterer := NewRegistryScopedRegisterer()
 	helmRepoRegisterer := NewHelmRepoScopedRegisterer()
 	projRegisterer := NewProjectScopedRegisterer(clusterRegisterer, registryRegisterer, helmRepoRegisterer)

+ 40 - 0
api/types/infra.go

@@ -0,0 +1,40 @@
+package types
+
+// InfraStatus is the status that an infrastructure can take
+type InfraStatus string
+
+// The allowed statuses
+const (
+	StatusCreating   InfraStatus = "creating"
+	StatusCreated    InfraStatus = "created"
+	StatusError      InfraStatus = "error"
+	StatusDestroying InfraStatus = "destroying"
+	StatusDestroyed  InfraStatus = "destroyed"
+)
+
+// InfraKind is the kind that infra can be
+type InfraKind string
+
+// The supported infra kinds
+const (
+	InfraTest InfraKind = "test"
+	InfraECR  InfraKind = "ecr"
+	InfraEKS  InfraKind = "eks"
+	InfraGCR  InfraKind = "gcr"
+	InfraGKE  InfraKind = "gke"
+	InfraDOCR InfraKind = "docr"
+	InfraDOKS InfraKind = "doks"
+)
+
+type Infra struct {
+	ID uint `json:"id"`
+
+	// The project that this integration belongs to
+	ProjectID uint `json:"project_id"`
+
+	// The type of infra that was provisioned
+	Kind InfraKind `json:"kind"`
+
+	// Status is the status of the infra
+	Status InfraStatus `json:"status"`
+}

+ 4 - 0
api/types/project.go

@@ -28,3 +28,7 @@ type DeleteProjectRequest struct {
 }
 
 type DeleteProjectResponse Project
+
+type ListProjectInfraResponse []*Infra
+
+type GetProjectPolicyResponse []*PolicyDocument

+ 2 - 2
cmd/migrate/keyrotate/helpers_test.go

@@ -483,9 +483,9 @@ func initInfra(tester *tester, t *testing.T) {
 	}
 
 	infra := &models.Infra{
-		Kind:        models.InfraECR,
+		Kind:        types.InfraECR,
 		ProjectID:   tester.initProjects[0].Model.ID,
-		Status:      models.StatusCreated,
+		Status:      types.StatusCreated,
 		LastApplied: []byte("testing"),
 	}
 

+ 153 - 0
docs/developing/backend-refactor-status.md

@@ -0,0 +1,153 @@
+| Path                     | Assigned To  | Changed schema? | CLI Updated | Frontend Updated |
+| ------------------------ | ------------ | --------------- | ----------- | ---------------- |
+| <li>- [ ] `GET /api/auth/check` </li> | | | |
+| <li>- [ ] `GET /api/capabilities` </li> | | | |
+| <li>- [ ] `GET /api/cli/login` </li> | | | |
+| <li>- [ ] `GET /api/cli/login/exchange` </li> | | | |
+| <li>- [ ] `GET /api/email/verify/finalize` </li> | | | |
+| <li>- [ ] `POST /api/email/verify/initiate` </li> | | | |
+| <li>- [ ] `GET /api/integrations/cluster` </li> | | | |
+| <li>- [ ] `GET /api/integrations/github-app/access` </li> | | | |
+| <li>- [ ] `GET /api/integrations/github-app/authorize` </li> | | | |
+| <li>- [ ] `GET /api/integrations/github-app/install` </li> | | | |
+| <li>- [ ] `GET /api/integrations/github-app/oauth` </li> | | | |
+| <li>- [ ] `POST /api/integrations/github-app/webhook` </li> | | | |
+| <li>- [ ] `GET /api/integrations/helm` </li> | | | |
+| <li>- [ ] `GET /api/integrations/registry` </li> | | | |
+| <li>- [ ] `GET /api/integrations/repo` </li> | | | |
+| <li>- [ ] `GET /api/livez` </li> | | | |
+| <li>- [ ] `POST /api/login` </li> | | | |
+| <li>- [ ] `POST /api/logout` </li> | | | |
+| <li>- [ ] `GET /api/oauth/digitalocean/callback` </li> | | | |
+| <li>- [ ] `GET /api/oauth/github-app/callback` </li> | | | |
+| <li>- [ ] `GET /api/oauth/github/callback` </li> | | | |
+| <li>- [ ] `GET /api/oauth/google/callback` </li> | | | |
+| <li>- [ ] `GET /api/oauth/login/github` </li> | | | |
+| <li>- [ ] `GET /api/oauth/login/google` </li> | | | |
+| <li>- [ ] `GET /api/oauth/projects/{project_id}/digitalocean` </li> | | | |
+| <li>- [ ] `GET /api/oauth/projects/{project_id}/github` </li> | | | |
+| <li>- [ ] `GET /api/oauth/projects/{project_id}/slack` </li> | | | |
+| <li>- [ ] `GET /api/oauth/slack/callback` </li> | | | |
+| <li>- [ ] `POST /api/password/reset/finalize` </li> | | | |
+| <li>- [ ] `POST /api/password/reset/initiate` </li> | | | |
+| <li>- [ ] `POST /api/password/reset/verify` </li> | | | |
+| <li>- [ ] `POST /api/projects` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/ci/actions/create` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/ci/actions/generate` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/clusters` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/clusters` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/clusters/candidates` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/clusters/candidates` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/clusters/candidates/{candidate_id}/resolve` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/clusters/{cluster_id}` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/clusters/{cluster_id}` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/clusters/{cluster_id}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/clusters/{cluster_id}/node/{node_name}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/clusters/{cluster_id}/nodes` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/collaborators` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/delete/{name}` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/deploy/addon/{name}/{version}` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/deploy/{name}/{version}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos/{kind}/{owner}/{name}/branches` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos/{kind}/{owner}/{name}/{branch}/buildpack/detect` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos/{kind}/{owner}/{name}/{branch}/contents` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos/{kind}/{owner}/{name}/{branch}/procfile` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/gitrepos/{installation_id}/repos/{kind}/{owner}/{name}/{branch}/tarball_url` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/helmrepos` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/helmrepos` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/helmrepos/{helm_id}/charts` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/infra` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/docr/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/doks/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/ecr/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/eks/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/gke/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/infra/{infra_id}/test/destroy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/integrations/aws` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/integrations/aws/{aws_integration_id}/overwrite` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/integrations/basic` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/integrations/gcp` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/integrations/oauth` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/invites` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/invites` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/invites/{invite_id}` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/invites/{invite_id}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/invites/{token}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/configmap` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/configmap/create` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/k8s/configmap/delete` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/configmap/list` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/configmap/rename` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/configmap/update` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/helm_releases` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/k8s/jobs/{namespace}/{name}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/jobs/{namespace}/{name}/pods` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/jobs/{namespace}/{name}/stop` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/kubeconfig` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/metrics` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/namespaces` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/namespaces/create` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/k8s/namespaces/delete` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/pods` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/k8s/pods/{namespace}/{name}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/pods/{namespace}/{name}/events/list` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/prometheus/detect` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/prometheus/ingresses` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/k8s/subdomain` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/{namespace}/ingress/{name}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/{namespace}/pod/{name}/logs` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/{kind}/status` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/{namespace}/{name}/jobs/status` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/k8s/{namespace}/{chart}/{release_name}/jobs` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/policy` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/docr` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/doks` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/ecr` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/eks` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/gcr` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/gke` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/provision/test` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/provision/{kind}/{infra_id}/logs` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/registries` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/dockerhub/token` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/docr/token` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/ecr/{region}/token` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/gcr/token` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/registries/{registry_id}` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/registries/{registry_id}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/{registry_id}/repositories` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/registries/{registry_id}/repositories/*` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/registries/{registry_id}/repository` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/releases/image/update/batch` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/history` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/releases/{name}/notifications` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/notifications` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/releases/{name}/rollback` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/releases/{name}/upgrade` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/webhook_token` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/releases/{name}/webhook_token` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/{revision}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/{revision}/components` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/{revision}/controllers` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/releases/{name}/{revision}/pods/all` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/roles` </li> | | | |
+| <li>- [ ] `POST /api/projects/{project_id}/roles/{user_id}` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/roles/{user_id}` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/slack_integrations` </li> | | | |
+| <li>- [ ] `GET /api/projects/{project_id}/slack_integrations/exists` </li> | | | |
+| <li>- [ ] `DELETE /api/projects/{project_id}/slack_integrations/{slack_integration_id}` </li> | | | |
+| <li>- [ ] `GET /api/readyz` </li> | | | |
+| <li>- [ ] `GET /api/templates` </li> | | | |
+| <li>- [ ] `GET /api/templates/upgrade_notes/{name}/{version}` </li> | | | |
+| <li>- [ ] `GET /api/templates/{name}/{version}` </li> | | | |
+| <li>- [ ] `POST /api/users` </li> | | | |
+| <li>- [ ] `GET /api/users/{user_id}` </li> | | | |
+| <li>- [ ] `DELETE /api/users/{user_id}` </li> | | | |
+| <li>- [ ] `GET /api/users/{user_id}/projects` </li> | | | |
+| <li>- [ ] `POST /api/webhooks/deploy/{token}` </li> | | | |

+ 15 - 14
internal/forms/infra.go

@@ -4,6 +4,7 @@ import (
 	"math/rand"
 	"time"
 
+	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
 )
 
@@ -18,10 +19,10 @@ type CreateTestInfra struct {
 // ToInfra converts the form to a gorm aws infra model
 func (ce *CreateTestInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:      models.InfraTest,
+		Kind:      types.InfraTest,
 		ProjectID: ce.ProjectID,
 		Suffix:    stringWithCharset(6, randCharset),
-		Status:    models.StatusCreating,
+		Status:    types.StatusCreating,
 	}, nil
 }
 
@@ -36,10 +37,10 @@ type CreateECRInfra struct {
 // ToInfra converts the form to a gorm aws infra model
 func (ce *CreateECRInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:             models.InfraECR,
+		Kind:             types.InfraECR,
 		ProjectID:        ce.ProjectID,
 		Suffix:           stringWithCharset(6, randCharset),
-		Status:           models.StatusCreating,
+		Status:           types.StatusCreating,
 		AWSIntegrationID: ce.AWSIntegrationID,
 	}, nil
 }
@@ -56,10 +57,10 @@ type CreateEKSInfra struct {
 // ToInfra converts the form to a gorm aws infra model
 func (ce *CreateEKSInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:             models.InfraEKS,
+		Kind:             types.InfraEKS,
 		ProjectID:        ce.ProjectID,
 		Suffix:           stringWithCharset(6, randCharset),
-		Status:           models.StatusCreating,
+		Status:           types.StatusCreating,
 		AWSIntegrationID: ce.AWSIntegrationID,
 	}, nil
 }
@@ -74,10 +75,10 @@ type CreateGCRInfra struct {
 // ToInfra converts the form to a gorm aws infra model
 func (ce *CreateGCRInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:             models.InfraGCR,
+		Kind:             types.InfraGCR,
 		ProjectID:        ce.ProjectID,
 		Suffix:           stringWithCharset(6, randCharset),
-		Status:           models.StatusCreating,
+		Status:           types.StatusCreating,
 		GCPIntegrationID: ce.GCPIntegrationID,
 	}, nil
 }
@@ -93,10 +94,10 @@ type CreateGKEInfra struct {
 // ToInfra converts the form to a gorm aws infra model
 func (ce *CreateGKEInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:             models.InfraGKE,
+		Kind:             types.InfraGKE,
 		ProjectID:        ce.ProjectID,
 		Suffix:           stringWithCharset(6, randCharset),
-		Status:           models.StatusCreating,
+		Status:           types.StatusCreating,
 		GCPIntegrationID: ce.GCPIntegrationID,
 	}, nil
 }
@@ -113,10 +114,10 @@ type CreateDOCRInfra struct {
 // ToInfra converts the form to a gorm infra model
 func (de *CreateDOCRInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:            models.InfraDOCR,
+		Kind:            types.InfraDOCR,
 		ProjectID:       de.ProjectID,
 		Suffix:          stringWithCharset(6, randCharset),
-		Status:          models.StatusCreating,
+		Status:          types.StatusCreating,
 		DOIntegrationID: de.DOIntegrationID,
 	}, nil
 }
@@ -133,10 +134,10 @@ type CreateDOKSInfra struct {
 // ToInfra converts the form to a gorm infra model
 func (de *CreateDOKSInfra) ToInfra() (*models.Infra, error) {
 	return &models.Infra{
-		Kind:            models.InfraDOKS,
+		Kind:            types.InfraDOKS,
 		ProjectID:       de.ProjectID,
 		Suffix:          stringWithCharset(6, randCharset),
-		Status:          models.StatusCreating,
+		Status:          types.StatusCreating,
 		DOIntegrationID: de.DOIntegrationID,
 	}, nil
 }

+ 12 - 12
internal/kubernetes/provisioner/global_stream.go

@@ -9,11 +9,11 @@ import (
 	"strings"
 
 	"github.com/aws/aws-sdk-go/service/ecr"
-	"github.com/porter-dev/porter/internal/repository"
-
-	redis "github.com/go-redis/redis/v8"
+	"github.com/go-redis/redis/v8"
 
+	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
+	"github.com/porter-dev/porter/internal/repository"
 )
 
 // GlobalStreamName is the name of the Redis stream for global operations
@@ -113,7 +113,7 @@ func GlobalStreamListener(
 					continue
 				}
 
-				infra.Status = models.StatusCreated
+				infra.Status = types.StatusCreated
 
 				infra, err = repo.Infra().UpdateInfra(infra)
 
@@ -122,7 +122,7 @@ func GlobalStreamListener(
 				}
 
 				// create ECR/EKS
-				if kind == string(models.InfraECR) {
+				if kind == string(types.InfraECR) {
 					reg := &models.Registry{
 						ProjectID:        projID,
 						AWSIntegrationID: infra.AWSIntegrationID,
@@ -163,7 +163,7 @@ func GlobalStreamListener(
 					if err != nil {
 						continue
 					}
-				} else if kind == string(models.InfraEKS) {
+				} else if kind == string(types.InfraEKS) {
 					cluster := &models.Cluster{
 						AuthMechanism:    models.AWS,
 						ProjectID:        projID,
@@ -197,7 +197,7 @@ func GlobalStreamListener(
 					if err != nil {
 						continue
 					}
-				} else if kind == string(models.InfraGCR) {
+				} else if kind == string(types.InfraGCR) {
 					reg := &models.Registry{
 						ProjectID:        projID,
 						GCPIntegrationID: infra.GCPIntegrationID,
@@ -217,7 +217,7 @@ func GlobalStreamListener(
 					if err != nil {
 						continue
 					}
-				} else if kind == string(models.InfraGKE) {
+				} else if kind == string(types.InfraGKE) {
 					cluster := &models.Cluster{
 						AuthMechanism:    models.GCP,
 						ProjectID:        projID,
@@ -251,7 +251,7 @@ func GlobalStreamListener(
 					if err != nil {
 						continue
 					}
-				} else if kind == string(models.InfraDOCR) {
+				} else if kind == string(types.InfraDOCR) {
 					reg := &models.Registry{
 						ProjectID:       projID,
 						DOIntegrationID: infra.DOIntegrationID,
@@ -270,7 +270,7 @@ func GlobalStreamListener(
 					if err != nil {
 						continue
 					}
-				} else if kind == string(models.InfraDOKS) {
+				} else if kind == string(types.InfraDOKS) {
 					cluster := &models.Cluster{
 						AuthMechanism:   models.DO,
 						ProjectID:       projID,
@@ -312,7 +312,7 @@ func GlobalStreamListener(
 					continue
 				}
 
-				infra.Status = models.StatusError
+				infra.Status = types.StatusError
 
 				infra, err = repo.Infra().UpdateInfra(infra)
 
@@ -326,7 +326,7 @@ func GlobalStreamListener(
 					continue
 				}
 
-				infra.Status = models.StatusDestroyed
+				infra.Status = types.StatusDestroyed
 
 				infra, err = repo.Infra().UpdateInfra(infra)
 

+ 6 - 44
internal/models/infra.go

@@ -6,32 +6,8 @@ import (
 	"strings"
 
 	"gorm.io/gorm"
-)
-
-// InfraStatus is the status that an infrastructure can take
-type InfraStatus string
-
-// The allowed statuses
-const (
-	StatusCreating   InfraStatus = "creating"
-	StatusCreated    InfraStatus = "created"
-	StatusError      InfraStatus = "error"
-	StatusDestroying InfraStatus = "destroying"
-	StatusDestroyed  InfraStatus = "destroyed"
-)
 
-// InfraKind is the kind that infra can be
-type InfraKind string
-
-// The supported infra kinds
-const (
-	InfraTest InfraKind = "test"
-	InfraECR  InfraKind = "ecr"
-	InfraEKS  InfraKind = "eks"
-	InfraGCR  InfraKind = "gcr"
-	InfraGKE  InfraKind = "gke"
-	InfraDOCR InfraKind = "docr"
-	InfraDOKS InfraKind = "doks"
+	"github.com/porter-dev/porter/api/types"
 )
 
 // Infra represents the metadata for an infrastructure type provisioned on
@@ -40,7 +16,7 @@ type Infra struct {
 	gorm.Model
 
 	// The type of infra that was provisioned
-	Kind InfraKind `json:"kind"`
+	Kind types.InfraKind `json:"kind"`
 
 	// A random 6-byte suffix to ensure workspace/stream ids are unique
 	Suffix string
@@ -49,7 +25,7 @@ type Infra struct {
 	ProjectID uint `json:"project_id"`
 
 	// Status is the status of the infra
-	Status InfraStatus `json:"status"`
+	Status types.InfraStatus `json:"status"`
 
 	// The AWS integration that was used to create the infra
 	AWSIntegrationID uint
@@ -69,23 +45,9 @@ type Infra struct {
 	LastApplied []byte
 }
 
-// InfraExternal is an external Infra to be shared over REST
-type InfraExternal struct {
-	ID uint `json:"id"`
-
-	// The project that this integration belongs to
-	ProjectID uint `json:"project_id"`
-
-	// The type of infra that was provisioned
-	Kind InfraKind `json:"kind"`
-
-	// Status is the status of the infra
-	Status InfraStatus `json:"status"`
-}
-
-// Externalize generates an external Infra to be shared over REST
-func (i *Infra) Externalize() *InfraExternal {
-	return &InfraExternal{
+// ToInfraType generates an external Infra to be shared over REST
+func (i *Infra) ToInfraType() *types.Infra {
+	return &types.Infra{
 		ID:        i.ID,
 		ProjectID: i.ProjectID,
 		Kind:      i.Kind,

+ 2 - 2
internal/repository/gorm/helpers_test.go

@@ -485,9 +485,9 @@ func initInfra(tester *tester, t *testing.T) {
 	}
 
 	infra := &models.Infra{
-		Kind:      models.InfraECR,
+		Kind:      types.InfraECR,
 		ProjectID: tester.initProjects[0].Model.ID,
-		Status:    models.StatusCreated,
+		Status:    types.StatusCreated,
 	}
 
 	infra, err := tester.repo.Infra().CreateInfra(infra)

+ 10 - 8
internal/repository/gorm/infra_test.go

@@ -3,9 +3,11 @@ package gorm_test
 import (
 	"testing"
 
+	"gorm.io/gorm"
+
 	"github.com/go-test/deep"
+	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
-	"gorm.io/gorm"
 )
 
 func TestCreateInfra(t *testing.T) {
@@ -18,9 +20,9 @@ func TestCreateInfra(t *testing.T) {
 	defer cleanup(tester, t)
 
 	infra := &models.Infra{
-		Kind:      models.InfraECR,
+		Kind:      types.InfraECR,
 		ProjectID: tester.initProjects[0].Model.ID,
-		Status:    models.StatusCreated,
+		Status:    types.StatusCreated,
 	}
 
 	infra, err := tester.repo.Infra().CreateInfra(infra)
@@ -40,12 +42,12 @@ func TestCreateInfra(t *testing.T) {
 		t.Errorf("incorrect registry ID: expected %d, got %d\n", 1, infra.Model.ID)
 	}
 
-	if infra.Kind != models.InfraECR {
-		t.Errorf("incorrect aws infra kind: expected %s, got %s\n", models.InfraECR, infra.Kind)
+	if infra.Kind != types.InfraECR {
+		t.Errorf("incorrect aws infra kind: expected %s, got %s\n", types.InfraECR, infra.Kind)
 	}
 
-	if infra.Status != models.StatusCreated {
-		t.Errorf("incorrect aws infra status: expected %s, got %s\n", models.StatusCreated, infra.Status)
+	if infra.Status != types.StatusCreated {
+		t.Errorf("incorrect aws infra status: expected %s, got %s\n", types.StatusCreated, infra.Status)
 	}
 }
 
@@ -75,7 +77,7 @@ func TestListInfrasByProjectID(t *testing.T) {
 	expInfra := models.Infra{
 		Kind:      "ecr",
 		ProjectID: tester.initProjects[0].Model.ID,
-		Status:    models.StatusCreated,
+		Status:    types.StatusCreated,
 	}
 
 	infra := infras[0]

+ 4 - 3
server/api/infra_handler.go

@@ -6,7 +6,8 @@ import (
 	"strconv"
 
 	"github.com/go-chi/chi"
-	"github.com/porter-dev/porter/internal/models"
+
+	"github.com/porter-dev/porter/api/types"
 )
 
 // HandleListProjectInfra returns a list of infrasa for a project
@@ -25,10 +26,10 @@ func (app *App) HandleListProjectInfra(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	extInfras := make([]*models.InfraExternal, 0)
+	extInfras := make([]*types.Infra, 0)
 
 	for _, infra := range infras {
-		extInfras = append(extInfras, infra.Externalize())
+		extInfras = append(extInfras, infra.ToInfraType())
 	}
 
 	w.WriteHeader(http.StatusOK)

+ 39 - 40
server/api/provision_handler.go

@@ -9,13 +9,12 @@ import (
 
 	"fmt"
 
+	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/internal/adapter"
 	"github.com/porter-dev/porter/internal/analytics"
 	"github.com/porter-dev/porter/internal/forms"
 	"github.com/porter-dev/porter/internal/kubernetes"
 	"github.com/porter-dev/porter/internal/kubernetes/provisioner"
-	"github.com/porter-dev/porter/internal/models"
-
-	"github.com/porter-dev/porter/internal/adapter"
 )
 
 // HandleProvisionTestInfra will create a test resource by deploying a provisioner
@@ -66,7 +65,7 @@ func (app *App) HandleProvisionTestInfra(w http.ResponseWriter, r *http.Request)
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -77,7 +76,7 @@ func (app *App) HandleProvisionTestInfra(w http.ResponseWriter, r *http.Request)
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -107,7 +106,7 @@ func (app *App) HandleDestroyTestInfra(w http.ResponseWriter, r *http.Request) {
 	agent, err := kubernetes.GetAgentInClusterConfig()
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -115,7 +114,7 @@ func (app *App) HandleDestroyTestInfra(w http.ResponseWriter, r *http.Request) {
 	}
 
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {
@@ -188,7 +187,7 @@ func (app *App) HandleProvisionAWSECRInfra(w http.ResponseWriter, r *http.Reques
 	awsInt, err := app.Repo.AWSIntegration().ReadAWSIntegration(infra.AWSIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -210,7 +209,7 @@ func (app *App) HandleProvisionAWSECRInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -221,7 +220,7 @@ func (app *App) HandleProvisionAWSECRInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -253,7 +252,7 @@ func (app *App) HandleDestroyAWSECRInfra(w http.ResponseWriter, r *http.Request)
 
 	// decode from JSON to form value
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -262,7 +261,7 @@ func (app *App) HandleDestroyAWSECRInfra(w http.ResponseWriter, r *http.Request)
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormValidation(err, ErrProjectValidateFields, w)
@@ -271,7 +270,7 @@ func (app *App) HandleDestroyAWSECRInfra(w http.ResponseWriter, r *http.Request)
 
 	// launch provisioning destruction pod
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {
@@ -347,7 +346,7 @@ func (app *App) HandleProvisionAWSEKSInfra(w http.ResponseWriter, r *http.Reques
 	awsInt, err := app.Repo.AWSIntegration().ReadAWSIntegration(infra.AWSIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -370,7 +369,7 @@ func (app *App) HandleProvisionAWSEKSInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -390,7 +389,7 @@ func (app *App) HandleProvisionAWSEKSInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -423,7 +422,7 @@ func (app *App) HandleDestroyAWSEKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// decode from JSON to form value
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -432,7 +431,7 @@ func (app *App) HandleDestroyAWSEKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormValidation(err, ErrProjectValidateFields, w)
@@ -441,7 +440,7 @@ func (app *App) HandleDestroyAWSEKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// launch provisioning destruction pod
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {
@@ -526,7 +525,7 @@ func (app *App) HandleProvisionGCPGCRInfra(w http.ResponseWriter, r *http.Reques
 	gcpInt, err := app.Repo.GCPIntegration().ReadGCPIntegration(infra.GCPIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -547,7 +546,7 @@ func (app *App) HandleProvisionGCPGCRInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -558,7 +557,7 @@ func (app *App) HandleProvisionGCPGCRInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -611,7 +610,7 @@ func (app *App) HandleProvisionGCPGKEInfra(w http.ResponseWriter, r *http.Reques
 	gcpInt, err := app.Repo.GCPIntegration().ReadGCPIntegration(infra.GCPIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -633,7 +632,7 @@ func (app *App) HandleProvisionGCPGKEInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -653,7 +652,7 @@ func (app *App) HandleProvisionGCPGKEInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -686,7 +685,7 @@ func (app *App) HandleDestroyGCPGKEInfra(w http.ResponseWriter, r *http.Request)
 
 	// decode from JSON to form value
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -695,7 +694,7 @@ func (app *App) HandleDestroyGCPGKEInfra(w http.ResponseWriter, r *http.Request)
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormValidation(err, ErrProjectValidateFields, w)
@@ -704,7 +703,7 @@ func (app *App) HandleDestroyGCPGKEInfra(w http.ResponseWriter, r *http.Request)
 
 	// launch provisioning destruction pod
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {
@@ -832,7 +831,7 @@ func (app *App) HandleProvisionDODOCRInfra(w http.ResponseWriter, r *http.Reques
 	oauthInt, err := app.Repo.OAuthIntegration().ReadOAuthIntegration(infra.DOIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -856,7 +855,7 @@ func (app *App) HandleProvisionDODOCRInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -867,7 +866,7 @@ func (app *App) HandleProvisionDODOCRInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -899,7 +898,7 @@ func (app *App) HandleDestroyDODOCRInfra(w http.ResponseWriter, r *http.Request)
 
 	// decode from JSON to form value
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -908,7 +907,7 @@ func (app *App) HandleDestroyDODOCRInfra(w http.ResponseWriter, r *http.Request)
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormValidation(err, ErrProjectValidateFields, w)
@@ -917,7 +916,7 @@ func (app *App) HandleDestroyDODOCRInfra(w http.ResponseWriter, r *http.Request)
 
 	// launch provisioning destruction pod
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {
@@ -995,7 +994,7 @@ func (app *App) HandleProvisionDODOKSInfra(w http.ResponseWriter, r *http.Reques
 	oauthInt, err := app.Repo.OAuthIntegration().ReadOAuthIntegration(infra.DOIntegrationID)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorDataRead(err, w)
@@ -1019,7 +1018,7 @@ func (app *App) HandleProvisionDODOKSInfra(w http.ResponseWriter, r *http.Reques
 	)
 
 	if err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorInternal(err, w)
@@ -1039,7 +1038,7 @@ func (app *App) HandleProvisionDODOKSInfra(w http.ResponseWriter, r *http.Reques
 
 	w.WriteHeader(http.StatusCreated)
 
-	infraExt := infra.Externalize()
+	infraExt := infra.ToInfraType()
 
 	if err := json.NewEncoder(w).Encode(infraExt); err != nil {
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -1072,7 +1071,7 @@ func (app *App) HandleDestroyDODOKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// decode from JSON to form value
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
@@ -1081,7 +1080,7 @@ func (app *App) HandleDestroyDODOKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		infra.Status = models.StatusError
+		infra.Status = types.StatusError
 		infra, _ = app.Repo.Infra().UpdateInfra(infra)
 
 		app.handleErrorFormValidation(err, ErrProjectValidateFields, w)
@@ -1090,7 +1089,7 @@ func (app *App) HandleDestroyDODOKSInfra(w http.ResponseWriter, r *http.Request)
 
 	// launch provisioning destruction pod
 	// mark infra for deletion
-	infra.Status = models.StatusDestroying
+	infra.Status = types.StatusDestroying
 	infra, err = app.Repo.Infra().UpdateInfra(infra)
 
 	if err != nil {