model

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

* @Author: link a624669980@163.com * @Date: 2022-05-16 17:37:08 * @LastEditors: LinkLeong * @LastEditTime: 2022-07-13 10:46:38 * @FilePath: /CasaOS/model/category.go * @Description:

* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-27 10:30:43 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-04 20:06:04 * @FilePath: /CasaOS/model/connections.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.com * @Date: 2022-07-13 10:43:45 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-03 14:45:35 * @FilePath: /CasaOS/model/disk.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.com * @Date: 2021-12-08 18:10:25 * @LastEditors: LinkLeong * @LastEditTime: 2022-07-13 10:49:16 * @FilePath: /CasaOS/model/docker.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-20 16:27:12 * @LastEditors: LinkLeong * @LastEditTime: 2022-06-09 18:18:46 * @FilePath: /CasaOS/model/file.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.org * @Date: 2022-07-26 11:12:12 * @LastEditors: LinkLeong * @LastEditTime: 2022-07-27 14:58:55 * @FilePath: /CasaOS/model/share.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-13 18:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-07-14 11:02:06 * @FilePath: /CasaOS/model/sys_common.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

* @Author: LinkLeong link@icewhale.org * @Date: 2022-05-13 18:15:46 * @LastEditors: LinkLeong * @LastEditTime: 2022-08-01 18:32:57 * @FilePath: /CasaOS/model/zima.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APPModel

type APPModel struct {
	LogPath        string
	LogSaveName    string
	LogFileExt     string
	DateStrFormat  string
	DateTimeFormat string
	UserDataPath   string
	TimeFormat     string
	DateFormat     string
	DBPath         string
	ShellPath      string
	TempPath       string
}

服务配置

type CasaOSGlobalVariables added in v0.2.3

type CasaOSGlobalVariables struct {
	AppChange bool
}

type CasaOSHeart added in v0.2.9

type CasaOSHeart struct {
	UuId string `json:"uuid"`
	Type string `json:"type"`
}

type CategoryList added in v0.3.3

type CategoryList struct {
	Id uint `gorm:"column:id;primary_key" json:"id"`
	//CreatedAt time.Time `json:"created_at"`
	//
	//UpdatedAt time.Time `json:"updated_at"`
	Font  string `json:"font"` // @tiger - 如果这个和前端有关,应该不属于后端的出参范围,而是前端去界定
	Name  string `json:"name"`
	Count uint   `json:"count"` // @tiger - count 属于动态信息,应该单独放在一个出参结构中(原因见另外一个关于 静态/动态 出参的注释)
}

type Connections added in v0.3.5

type Connections struct {
	ID         uint   `json:"id"`
	Username   string `json:"username"`
	Password   string `json:"password,omitempty"`
	Host       string `json:"host"`
	Port       string `json:"port"`
	MountPoint string `json:"mount_point"`
}

type CustomizationPostData

type CustomizationPostData struct {
	ContainerName string    `json:"container_name"`
	CustomId      string    `json:"custom_id"`
	Origin        string    `json:"origin"`
	NetworkModel  string    `json:"network_model"`
	Index         string    `json:"index"`
	Icon          string    `json:"icon"`
	Image         string    `json:"image"`
	Envs          EnvArray  `json:"envs"`
	Ports         PortArray `json:"ports"`
	Volumes       PathArray `json:"volumes"`
	Devices       PathArray `json:"devices"`
	//Port         string    `json:"port,omitempty"`
	PortMap     string   `json:"port_map"`
	CpuShares   int64    `json:"cpu_shares"`
	Memory      int64    `json:"memory"`
	Restart     string   `json:"restart"`
	EnableUPNP  bool     `json:"enable_upnp"`
	Label       string   `json:"label"`
	Description string   `json:"description"`
	Position    bool     `json:"position"`
	HostName    string   `json:"host_name"`
	Privileged  bool     `json:"privileged"`
	CapAdd      []string `json:"cap_add"`
	Cmd         []string `json:"cmd"`
	Protocol    string   `json:"protocol"`
	Host        string   `json:"host"`
}

type Devices

type Devices struct {
	ContainerPath string `json:"container_path"`
	Path          string `json:"path"`
	Desc          string `json:"desc"`
	Type          int    `json:"type"` //  1:必选 2:可选 3:默认值不必显示 4:系统处理 5:container内容也可编辑
}

type DockerStatsModel added in v0.2.3

type DockerStatsModel struct {
	Icon     string      `json:"icon"`
	Title    string      `json:"title"`
	Data     interface{} `json:"data"`
	Previous interface{} `json:"previous"`
}

type Drive added in v0.2.6

type Drive struct {
	Name           string `json:"name"`
	Size           uint64 `json:"size"`
	Model          string `json:"model"`
	Health         string `json:"health"`
	Temperature    int    `json:"temperature"`
	DiskType       string `json:"disk_type"`
	NeedFormat     bool   `json:"need_format"`
	Serial         string `json:"serial"`
	Path           string `json:"path"`
	ChildrenNumber int    `json:"children_number"`
}

type DriveUSB added in v0.2.8

type DriveUSB struct {
	Name     string        `json:"name"`
	Size     uint64        `json:"size"`
	Model    string        `json:"model"`
	Avail    uint64        `json:"avail"`
	Children []USBChildren `json:"children"`
}

type Env

type Env struct {
	Name  string `json:"container"`
	Value string `json:"host"`
	Desc  string `json:"desc"`
	Type  int    `json:"type"`
}

type EnvArray

type EnvArray []Env

func (*EnvArray) Scan

func (p *EnvArray) Scan(input interface{}) error

Scan 实现方法

func (EnvArray) Value

func (p EnvArray) Value() (driver.Value, error)

Value 实现方法

type Envs

type Envs struct {
	Name  string `json:"name"`
	Value string `json:"value"`
	Desc  string `json:"desc"`
	Type  int    `json:"type"` //  1:必选 2:可选 3:默认值不必显示 4:系统处理 5:container内容也可编辑
}

type FileItem added in v0.3.2

type FileItem struct {
	From          string `json:"from" binding:"required"`
	Finished      bool   `json:"finished"`
	Size          int64  `json:"size"`
	ProcessedSize int64  `json:"processed_size"`
}

type FileOperate added in v0.3.2

type FileOperate struct {
	Type          string     `json:"type" binding:"required"`
	Item          []FileItem `json:"item" binding:"required"`
	TotalSize     int64      `json:"total_size"`
	ProcessedSize int64      `json:"processed_size"`
	To            string     `json:"to" binding:"required"`
	Style         string     `json:"style"`
	Finished      bool       `json:"finished"`
}

type FileSetting added in v0.3.0

type FileSetting struct {
	ShareDir    []string `json:"share_dir" delim:"|"`
	DownloadDir string   `json:"download_dir"`
}

type FileUpdate added in v0.3.2

type FileUpdate struct {
	FilePath    string `json:"path" binding:"required"`
	FileContent string `json:"content" binding:"required"`
}

type GoDaddyModel

type GoDaddyModel struct {
	Type    uint   `json:"type"`
	ApiHost string `json:"api_host"`
	Key     string `json:"key"`
	Secret  string `json:"secret"`
	Host    string `json:"host"`
}

type IOCountersStat

type IOCountersStat struct {
	Name        string `json:"name"`        // interface name
	BytesSent   uint64 `json:"bytesSent"`   // number of bytes sent
	BytesRecv   uint64 `json:"bytesRecv"`   // number of bytes received
	PacketsSent uint64 `json:"packetsSent"` // number of packets sent
	PacketsRecv uint64 `json:"packetsRecv"` // number of packets received
	Errin       uint64 `json:"errin"`       // total number of errors while receiving
	Errout      uint64 `json:"errout"`      // total number of errors while sending
	Dropin      uint64 `json:"dropin"`      // total number of incoming packets which were dropped
	Dropout     uint64 `json:"dropout"`     // total number of outgoing packets which were dropped (always 0 on OSX and BSD)
	Fifoin      uint64 `json:"fifoin"`      // total number of FIFO buffers errors while receiving
	Fifoout     uint64 `json:"fifoout"`     // total number of FIFO buffers errors while sending
	State       string `json:"state"`
	Time        int64  `json:"time"`
}

type JSON

type JSON json.RawMessage

type LSBLKModel

type LSBLKModel struct {
	Name        string       `json:"name"`
	FsType      string       `json:"fstype"`
	Size        uint64       `json:"size"`
	FSSize      string       `json:"fssize"`
	Path        string       `json:"path"`
	Model       string       `json:"model"` //设备标识符
	RM          bool         `json:"rm"`    //是否为可移动设备
	RO          bool         `json:"ro"`    //是否为只读设备
	State       string       `json:"state"`
	PhySec      int          `json:"phy-sec"` //物理扇区大小
	Type        string       `json:"type"`
	Vendor      string       `json:"vendor"`  //供应商
	Rev         string       `json:"rev"`     //修订版本
	FSAvail     string       `json:"fsavail"` //可用空间
	FSUse       string       `json:"fsuse%"`  //已用百分比
	MountPoint  string       `json:"mountpoint"`
	Format      string       `json:"format"`
	Health      string       `json:"health"`
	HotPlug     bool         `json:"hotplug"`
	UUID        string       `json:"uuid"`
	FSUsed      string       `json:"fsused"`
	Temperature int          `json:"temperature"`
	Tran        string       `json:"tran"`
	MinIO       uint64       `json:"min-io"`
	UsedPercent float64      `json:"used_percent"`
	Serial      string       `json:"serial"`
	Children    []LSBLKModel `json:"children"`
	SubSystems  string       `json:"subsystems"`
	Label       string       `json:"label"`
	//详情特有
	StartSector uint64 `json:"start_sector,omitempty"`
	Rota        bool   `json:"rota"` //true(hhd) false(ssd)
	DiskType    string `json:"disk_type"`
	EndSector   uint64 `json:"end_sector,omitempty"`
}

type MapStrings

type MapStrings []map[string]string

***************使gorm支持[]string结构******************

func (*MapStrings) Scan

func (c *MapStrings) Scan(input interface{}) error

func (MapStrings) Value

func (c MapStrings) Value() (driver.Value, error)

type NotifyMssage added in v0.2.9

type NotifyMssage struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type Path

type Path struct {
	Name       string                 `json:"name"`   //File name or document name
	Path       string                 `json:"path"`   //Full path to file or folder
	IsDir      bool                   `json:"is_dir"` //Is it a folder
	Date       time.Time              `json:"date"`
	Size       int64                  `json:"size"` //File Size
	Type       string                 `json:"type,omitempty"`
	Label      string                 `json:"label,omitempty"`
	Write      bool                   `json:"write"`
	Extensions map[string]interface{} `json:"extensions"`
}

type PathArray

type PathArray []PathMap

func (*PathArray) Scan

func (p *PathArray) Scan(input interface{}) error

Scan 实现方法

func (PathArray) Value

func (p PathArray) Value() (driver.Value, error)

Value 实现方法

type PathMap

type PathMap struct {
	ContainerPath string `json:"container"`
	Path          string `json:"host"`
	Type          int    `json:"type"`
	Desc          string `json:"desc"`
}

type PortArray

type PortArray []PortMap

func (*PortArray) Scan

func (p *PortArray) Scan(input interface{}) error

Scan 实现方法

func (PortArray) Value

func (p PortArray) Value() (driver.Value, error)

Value 实现方法

type PortMap

type PortMap struct {
	ContainerPort string `json:"container"`
	CommendPort   string `json:"host"`
	Protocol      string `json:"protocol"`
	Desc          string `json:"desc"`
	Type          int    `json:"type"`
}

type Ports

type Ports struct {
	ContainerPort uint   `json:"container_port"`
	CommendPort   int    `json:"commend_port"`
	Desc          string `json:"desc"`
	Type          int    `json:"type"` //  1:必选 2:可选 3:默认值不必显示 4:系统处理  5:container内容也可编辑
}

type RedisModel

type RedisModel struct {
	Host        string
	Password    string
	MaxIdle     int
	MaxActive   int
	IdleTimeout time.Duration
}

redis配置文件

type Result

type Result struct {
	Success int         `json:"success" example:"200"`
	Message string      `json:"message" example:"ok"`
	Data    interface{} `json:"data" example:"返回结果"`
}

公共返回模型

type SearchFileInfo

type SearchFileInfo struct {
	Path string `json:"path"`
	Name string `json:"name"`
	Type int    `json:"type"`
}

type ServerAppList

type ServerAppList struct {
	Id             uint      `gorm:"column:id;primary_key" json:"id"`
	Title          string    `json:"title"`
	Description    string    `json:"description"`
	Tagline        string    `json:"tagline"`
	Tags           Strings   `gorm:"type:json" json:"tags"`
	Icon           string    `json:"icon"`
	ScreenshotLink Strings   `gorm:"type:json" json:"screenshot_link"`
	Category       string    `json:"category"`
	CategoryId     int       `json:"category_id"`
	CategoryFont   string    `json:"category_font"`
	PortMap        string    `json:"port_map"`
	ImageVersion   string    `json:"image_version"`
	Tip            string    `json:"tip"`
	Envs           EnvArray  `json:"envs"`
	Ports          PortArray `json:"ports"`
	Volumes        PathArray `json:"volumes"`
	Devices        PathArray `json:"devices"`
	NetworkModel   string    `json:"network_model"`
	Image          string    `json:"image"`
	Index          string    `json:"index"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	State          int       `json:"state"`
	Author         string    `json:"author"`
	MinMemory      int       `json:"min_memory"`
	MinDisk        int       `json:"min_disk"`
	MaxMemory      uint64    `json:"max_memory"`
	Thumbnail      string    `json:"thumbnail"`
	Healthy        string    `json:"healthy"`
	Plugins        Strings   `json:"plugins"`
	Origin         string    `json:"origin"`
	Type           int       `json:"type"`
	QueryCount     int       `json:"query_count"`
	Developer      string    `json:"developer"`
	HostName       string    `json:"host_name"`
	Privileged     bool      `json:"privileged"`
	CapAdd         Strings   `json:"cap_add"`
	Cmd            Strings   `json:"cmd"`
}

@tiger - 对于用于出参的数据结构,静态信息(例如 title)和

动态信息(例如 state、query_count)应该划分到不同的数据结构中

这样的好处是
1 - 多次获取动态信息时可以减少出参复杂度,因为静态信息只获取一次就好
2 - 在未来的迭代中,可以降低维护成本(所有字段都展开放在一个层级维护成本略高)

另外,一些针对性字段,例如 Docker 相关的,可以用 map 来保存。
这样在未来增加多态 App,例如 Snap,不需要维护多个结构,或者一个结构保存不必要的字段

type ServerAppListCollection added in v0.3.3

type ServerAppListCollection struct {
	List      []ServerAppList `json:"list"`
	Recommend []ServerAppList `json:"recommend"`
	Community []ServerAppList `json:"community"`
	Version   string          `json:"version"`
}

type ServerCategoryList

type ServerCategoryList struct {
	Version string         `json:"version"`
	Item    []CategoryList `json:"item"`
}

type ServerModel

type ServerModel struct {
	HttpPort     string
	RunMode      string
	ServerApi    string
	LockAccount  bool
	Token        string
	USBAutoMount string
	SocketPort   string
}

服务配置

type Shares added in v0.3.5

type Shares struct {
	ID        uint   `json:"id"`
	Anonymous bool   `json:"anonymous"`
	Path      string `json:"path"`
}

type SmartctlA added in v0.2.6

type SmartctlA struct {
	Smartctl struct {
		Version      []int    `json:"version"`
		SvnRevision  string   `json:"svn_revision"`
		PlatformInfo string   `json:"platform_info"`
		BuildInfo    string   `json:"build_info"`
		Argv         []string `json:"argv"`
		ExitStatus   int      `json:"exit_status"`
	} `json:"smartctl"`
	Device struct {
		Name     string `json:"name"`
		InfoName string `json:"info_name"`
		Type     string `json:"type"`
		Protocol string `json:"protocol"`
	} `json:"device"`
	ModelName       string `json:"model_name"`
	SerialNumber    string `json:"serial_number"`
	FirmwareVersion string `json:"firmware_version"`
	UserCapacity    struct {
		Blocks int   `json:"blocks"`
		Bytes  int64 `json:"bytes"`
	} `json:"user_capacity"`
	SmartStatus struct {
		Passed bool `json:"passed"`
	} `json:"smart_status"`
	AtaSmartData struct {
		OfflineDataCollection struct {
			Status struct {
				Value  int    `json:"value"`
				String string `json:"string"`
			} `json:"status"`
			CompletionSeconds int `json:"completion_seconds"`
		} `json:"offline_data_collection"`
		SelfTest struct {
			Status struct {
				Value  int    `json:"value"`
				String string `json:"string"`
				Passed bool   `json:"passed"`
			} `json:"status"`
			PollingMinutes struct {
				Short      int `json:"short"`
				Extended   int `json:"extended"`
				Conveyance int `json:"conveyance"`
			} `json:"polling_minutes"`
		} `json:"self_test"`
		Capabilities struct {
			Values                        []int `json:"values"`
			ExecOfflineImmediateSupported bool  `json:"exec_offline_immediate_supported"`
			OfflineIsAbortedUponNewCmd    bool  `json:"offline_is_aborted_upon_new_cmd"`
			OfflineSurfaceScanSupported   bool  `json:"offline_surface_scan_supported"`
			SelfTestsSupported            bool  `json:"self_tests_supported"`
			ConveyanceSelfTestSupported   bool  `json:"conveyance_self_test_supported"`
			SelectiveSelfTestSupported    bool  `json:"selective_self_test_supported"`
			AttributeAutosaveEnabled      bool  `json:"attribute_autosave_enabled"`
			ErrorLoggingSupported         bool  `json:"error_logging_supported"`
			GpLoggingSupported            bool  `json:"gp_logging_supported"`
		} `json:"capabilities"`
	} `json:"ata_smart_data"`
	PowerOnTime struct {
		Hours int `json:"hours"`
	} `json:"power_on_time"`
	PowerCycleCount int `json:"power_cycle_count"`
	Temperature     struct {
		Current int `json:"current"`
	} `json:"temperature"`
}

type Storage added in v0.2.6

type Storage struct {
	MountPoint string `json:"mount_point"`
	Size       string `json:"size"`
	Avail      string `json:"avail"` //可用空间
	Type       string `json:"type"`
	Path       string `json:"path"`
	DriveName  string `json:"drive_name"`
	Label      string `json:"label"`
}

type Storages added in v0.3.5

type Storages struct {
	DiskName string    `json:"disk_name"`
	Size     uint64    `json:"size"`
	Path     string    `json:"path"`
	Children []Storage `json:"children"`
}

type Strings

type Strings []string

***************使gorm支持[]string结构******************

func (*Strings) Scan

func (c *Strings) Scan(input interface{}) error

func (Strings) Value

func (c Strings) Value() (driver.Value, error)

type Summary added in v0.2.6

type Summary struct {
	Size   uint64 `json:"size"`
	Avail  uint64 `json:"avail"` //可用空间
	Health bool   `json:"health"`
	Used   uint64 `json:"used"`
}

type SysInfoModel

type SysInfoModel struct {
	Name string //系统名称
}

系统配置

type SystemConfig

type SystemConfig struct {
	ConfigPath string `json:"config_path"`
}

type TcpPorts

type TcpPorts struct {
	Desc          string `json:"desc"`
	ContainerPort int    `json:"container_port"`
}

type USBChildren added in v0.3.5

type USBChildren struct {
	Name       string `json:"name"`
	Size       uint64 `json:"size"`
	Avail      uint64 `json:"avail"`
	MountPoint string `json:"mount_point"`
}

type UdpPorts

type UdpPorts struct {
	Desc          string `json:"desc"`
	ContainerPort int    `json:"container_port"`
}

type UserInfo added in v0.3.0

type UserInfo struct {
	NickName string `json:"nick_name"`
	Desc     string `json:"desc"`
	ShareId  string `json:"share_id"`
	Avatar   string `json:"avatar"`
	Version  int    `json:"version,omitempty"`
}

type UserModel

type UserModel struct {
	UserName    string
	PWD         string
	Token       string
	Head        string
	Email       string
	Description string
	Initialized bool
	Avatar      string
	NickName    string
	Public      string
}

用户相关

type Version

type Version struct {
	Id        uint      `gorm:"column:id;primary_key" json:"id"`
	ChangeLog string    `json:"change_log"`
	Version   string    `json:"version"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Volume

type Volume struct {
	ContainerPath string `json:"container_path"`
	Path          string `json:"path"`
	Desc          string `json:"desc"`
	Type          int    `json:"type"` //  1:必选 2:可选 3:默认值不必显示 4:系统处理   5:container内容也可编辑
}

Directories

Path Synopsis
* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-27 15:01:58 * @LastEditors: LinkLeong * @LastEditTime: 2022-05-31 14:51:21 * @FilePath: /CasaOS/model/notify/application.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.com * @Date: 2022-05-27 15:01:58 * @LastEditors: LinkLeong * @LastEditTime: 2022-05-31 14:51:21 * @FilePath: /CasaOS/model/notify/application.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.com * @Date: 2022-06-15 11:30:47 * @LastEditors: LinkLeong * @LastEditTime: 2022-06-23 18:40:40 * @FilePath: /CasaOS/model/system_model/verify_information.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.
* @Author: LinkLeong link@icewhale.com * @Date: 2022-06-15 11:30:47 * @LastEditors: LinkLeong * @LastEditTime: 2022-06-23 18:40:40 * @FilePath: /CasaOS/model/system_model/verify_information.go * @Description: * @Website: https://www.casaos.io * Copyright (c) 2022 by icewhale, All Rights Reserved.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL