config

package
v0.0.0-...-af25eba Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CleanupDueDays 代表每次自動執行 cleanup 的間隔天數
	CleanupDueDays = 30
	// CheckUpdatesDueDays 代表每次自動執行檢查版本的間隔天數
	CheckUpdatesDueDays = 15
)

Variables

View Source
var ErrTokenNotExist = errors.New(`token not exist.
You might need to run 'slctl init'`)

ErrTokenNotExist 代表了 GitHub Token 在不存在於 config 中

Functions

func Refresh

func Refresh(home paths.Home, token string, _ *logrus.Logger) (err error)

Refresh 將傳入的 token 寫回檔案中

Types

type ConfFile

type ConfFile struct {
	Token        string    `json:"token"`        // github token
	Cleanup      time.Time `json:"cleanup"`      // 下次要執行 cleanup 的時間
	CheckUpdates time.Time `json:"checkUpdates"` // 下次要執行檢查版本的時間
}

ConfFile 內容等於 $SL_HOME/config/configs.yaml

func LoadConfFile

func LoadConfFile(path string) (*ConfFile, error)

LoadConfFile return a pointer of a ConfFile which read from path

func NewConfFile

func NewConfFile() (c *ConfFile)

NewConfFile return a pointer of a blank ConfFile

func (*ConfFile) UpdateCheckUpdatesTime

func (c *ConfFile) UpdateCheckUpdatesTime()

UpdateCheckUpdatesTime updates check updates time

func (*ConfFile) UpdateCheckUpdatesTimeInDays

func (c *ConfFile) UpdateCheckUpdatesTimeInDays(days int)

UpdateCheckUpdatesTimeInDays updates check updates time

func (*ConfFile) UpdateCleanupTime

func (c *ConfFile) UpdateCleanupTime()

UpdateCleanupTime updates cleanup time

func (*ConfFile) WriteFile

func (c *ConfFile) WriteFile(path string, perm os.FileMode) error

WriteFile 將當前的 ConfFile 內容寫入 path

Jump to

Keyboard shortcuts

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