diff --git a/api/edge/edge.go b/api/edge/edge.go new file mode 100644 index 000000000..ee0cac38a --- /dev/null +++ b/api/edge/edge.go @@ -0,0 +1,48 @@ +package edge + +type ( + + // StackPayload represents the payload sent to the agent + StackPayload struct { + // ID of the stack + ID int + // Name of the stack + Name string + // Content of the stack file + FileContent string + // Namespace to use for kubernetes stack. Keep empty to use the manifest namespace. + Namespace string + // Version of the stack file + Version int + // Content of the .env file + DotEnvFileContent string + + // RegistryCredentials holds the credentials for a Docker registry. + // + // Used only for EE + RegistryCredentials []RegistryCredentials + // PrePullImage is a flag indicating if the agent should pull the image before deploying the stack. + // + // Used only for EE + PrePullImage bool + // RePullImage is a flag indicating if the agent should pull the image if it is already present on the node. + // + // Used only for EE + RePullImage bool + // RetryDeploy is a flag indicating if the agent should retry to deploy the stack if it fails. + // + // Used only for EE + RetryDeploy bool + // EdgeUpdateID is the ID of the edge update related to this stack. + // + // Used only for EE + EdgeUpdateID int + } + + // RegistryCredentials holds the credentials for a Docker registry. + RegistryCredentials struct { + ServerURL string + Username string + Secret string + } +) diff --git a/api/http/handler/endpointedge/endpoint_edgestack_inspect.go b/api/http/handler/endpointedge/endpoint_edgestack_inspect.go index c32970162..41b357c8e 100644 --- a/api/http/handler/endpointedge/endpoint_edgestack_inspect.go +++ b/api/http/handler/endpointedge/endpoint_edgestack_inspect.go @@ -10,19 +10,12 @@ import ( "github.com/portainer/libhttp/request" "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + "github.com/portainer/portainer/api/edge" "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 - DotEnvFileContent 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) // @description **Access policy**: public // @tags edge, endpoints, edge_stacks @@ -30,7 +23,7 @@ type configResponse struct { // @produce json // @param id path int true "environment(endpoint) Id" // @param stackId path int true "EdgeStack Id" -// @success 200 {object} configResponse +// @success 200 {object} edge.StackPayload // @failure 500 // @failure 400 // @failure 404 @@ -92,9 +85,9 @@ func (handler *Handler) endpointEdgeStackInspect(w http.ResponseWriter, r *http. } } - return response.JSON(w, configResponse{ - StackFileContent: string(stackFileContent), + return response.JSON(w, edge.StackPayload{ DotEnvFileContent: string(dotEnvFileContent), + FileContent: string(stackFileContent), Name: edgeStack.Name, Namespace: namespace, })