1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

feat(edge/stacks): use namespace in manifest [EE-4507] (#8145)

This commit is contained in:
Chaim Lev-Ari 2022-12-13 22:56:47 +02:00 committed by GitHub
parent 8936ae9b7a
commit 930d9e5628
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 47 deletions

View file

@ -10,11 +10,14 @@ import (
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/http/middlewares"
"github.com/portainer/portainer/api/internal/endpointutils"
"github.com/portainer/portainer/api/kubernetes"
)
type configResponse struct {
StackFileContent string
Name string
// Namespace to use for Kubernetes manifests, leave empty to use the namespaces defined in the manifest
Namespace string
}
// @summary Inspect an Edge Stack for an Environment(Endpoint)
@ -59,12 +62,18 @@ func (handler *Handler) endpointEdgeStackInspect(w http.ResponseWriter, r *http.
}
}
namespace := ""
if !edgeStack.UseManifestNamespaces {
namespace = kubernetes.DefaultNamespace
}
if endpointutils.IsKubernetesEndpoint(endpoint) {
fileName = edgeStack.ManifestPath
if fileName == "" {
return httperror.BadRequest("Kubernetes is not supported by this stack", errors.New("Kubernetes is not supported by this stack"))
}
}
stackFileContent, err := handler.FileService.GetFileContent(edgeStack.ProjectPath, fileName)
@ -75,5 +84,6 @@ func (handler *Handler) endpointEdgeStackInspect(w http.ResponseWriter, r *http.
return response.JSON(w, configResponse{
StackFileContent: string(stackFileContent),
Name: edgeStack.Name,
Namespace: namespace,
})
}