Repository navigation
Expand file tree
/
Copy pathconstants.go
More file actions
190 lines (161 loc) · 5.64 KB
/
Copy pathconstants.go
File metadata and controls
190 lines (161 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package appdir
// Rule: no bare strings for closed sets. Every kind, scope, rule, profile and
// warning code that appears in a switch, a map key or JSON output is one of the
// typed constants below.
// Kind names one entry in a home's layout: a file or a folder.
type Kind string
// Standard kinds, used when the tool's author changes nothing (SPEC 5.1).
const (
KindHome Kind = "home" // home.jsonc: app, layout, scope
KindConfig Kind = "config" // config.jsonc: settings, committed
KindConfigLocal Kind = "config-local" // config.local.jsonc: this machine only
KindGitignore Kind = "gitignore" // .gitignore: written between markers
KindShared Kind = "shared" // shared/: team-shared files, committed
KindDB Kind = "db" // <app>.db
KindBackups Kind = "backups" // backups/
KindCache Kind = "cache" // cache/: safe to delete
KindRun Kind = "run" // run/: lock, pid, socket, discovery
KindLogs Kind = "logs" // logs/
)
// Scope says which home a kind lives in.
type Scope string
// Scopes. ScopeGlobal and ScopeProject also name the two homes in results.
const (
ScopeGlobal Scope = "global"
ScopeProject Scope = "project"
ScopeProjectElseGlobal Scope = "project-else-global"
ScopeBoth Scope = "both" // one copy per home (config files, home.jsonc)
)
// Mode is the kind of tool: it sets the default scope of data kinds.
type Mode string
// Modes. ModeProject is the default because it fails safe (SPEC 5.2).
const (
ModeProject Mode = "project"
ModeGlobal Mode = "global"
)
// Lookup is the project lookup style.
type Lookup string
// Lookup styles.
const (
WalkUp Lookup = "walk-up"
HereOnly Lookup = "here-only"
)
// EntryType says whether a kind is a file or a folder.
type EntryType string
// Entry types.
const (
TypeFile EntryType = "file"
TypeFolder EntryType = "folder"
)
// GitRule says whether a kind is committed.
type GitRule string
// Git rules.
const (
GitCommit GitRule = "commit"
GitIgnore GitRule = "ignore"
)
// Rule names the resolution rule that picked a path, for paths --json and
// doctor.
type Rule string
// Rules.
const (
RuleFlag Rule = "flag" // --home (WithHome)
RuleEnvHome Rule = "env-home" // <APP>_HOME
RuleEnvKind Rule = "env-kind" // <APP>_<KIND>_DIR
RuleProject Rule = "project" // found by lookup
RuleWorktree Rule = "worktree" // main checkout of a linked worktree
RulePointer Rule = "pointer" // home: or db: key
RuleGlobal Rule = "global" // ~/.<app>
RuleTemp Rule = "temp" // <tmp>/<app>-<uid>/
RuleDefaults Rule = "defaults" // no $HOME: global config is code defaults
)
// Profile names a set of homes (prod, dev, or an author-added name).
type Profile string
// Default profiles.
const (
ProfileProd Profile = "prod"
ProfileDev Profile = "dev"
)
// DBAccess is the result of the prod-db guard.
type DBAccess int
// DB access levels.
const (
AccessReadWrite DBAccess = iota
AccessReadOnly // dev build on the prod db with <APP>_ALLOW_PROD=1: never migrate
)
// String implements fmt.Stringer.
func (a DBAccess) String() string {
if a == AccessReadOnly {
return "read-only"
}
return "read-write"
}
// RunFile names a file in run/.
type RunFile string
// Run files (SPEC 7).
const (
RunLock RunFile = "lock" // run/lock: migrations, layout changes
RunDaemonLock RunFile = "daemon-lock" // run/daemon.lock: held for a daemon's life
RunPID RunFile = "pid" // run/<app>.pid: display only
RunDiscovery RunFile = "discovery" // run/discovery.json
RunSocket RunFile = "socket" // run/<app>.sock
RunSocketFile RunFile = "socket-file" // run/socket: path of a fallback socket
)
// MoveStatus is the outcome of MoveLegacy.
type MoveStatus string
// Move outcomes.
const (
MoveNone MoveStatus = "none"
MoveDone MoveStatus = "moved"
MoveBothExist MoveStatus = "both-exist"
MoveSkipped MoveStatus = "skipped"
MoveAlready MoveStatus = "already"
)
// WarningCode identifies a warning.
type WarningCode string
// Warning codes.
const (
WarnProfileEnvIgnored WarningCode = "profile-env-ignored"
WarnEnvPointsToProd WarningCode = "env-points-to-prod"
WarnPointerChain WarningCode = "pointer-chain-ignored"
WarnPointerProfile WarningCode = "pointer-ignored-for-profile"
WarnCeilingRelative WarningCode = "ceiling-relative"
// WarnCeilingDropped: an <APP>_CEILING_DIRS entry that is not relative
// but does not expand to an absolute path ($VAR without braces, an unset
// ${VAR}, ~user); it is ignored, and without this warning a ceiling would
// silently have no effect (finding D5).
WarnCeilingDropped WarningCode = "ceiling-dropped"
WarnWorktreeMainMissing WarningCode = "worktree-main-missing"
)
// Env suffixes under <APP>_ (SPEC 5.3: reserved names).
const (
envHome = "HOME"
envProfile = "PROFILE"
envAllowProd = "ALLOW_PROD"
envCeilingDirs = "CEILING_DIRS"
envDaemonProfile = "DAEMON_PROFILE"
envKindSuffix = "_DIR"
envTestRoot = "APPDIR_TEST_ROOT"
)
// Fixed names inside a home.
const (
profilesDir = "profiles"
movedFile = "MOVED.txt"
legacyMarkerFile = ".legacy-move"
cacheTagFile = "CACHEDIR.TAG"
gitEntry = ".git"
pointerKeyHome = "home"
pointerKeyDB = "db"
homeKeyApp = "app"
homeKeyLayout = "layout"
homeKeyScope = "scope"
)
// Defaults (rule zero: each has an option).
// ds:def id=default-constants-kpphgn26 owner=@khanakia stability=stable
const (
defaultLayoutVersion = 1
defaultSocketMaxLen = 100
defaultDirPerm = 0o700
defaultFilePerm = 0o600
socketHashLen = 12
)