mirror of https://github.com/portainer/portainer
fix(edge-stack): transmit dot env file to agent [EE-4533] (#8664)
parent
c90a1be0e5
commit
4f04fe54a7
|
@ -3,6 +3,8 @@ package endpointedge
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
httperror "github.com/portainer/libhttp/error"
|
httperror "github.com/portainer/libhttp/error"
|
||||||
"github.com/portainer/libhttp/request"
|
"github.com/portainer/libhttp/request"
|
||||||
|
@ -14,8 +16,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type configResponse struct {
|
type configResponse struct {
|
||||||
StackFileContent string
|
StackFileContent string
|
||||||
Name string
|
DotEnvFileContent string
|
||||||
|
Name string
|
||||||
// Namespace to use for Kubernetes manifests, leave empty to use the namespaces defined in the manifest
|
// Namespace to use for Kubernetes manifests, leave empty to use the namespaces defined in the manifest
|
||||||
Namespace string
|
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)
|
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{
|
return response.JSON(w, configResponse{
|
||||||
StackFileContent: string(stackFileContent),
|
StackFileContent: string(stackFileContent),
|
||||||
Name: edgeStack.Name,
|
DotEnvFileContent: string(dotEnvFileContent),
|
||||||
Namespace: namespace,
|
Name: edgeStack.Name,
|
||||||
|
Namespace: namespace,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue