2022-09-26 08:32:40 +00:00
|
|
|
package model
|
|
|
|
|
2022-09-29 10:16:56 +00:00
|
|
|
import (
|
|
|
|
"path"
|
2023-04-08 06:02:14 +00:00
|
|
|
"strings"
|
2023-03-02 05:54:07 +00:00
|
|
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
2022-09-29 10:16:56 +00:00
|
|
|
)
|
|
|
|
|
2022-09-26 08:32:40 +00:00
|
|
|
type AppInstall struct {
|
|
|
|
BaseModel
|
2023-03-02 05:54:07 +00:00
|
|
|
Name string `json:"name" gorm:"type:varchar(64);not null;UNIQUE"`
|
|
|
|
AppId uint `json:"appId" gorm:"type:integer;not null"`
|
|
|
|
AppDetailId uint `json:"appDetailId" gorm:"type:integer;not null"`
|
|
|
|
Version string `json:"version" gorm:"type:varchar(64);not null"`
|
|
|
|
Param string `json:"param" gorm:"type:longtext;"`
|
|
|
|
Env string `json:"env" gorm:"type:longtext;"`
|
|
|
|
DockerCompose string `json:"dockerCompose" gorm:"type:longtext;"`
|
|
|
|
Status string `json:"status" gorm:"type:varchar(256);not null"`
|
|
|
|
Description string `json:"description" gorm:"type:varchar(256);"`
|
|
|
|
Message string `json:"message" gorm:"type:longtext;"`
|
|
|
|
ContainerName string `json:"containerName" gorm:"type:varchar(256);not null"`
|
|
|
|
ServiceName string `json:"serviceName" gorm:"type:varchar(256);not null"`
|
|
|
|
HttpPort int `json:"httpPort" gorm:"type:integer;not null"`
|
|
|
|
HttpsPort int `json:"httpsPort" gorm:"type:integer;not null"`
|
|
|
|
App App `json:"app" gorm:"-:migration"`
|
2022-09-29 10:16:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-07 07:49:39 +00:00
|
|
|
func (i *AppInstall) GetPath() string {
|
2023-11-10 07:06:07 +00:00
|
|
|
return path.Join(i.GetAppPath(), i.Name)
|
2022-09-29 10:16:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-07 07:49:39 +00:00
|
|
|
func (i *AppInstall) GetComposePath() string {
|
2023-11-10 07:06:07 +00:00
|
|
|
return path.Join(i.GetAppPath(), i.Name, "docker-compose.yml")
|
2022-09-26 08:32:40 +00:00
|
|
|
}
|
2023-04-07 08:46:11 +00:00
|
|
|
|
|
|
|
func (i *AppInstall) GetEnvPath() string {
|
2023-11-10 07:06:07 +00:00
|
|
|
return path.Join(i.GetAppPath(), i.Name, ".env")
|
2023-04-08 06:02:14 +00:00
|
|
|
}
|
|
|
|
|
2023-11-10 07:06:07 +00:00
|
|
|
func (i *AppInstall) GetAppPath() string {
|
2023-04-08 06:02:14 +00:00
|
|
|
if i.App.Resource == constant.AppResourceLocal {
|
|
|
|
return path.Join(constant.LocalAppInstallDir, strings.TrimPrefix(i.App.Key, constant.AppResourceLocal))
|
|
|
|
} else {
|
|
|
|
return path.Join(constant.AppInstallDir, i.App.Key)
|
|
|
|
}
|
2023-04-07 08:46:11 +00:00
|
|
|
}
|