fix(edge-stack): transmit dot env file to agent [EE-4533] (#8664)

pull/9048/head
cmeng 2023-06-06 09:39:08 +12:00 committed by GitHub
parent c90a1be0e5
commit 4f04fe54a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 5 deletions

View File

@ -3,6 +3,8 @@ package endpointedge
import (
"errors"
"net/http"
"os"
"path"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
@ -14,8 +16,9 @@ import (
)
type configResponse struct {
StackFileContent string
Name string
StackFileContent string
DotEnvFileContent string
Name string
// Namespace to use for Kubernetes manifests, leave empty to use the namespaces defined in the manifest
Namespace string
}
@ -81,9 +84,18 @@ func (handler *Handler) endpointEdgeStackInspect(w http.ResponseWriter, r *http.
return httperror.InternalServerError("Unable to retrieve Compose file from disk", err)
}
var dotEnvFileContent []byte
if _, err = os.Stat(path.Join(edgeStack.ProjectPath, ".env")); err == nil {
dotEnvFileContent, err = handler.FileService.GetFileContent(edgeStack.ProjectPath, ".env")
if err != nil {
return httperror.InternalServerError("Unable to retrieve .env file from disk", err)
}
}
return response.JSON(w, configResponse{
StackFileContent: string(stackFileContent),
Name: edgeStack.Name,
Namespace: namespace,
StackFileContent: string(stackFileContent),
DotEnvFileContent: string(dotEnvFileContent),
Name: edgeStack.Name,
Namespace: namespace,
})
}