git-project-manager/internal/config/config.go

81 lines
2.6 KiB
Go

package config
import "time"
type Config struct {
// Named keys above maintained for backwards compatibility
// Ideally only Gitlabs is used
GitlabHost string `yaml:"gitlabHost,omitempty" json:"gitlabHost,omitempty"`
GitlabToken string `yaml:"gitlabToken,omitempty" json:"gitlabToken,omitempty"`
Gitlabs []GitlabConfig `yaml:"gitlabs" json:"gitlabs"`
Giteas []GiteaConfig `yaml:"giteas" json:"giteas"`
LogLevel string `yaml:"logLevel" json:"logLevel" enum:"info,warn,debug,error"`
ProjectPath string `yaml:"projectPath" json:"projectPath"`
Cache cacheConfig `yaml:"cache" json:"cache"`
Dump struct {
Full bool `yaml:"full" json:"full"`
} `yaml:"dump" json:"dump"`
Editor editorConfig `yaml:"editor" json:"editor"`
}
type GiteaConfig struct {
Host string `yaml:"host" json:"host"`
Name string `yaml:"name" json:"name"`
Token string `yaml:"token" json:"token"`
CloneProto CloneProto `yaml:"cloneProto" json:"cloneProto"`
}
type GitlabConfig struct {
Host string `yaml:"host" json:"host"`
Name string `yaml:"name" json:"name"`
Token string `yaml:"token" json:"token"`
CloneProto CloneProto `yaml:"cloneProto" json:"cloneProto"`
}
type CloneProto string
const (
CloneProtoSSH CloneProto = "ssh"
CloneProtoHTTP CloneProto = "http"
)
type editorConfig struct {
DisplayName string `yaml:"displanName,omitempty" json:"displanName,omitempty"`
Binary string `yaml:"binary,omitempty" json:"binary,omitempty"`
OpenFlags string `yaml:"openFlags,omitempty" json:"openFlags,omitempty"`
OpenDirectory bool `yaml:"openDirectory" json:"openDirectory" description:"Don't open well-known files, open directory"`
}
type loadConfig struct {
OwnerOnly bool `yaml:"ownerOnly" json:"ownerOnly"`
}
type cacheConfig struct {
Ttl time.Duration `yaml:"ttl,omitempty" json:"ttl,omitempty"`
File string `yaml:"file,omitempty" json:"file,omitempty"`
Load loadConfig `yaml:"load" json:"load"`
Unlock struct {
Force bool `yaml:"force" json:"force"`
} `yaml:"unlock" json:"unlock"`
Clear struct {
ClearAliases bool `yaml:"clearAliases,omitempty" json:"clearAliases,omitempty"`
} `yaml:"clear,omitempty" json:"clear,omitempty"`
}
var DefaultConfig = Config{
LogLevel: "warn",
ProjectPath: "~/work/projects",
Gitlabs: []GitlabConfig{{
Host: "https://gitlab.com",
Token: "yourtokenhere",
CloneProto: CloneProtoSSH,
Name: "GitLab",
}},
Cache: cacheConfig{
Ttl: 168 * time.Hour,
Load: loadConfig{
OwnerOnly: true,
},
},
}