scope.go 777 B

1234567891011121314151617181920212223242526272829
  1. package config
  2. import "fmt"
  3. // Scope determines which config file is targeted for read/write operations.
  4. type Scope int
  5. const (
  6. // ScopeGlobal targets the global data config (~/.local/share/crush/crush.json).
  7. ScopeGlobal Scope = iota
  8. // ScopeWorkspace targets the workspace config (.crush/crush.json).
  9. ScopeWorkspace
  10. )
  11. // String returns a human-readable label for the scope.
  12. func (s Scope) String() string {
  13. switch s {
  14. case ScopeGlobal:
  15. return "global"
  16. case ScopeWorkspace:
  17. return "workspace"
  18. default:
  19. return fmt.Sprintf("Scope(%d)", int(s))
  20. }
  21. }
  22. // ErrNoWorkspaceConfig is returned when a workspace-scoped write is
  23. // attempted on a ConfigStore that has no workspace config path.
  24. var ErrNoWorkspaceConfig = fmt.Errorf("no workspace config path configured")