hash
stringlengths 40
40
| date
stringdate 2019-01-29 11:49:07
2025-03-22 03:23:55
| author
stringclasses 79
values | commit_message
stringlengths 14
85
| is_merge
bool 1
class | git_diff
stringlengths 210
1.63M
| type
stringclasses 8
values | masked_commit_message
stringlengths 8
79
|
|---|---|---|---|---|---|---|---|
c758a1c57fb6084631736a7dda5ac0aaeeffa946
|
2024-04-27 01:21:18
|
Tom Payne
|
fix: Apply .chezmoiignore to dirs in external archives
| false
|
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index 343086e22e2..0e2b905b99c 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -2310,6 +2310,9 @@ func (s *SourceState) readExternalArchive(
targetRelPath := externalRelPath.JoinString(name)
if s.Ignore(targetRelPath) {
+ if fileInfo.IsDir() {
+ return fs.SkipDir
+ }
return nil
}
diff --git a/internal/cmd/applycmd_test.go b/internal/cmd/applycmd_test.go
index c65be9c0497..bf06101192b 100644
--- a/internal/cmd/applycmd_test.go
+++ b/internal/cmd/applycmd_test.go
@@ -235,6 +235,27 @@ func TestIssue2132(t *testing.T) {
})
}
+func TestIssue2597(t *testing.T) {
+ chezmoitest.WithTestFS(t, map[string]any{
+ "/home/user": map[string]any{
+ ".local/share/chezmoi": map[string]any{
+ ".chezmoiexternal.toml": chezmoitest.JoinLines(
+ `[".oh-my-zsh"]`,
+ ` type = "archive"`,
+ ` url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"`,
+ ` exact = true`,
+ ` stripComponents = 1`,
+ ),
+ ".chezmoiignore": chezmoitest.JoinLines(
+ `.oh-my-zsh/cache`,
+ ),
+ },
+ },
+ }, func(fileSystem vfs.FS) {
+ assert.NoError(t, newTestConfig(t, fileSystem).execute([]string{"apply"}))
+ })
+}
+
func TestIssue3206(t *testing.T) {
chezmoitest.WithTestFS(t, map[string]any{
"/home/user": map[string]any{
diff --git a/internal/cmd/testdata/scripts/issue2597.txtar b/internal/cmd/testdata/scripts/issue2597.txtar
new file mode 100644
index 00000000000..c89ba35c276
--- /dev/null
+++ b/internal/cmd/testdata/scripts/issue2597.txtar
@@ -0,0 +1,20 @@
+exec tar czf www/master.tar.gz master
+
+httpd www
+
+exec chezmoi apply
+exists $HOME/.oh-my-zsh/README.md
+! exists $HOME/.oh-my-zsh/cache/.gitkeep
+
+-- home/user/.local/share/chezmoi/.chezmoiexternal.toml.tmpl --
+[".oh-my-zsh"]
+ type = "archive"
+ url = "{{ env "HTTPD_URL" }}/master.tar.gz"
+ exact = true
+ stripComponents = 1
+-- home/user/.local/share/chezmoi/.chezmoiignore --
+.oh-my-zsh/cache
+-- master/README.md --
+# contents of README.md
+-- master/cache/.gitkeep --
+-- www/.keep --
|
fix
|
Apply .chezmoiignore to dirs in external archives
|
57484ed340a4d5b713a68d5a89833309e6daf15f
|
2024-10-23 04:31:13
|
Tom Payne
|
chore: Update tools
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index edfcdd0defc..56498d48c22 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -24,7 +24,7 @@ env:
GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases
PYTHON_VERSION: '3.10' # https://www.python.org/downloads/
RAGE_VERSION: 0.10.0 # https://github.com/str4d/rage/releases
- UV_VERSION: 0.4.24 # https://github.com/astral-sh/uv/releases
+ UV_VERSION: 0.4.25 # https://github.com/astral-sh/uv/releases
jobs:
changes:
runs-on: ubuntu-22.04
|
chore
|
Update tools
|
f300d3d294183d09ce4adef35dc7a49ad359a588
|
2022-09-12 22:54:21
|
Tom Payne
|
chore: Remove old bug workaround
| false
|
diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go
index e832d8401be..dea9f5d7d4d 100644
--- a/pkg/chezmoi/sourcestate.go
+++ b/pkg/chezmoi/sourcestate.go
@@ -619,60 +619,6 @@ func (s *SourceState) Apply(
return err
}
- // Mitigate a bug in chezmoi before version 2.0.10 in a user-friendly
- // way.
- //
- // chezmoi before version 2.0.10 incorrectly stored the last written
- // entry state permissions, due to buggy umask handling. This caused
- // chezmoi apply to raise a false positive that a file or directory had
- // been modified since chezmoi last wrote it, since the permissions did
- // not match. Further compounding the problem, the diff presented to the
- // user was empty as the target state matched the actual state.
- //
- // The mitigation consists of several parts. First, detect that the bug
- // as precisely as possible by detecting where the the target state,
- // actual state, and last written entry state permissions match when the
- // umask is considered.
- //
- // If this is the case, then patch the last written entry state as if
- // the permissions were correctly stored.
- //
- // Finally, try to update the last written entry state in the persistent
- // state so we don't hit this path the next time the user runs chezmoi
- // apply. We ignore any errors because the persistent state might be in
- // read-only or dry-run mode.
- //
- // FIXME remove this mitigation in a later version of chezmoi
- switch {
- case lastWrittenEntryState == nil:
- case lastWrittenEntryState.Type == EntryStateTypeFile:
- if targetStateFile, ok := targetStateEntry.(*TargetStateFile); ok {
- if actualStateFile, ok := actualStateEntry.(*ActualStateFile); ok {
- if actualStateFile.perm.Perm() == targetStateFile.perm.Perm() {
- if targetStateFile.perm.Perm() != lastWrittenEntryState.Mode.Perm() {
- if targetStateFile.perm.Perm() == lastWrittenEntryState.Mode.Perm()&^s.umask {
- lastWrittenEntryState.Mode = targetStateFile.perm
- _ = persistentStateSet(persistentState, EntryStateBucket, targetAbsPath.Bytes(), lastWrittenEntryState)
- }
- }
- }
- }
- }
- case lastWrittenEntryState.Type == EntryStateTypeDir:
- if targetStateDir, ok := targetStateEntry.(*TargetStateDir); ok {
- if actualStateDir, ok := actualStateEntry.(*ActualStateDir); ok {
- if actualStateDir.perm.Perm() == targetStateDir.perm.Perm() {
- if targetStateDir.perm.Perm() != lastWrittenEntryState.Mode.Perm() {
- if targetStateDir.perm.Perm() == lastWrittenEntryState.Mode.Perm()&^s.umask {
- lastWrittenEntryState.Mode = fs.ModeDir | targetStateDir.perm
- _ = persistentStateSet(persistentState, EntryStateBucket, targetAbsPath.Bytes(), lastWrittenEntryState)
- }
- }
- }
- }
- }
- }
-
// If the target entry state matches the actual entry state, but not the
// last written entry state then silently update the last written entry
// state. This handles the case where the user makes identical edits to
|
chore
|
Remove old bug workaround
|
c9d1f008ede0f0394a9e664dcf814d6f1f0986af
|
2025-02-21 07:13:27
|
Tom Payne
|
chore: Update GitHub Actions
| false
|
diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml
index 5aa5db8ba9b..5d18bd55a98 100644
--- a/.github/actions/setup-go/action.yml
+++ b/.github/actions/setup-go/action.yml
@@ -30,7 +30,7 @@ runs:
echo "GOCACHE=/home/runner/go/pkg/mod" >> $GITHUB_ENV
echo "GOMODCACHE=/home/runner/.cache/go-build" >> $GITHUB_ENV
fi
- - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
+ - uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f
if: ${{ inputs.upload-cache == 'true' }}
with:
path: |
@@ -39,7 +39,7 @@ runs:
key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ runner.arch }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ inputs.cache-prefix }}-${{ runner.os }}-${{ runner.arch }}-go-${{ inputs.go-version }}-
- - uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
+ - uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f
if: ${{ inputs.upload-cache != 'true' }}
with:
path: |
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index dee91db3b90..fb366836e23 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -70,10 +70,10 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
upload-cache: false
- - uses: github/codeql-action/init@08bc0cf022445eacafaa248bf48da20f26b8fd40
+ - uses: github/codeql-action/init@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8
with:
languages: go
- - uses: github/codeql-action/analyze@08bc0cf022445eacafaa248bf48da20f26b8fd40
+ - uses: github/codeql-action/analyze@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8
misspell:
runs-on: ubuntu-22.04
permissions:
@@ -92,7 +92,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
+ - uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f
with:
path: |
~/.go-alpine
@@ -113,7 +113,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
+ - uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f
with:
path: |
~/.go-archlinux
@@ -498,7 +498,7 @@ jobs:
with:
cache-prefix: release-go
go-version: ${{ env.GO_VERSION }}
- - uses: sigstore/cosign-installer@c56c2d3e59e4281cc41dea2217323ba5694b171e
+ - uses: sigstore/cosign-installer@d7d6bc7722e3daa8354c50bcb52f4837da5e9b6a
- name: create-syso
run: |
make create-syso
|
chore
|
Update GitHub Actions
|
797e3cf0f2dd603f5b4c52930ffd513ade8e1012
|
2023-10-29 20:02:12
|
Tom Payne
|
fix: Make stdinIsATTY return false if --no-tty is passed
| false
|
diff --git a/internal/cmd/inittemplatefuncs.go b/internal/cmd/inittemplatefuncs.go
index 757965ecc53..89c45d36f92 100644
--- a/internal/cmd/inittemplatefuncs.go
+++ b/internal/cmd/inittemplatefuncs.go
@@ -13,6 +13,9 @@ func (c *Config) exitInitTemplateFunc(code int) string {
}
func (c *Config) stdinIsATTYInitTemplateFunc() bool {
+ if c.noTTY {
+ return false
+ }
file, ok := c.stdin.(*os.File)
if !ok {
return false
|
fix
|
Make stdinIsATTY return false if --no-tty is passed
|
1fbe862dbc974566da755df3ea12bc18b4e7c8f9
|
2022-09-24 01:46:52
|
Tom Payne
|
fix: Preserve case in user template data
| false
|
diff --git a/.golangci.yml b/.golangci.yml
index 0b7d3b63e6c..05c78bc9d2b 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -113,18 +113,19 @@ linters-settings:
- anon
- empty
- error
- - github.com/charmbracelet/bubbletea\.Model
- - github.com/charmbracelet/bubbletea\.Msg
- - github.com/go-git/go-git/v5/plumbing/format/diff\.File
- - github.com/go-git/go-git/v5/plumbing/format/diff\.Patch
- - github.com/mitchellh/mapstructure\.DecodeHookFunc
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.ActualStateEntry
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.Encryption
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateOrigin
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateEntry
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.System
- - github.com/twpayne/chezmoi/v2/pkg/chezmoi\.TargetStateEntry
- - github.com/twpayne/go-vfs/v4\.FS
+ - github\.com/charmbracelet/bubbletea\.Model
+ - github\.com/charmbracelet/bubbletea\.Msg
+ - github\.com/go-git/go-git/v5/plumbing/format/diff\.File
+ - github\.com/go-git/go-git/v5/plumbing/format/diff\.Patch
+ - github\.com/mitchellh/mapstructure\.DecodeHookFunc
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.ActualStateEntry
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.Encryption
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.Format
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateOrigin
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateEntry
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.System
+ - github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.TargetStateEntry
+ - github\.com/twpayne/go-vfs/v4\.FS
- stdlib
misspell:
locale: US
diff --git a/assets/chezmoi.io/docs/reference/templates/variables.md b/assets/chezmoi.io/docs/reference/templates/variables.md
index 3a93eb9acb0..f1ba9ae9fb2 100644
--- a/assets/chezmoi.io/docs/reference/templates/variables.md
+++ b/assets/chezmoi.io/docs/reference/templates/variables.md
@@ -45,8 +45,3 @@ NT\CurrentVersion`.
Additional variables can be defined in the config file in the `data` section.
Variable names must consist of a letter and be followed by zero or more letters
and/or digits.
-
-!!! hint
-
- Until [#463](https://github.com/twpayne/chezmoi/issues/463) is resolved, custom
- data fields from the `data` section appear as all lowercase strings.
diff --git a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md
index b0a197ee31f..92e659e2cfd 100644
--- a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md
+++ b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/design.md
@@ -191,13 +191,6 @@ but must meet the following criteria, in order of importance:
4. Not add significant extra complexity to the user interface or underlying
implementation.
-## Why does chezmoi convert all my template variables to lowercase?
-
-This is due to a feature in
-[`github.com/spf13/viper`](https://github.com/spf13/viper), the library that
-chezmoi uses to read its configuration file. For more information see [this
-GitHub issue](https://github.com/twpayne/chezmoi/issues/463).
-
## Why does `chezmoi cd` spawn a shell instead of just changing directory?
`chezmoi cd` spawns a shell because it is not possible for a program to change
diff --git a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md
index 5a060150bbe..10e9373d2cd 100644
--- a/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md
+++ b/assets/chezmoi.io/docs/user-guide/manage-machine-to-machine-differences.md
@@ -33,19 +33,12 @@ machine to machine. For example, for your home machine:
email = "[email protected]"
```
-!!! note
-
- All variable names will be converted to lowercase. This is due to a feature
- of a library used by chezmoi. See [this GitHub
- issue](https://github.com/twpayne/chezmoi/issues/463) for more information.
-
If you intend to store private data (e.g. access tokens) in
`~/.config/chezmoi/chezmoi.toml`, make sure it has permissions `0600`.
-If you prefer, you can use any format supported by
-[Viper](https://github.com/spf13/viper) for your configuration file. This
-includes JSON, YAML, and TOML. Variable names must start with a letter and be
-followed by zero or more letters or digits.
+If you prefer, you can use JSON or YAML for your configuration file. Variable
+names must start with a letter and be followed by zero or more letters or
+digits.
Then, add `~/.gitconfig` to chezmoi using the `--autotemplate` flag to turn it
into a template and automatically detect variables from the `data` section of
diff --git a/go.mod b/go.mod
index 25ae95835bd..d584fe2c845 100644
--- a/go.mod
+++ b/go.mod
@@ -27,9 +27,8 @@ require (
github.com/rogpeppe/go-internal v1.9.0
github.com/rs/zerolog v1.28.0
github.com/sergi/go-diff v1.1.0
- github.com/spf13/afero v1.9.2
github.com/spf13/cobra v1.5.0
- github.com/spf13/viper v1.13.0
+ github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
github.com/twpayne/go-pinentry v0.2.0
github.com/twpayne/go-shell v0.3.1
@@ -89,14 +88,12 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
- github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
- github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
@@ -109,7 +106,6 @@ require (
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
- github.com/pelletier/go-toml v1.9.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect
github.com/pkg/errors v0.9.1 // indirect
@@ -117,9 +113,6 @@ require (
github.com/rivo/uniseg v0.4.2 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
- github.com/spf13/jwalterweatherman v1.1.0 // indirect
- github.com/spf13/pflag v1.0.5 // indirect
- github.com/subosito/gotenv v1.4.1 // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/yuin/goldmark v1.4.15 // indirect
github.com/yuin/goldmark-emoji v1.0.1 // indirect
@@ -130,7 +123,6 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
- gopkg.in/yaml.v2 v2.4.0 // indirect
)
exclude github.com/sergi/go-diff v1.2.0 // https://github.com/sergi/go-diff/issues/123
diff --git a/go.sum b/go.sum
index 81fb64563aa..82a6855f371 100644
--- a/go.sum
+++ b/go.sum
@@ -1,56 +1,7 @@
-cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
-cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
-cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
-cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
-cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
-cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
-cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
-cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
-cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
-cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
-cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
-cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
-cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
-cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
-cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
-cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
-cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY=
-cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y=
-cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
-cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
-cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
-cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
-cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
-cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=
-cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/compute v1.7.0 h1:v/k9Eueb8aAJ0vZuxKMrgm6kPhCLZU9HxFU+AFDs9Uk=
-cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
-cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=
-cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
-cloud.google.com/go/firestore v1.6.1 h1:8rBq3zRjnHx8UtBvaOWqBB1xq9jH6/wltfQLlTMh2Fw=
-cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
-cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
-cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
-cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=
-cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
-cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
-cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
-cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
-cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
-cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
-cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU=
-cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
-dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=
-dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/age v1.0.0 h1:V6q14n0mqYU3qKFkZ6oOaF9oXneOviS3ubXsSVBRSzc=
filippo.io/age v1.0.0/go.mod h1:PaX+Si/Sd5G8LgfCwldsSba3H1DDQZhIhFGkhbHaBq8=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
-github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
-github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
-github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
@@ -72,7 +23,6 @@ github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVK
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
-github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
@@ -116,8 +66,6 @@ github.com/bradenhilton/mozillainstallhash v1.0.0/go.mod h1:yVD0OX1izZHYl1lBm2UD
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bwesterb/go-ristretto v1.2.1 h1:Xd9ZXmjKE2aY8Ub7+4bX7tXsIPsV1pIZaUlJUjI1toE=
github.com/bwesterb/go-ristretto v1.2.1/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
-github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
-github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/charmbracelet/bubbles v0.14.0 h1:DJfCwnARfWjZLvMglhSQzo76UZ2gucuHPy9jLWX45Og=
github.com/charmbracelet/bubbles v0.14.0/go.mod h1:bbeTiXwPww4M031aGi8UK2HT9RDWoiNibae+1yCMtcc=
github.com/charmbracelet/bubbletea v0.21.0/go.mod h1:GgmJMec61d08zXsOhqRC/AiOx4K4pmz+VIcRIm1FKr4=
@@ -130,21 +78,9 @@ github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJ
github.com/charmbracelet/lipgloss v0.5.0/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs=
github.com/charmbracelet/lipgloss v0.6.0 h1:1StyZB9vBSOyuZxQUcUwGr17JmojPNm87inij9N3wJY=
github.com/charmbracelet/lipgloss v0.6.0/go.mod h1:tHh2wr34xcHjC2HCXIlGSG1jaDF0S0atAUvBMP6Ppuk=
-github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
-github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
-github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
-github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
-github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
-github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
-github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
-github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.2.0 h1:NheeISPSUcYftKlfrLuOo4T62FkmD4t4jviLfFFYaec=
github.com/cloudflare/circl v1.2.0/go.mod h1:Ch2UgYr6ti2KTtlejELlROl0YIYj7SLjAC8M+INXlMk=
-github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
-github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
-github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
-github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
@@ -167,15 +103,6 @@ github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnm
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
-github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
-github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
-github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
-github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
-github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad h1:EmNYJhPYy0pOFjCx2PrgtaBXmee0iUX9hLlxE1xHOJE=
-github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
-github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
-github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
-github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
@@ -192,62 +119,21 @@ github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2Su
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
-github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
-github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
-github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
-github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
-github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
-github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
-github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
-github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
-github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
-github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
-github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
-github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
-github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
-github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
-github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
-github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
-github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
-github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
-github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
-github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
-github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
-github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
@@ -259,56 +145,19 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gops v0.3.25 h1:Pf6uw+cO6pDhc7HJ71NiG0x8dyQTeQcmg3HQFF39qVw=
github.com/google/gops v0.3.25/go.mod h1:8A7ebAm0id9K3H0uOggeRVGxszSvnlURun9mg3GdYDw=
-github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
-github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
-github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
-github.com/google/martian/v3 v3.1.0 h1:wCKgOCHuUEVfsaQLpPSJb7VdYCdTVZQAuOdYm1yc/60=
-github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
-github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
-github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
-github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
-github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2 h1:LR89qFljJ48s990kEKGsk213yIJDPI4205OKOzbURK8=
-github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
-github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
-github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
-github.com/googleapis/gax-go/v2 v2.4.0 h1:dS9eYAjhrE2RjmzYw2XAPvcXfmcQLtFEQWn0CR82awk=
-github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 h1:tlyzajkF3030q6M8SvmJSemC9DTHL/xaMa18b65+JM4=
-github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
-github.com/hashicorp/consul/api v1.12.0 h1:k3y1FYv6nuKyNTqj6w9gXOx5r5CfLj/k/euUeBXj1OY=
-github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
-github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM=
-github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
-github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
-github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
-github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
-github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
-github.com/hashicorp/serf v0.9.7 h1:hkdgbqizGQHuU5IPqYM1JdSMV8nKfpuOnZYXssk9muY=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
-github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
-github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=
-github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
@@ -325,21 +174,13 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
-github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
-github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
-github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
-github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 h1:WjT3fLi9n8YWh/Ih8Q1LHAPsTqGddPcHqscN+PJ3i68=
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19/go.mod h1:hY+WOq6m2FpbvyrI93sMaypsttvaIL5nhVR92dTMUcQ=
-github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
-github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
-github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -354,8 +195,6 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
-github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
-github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -386,8 +225,6 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
-github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
-github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 h1:kMlmsLSbjkikxQJ1IPwaM+7LJ9ltFu/fi8CRzvSnQmA=
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
@@ -408,8 +245,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
-github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
-github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
@@ -419,19 +254,14 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pkg/sftp v1.13.1 h1:I2qBYMChEhIjOgazfJmV3/mZM256btk6wkCDRmW7JYs=
-github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
-github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=
-github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8=
github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
-github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=
@@ -440,7 +270,6 @@ github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/sagikazarmark/crypt v0.6.0 h1:REOEXCs/NFY/1jOCEouMuT4zEniE5YoXbvpC5X/TLF8=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
@@ -453,19 +282,13 @@ github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
-github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
-github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
-github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
-github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
-github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU=
-github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
@@ -478,8 +301,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
-github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
@@ -503,9 +324,6 @@ github.com/xanzy/ssh-agent v0.3.2 h1:eKj4SX2Fe7mui28ZgnFW5fmTz1EIr7ugo5s6wDxdHBM
github.com/xanzy/ssh-agent v0.3.2/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
-github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.4/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
github.com/yuin/goldmark v1.4.15 h1:CFa84T0goNn/UIXYS+dmjjVxMyTAvpOmzld40N/nfK0=
@@ -518,178 +336,50 @@ github.com/zalando/go-keyring v0.2.1 h1:MBRN/Z8H4U5wEKXiD67YbDAr5cj/DOStmSga70/2
github.com/zalando/go-keyring v0.2.1/go.mod h1:g63M2PPn0w5vjmEbwAX3ib5I+41zdm4esSETOn9Y6Dw=
go.etcd.io/bbolt v1.3.7-0.20220226045046-fd5535f71f48 h1:edJBWeGHJkzwvJ8ReW0h50BRw6ikNVtrzhqtbseIAL8=
go.etcd.io/bbolt v1.3.7-0.20220226045046-fd5535f71f48/go.mod h1:sh/Yp01MYDakY7RVfzKZn+T1WOMTTFJrWjl7+M73RXA=
-go.etcd.io/etcd/api/v3 v3.5.4 h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc=
-go.etcd.io/etcd/client/pkg/v3 v3.5.4 h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7HqOg=
-go.etcd.io/etcd/client/v2 v2.305.4 h1:Dcx3/MYyfKcPNLpR4VVQUP5KgYrBeJtktBwEKkw08Ao=
-go.etcd.io/etcd/client/v3 v3.5.4 h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4=
-go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
-go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
-go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
-go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
-go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 h1:a5Yg6ylndHHYJqIPrdq0AhvR6KTvDTAvgBtaidhEevY=
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
-golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
-golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
-golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
-golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
-golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
-golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220921164117-439092de6870 h1:j8b6j9gzSigH28O5SjSpQSSh9lFd6f5D/q0aHjNTulc=
golang.org/x/exp v0.0.0-20220921164117-439092de6870/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
-golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
-golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
-golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
-golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
-golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
-golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
-golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
-golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI=
-golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
-golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
-golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=
-golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
-golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
-golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
-golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
-golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220921203646-d300de134e69 h1:hUJpGDpnfwdJW8iNypFjmSY0sCBEL+spFTZ2eO+Sfps=
golang.org/x/net v0.0.0-20220921203646-d300de134e69/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
-golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
-golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
-golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
-golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
-golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 h1:lxqLZaMad/dJHMFZH0NiNpiEZI/nhgWhe4wgzpE+MuA=
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
-golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -711,176 +401,28 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220919170432-7a66f970e087 h1:tPwmk4vmvVCMdr98VgL4JH+qZxPL8fqlUOHnyOM8N3w=
golang.org/x/term v0.0.0-20220919170432-7a66f970e087/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
-golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
-golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
-golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
-golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
-golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
-golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
-golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618=
-google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
-google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
-google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
-google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
-google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
-google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
-google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
-google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
-google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
-google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
-google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
-google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
-google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
-google.golang.org/api v0.81.0 h1:o8WF5AvfidafWbFjsRyupxyEQJNUWxLZJCK5NXrxZZ8=
-google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
-google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
-google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
-google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
-google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
-google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
-google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
-google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
-google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
-google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
-google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
-google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
-google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
-google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I=
-google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
-google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
-google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
-google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
-google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
-google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
-google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
-google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
-google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
-google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
-google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
-google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
-google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
-google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
-google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
-google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
-google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
-google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
-google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
-google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
-google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
-google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
-gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
@@ -898,24 +440,10 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
-honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
-honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
mvdan.cc/editorconfig v0.2.0 h1:XL+7ys6ls/RKrkUNFQvEwIvNHh+JKx8Mj1pUV5wQxQE=
mvdan.cc/sh/v3 v3.5.1 h1:hmP3UOw4f+EYexsJjFxvU38+kn+V/s2CclXHanIBkmQ=
mvdan.cc/sh/v3 v3.5.1/go.mod h1:1JcoyAKm1lZw/2bZje/iYKWicU/KMd0rsyJeKHnsK4E=
-rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
-rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/goversion v1.2.0 h1:SPn+NLTiAG7w30IRK/DKp1BjvpWabYgxlLp/+kx5J8w=
rsc.io/goversion v1.2.0/go.mod h1:Eih9y/uIBS3ulggl7KNJ09xGSLcuNaLgmvvqa07sgfo=
-rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=
-rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
-rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
-rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/pkg/chezmoi/chezmoi.go b/pkg/chezmoi/chezmoi.go
index e44c8ff0b65..e42349bfc81 100644
--- a/pkg/chezmoi/chezmoi.go
+++ b/pkg/chezmoi/chezmoi.go
@@ -17,6 +17,9 @@ import (
"github.com/spf13/cobra"
vfs "github.com/twpayne/go-vfs/v4"
+ "golang.org/x/exp/constraints"
+ "golang.org/x/exp/maps"
+ "golang.org/x/exp/slices"
)
var (
@@ -318,6 +321,13 @@ func mustTrimSuffix(s, suffix string) string {
return s[:len(s)-len(suffix)]
}
+// sortedKeys returns the keys of V in order.
+func sortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
+ keys := maps.Keys(m)
+ slices.Sort(keys)
+ return keys
+}
+
// ensureSuffix adds suffix to s if s is not suffixed by suffix.
func ensureSuffix(s, suffix string) string {
if strings.HasSuffix(s, suffix) {
diff --git a/pkg/chezmoi/chezmoi_test.go b/pkg/chezmoi/chezmoi_test.go
index 763a0cf3999..b3a0218fe40 100644
--- a/pkg/chezmoi/chezmoi_test.go
+++ b/pkg/chezmoi/chezmoi_test.go
@@ -10,9 +10,6 @@ import (
"github.com/rs/zerolog/pkgerrors"
"github.com/stretchr/testify/assert"
"github.com/twpayne/go-vfs/v4"
- "golang.org/x/exp/constraints"
- "golang.org/x/exp/maps"
- "golang.org/x/exp/slices"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
)
@@ -176,9 +173,3 @@ func TestUniqueAbbreviations(t *testing.T) {
})
}
}
-
-func sortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
- keys := maps.Keys(m)
- slices.Sort(keys)
- return keys
-}
diff --git a/pkg/chezmoi/format.go b/pkg/chezmoi/format.go
index 5b872c40f1f..f4cb2ee96f1 100644
--- a/pkg/chezmoi/format.go
+++ b/pkg/chezmoi/format.go
@@ -4,6 +4,7 @@ import (
"bytes"
"compress/gzip"
"encoding/json"
+ "fmt"
"io"
"strings"
@@ -38,12 +39,24 @@ type formatTOML struct{}
// A formatYAML implements the YAML serialization format.
type formatYAML struct{}
-// Formats is a map of all Formats by name.
-var Formats = map[string]Format{
- "json": FormatJSON,
- "toml": FormatTOML,
- "yaml": FormatYAML,
-}
+var (
+ // FormatsByName is a map of all FormatsByName by name.
+ FormatsByName = map[string]Format{
+ "json": FormatJSON,
+ "toml": FormatTOML,
+ "yaml": FormatYAML,
+ }
+
+ // Formats is a map of all Formats by extension.
+ FormatsByExtension = map[string]Format{
+ "json": FormatJSON,
+ "toml": FormatTOML,
+ "yaml": FormatYAML,
+ "yml": FormatYAML,
+ }
+
+ FormatExtensions = sortedKeys(FormatsByExtension)
+)
// Marshal implements Format.Marshal.
func (formatGzippedJSON) Marshal(value any) ([]byte, error) {
@@ -132,9 +145,27 @@ func (formatYAML) Unmarshal(data []byte, value any) error {
return yaml.Unmarshal(data, value)
}
+// FormatFromAbsPath returns the expected format of absPath.
+func FormatFromAbsPath(absPath AbsPath) (Format, error) {
+ format, err := formatFromExtension(absPath.Ext())
+ if err != nil {
+ return nil, fmt.Errorf("%s: %w", absPath, err)
+ }
+ return format, nil
+}
+
+// formatFromExtension returns the expected format of absPath.
+func formatFromExtension(extension string) (Format, error) {
+ format, ok := FormatsByExtension[strings.TrimPrefix(extension, ".")]
+ if !ok {
+ return nil, fmt.Errorf("%s: unknown format", extension)
+ }
+ return format, nil
+}
+
func isPrefixDotFormat(name, prefix string) bool {
- for _, format := range Formats {
- if name == prefix+"."+format.Name() {
+ for extension := range FormatsByExtension {
+ if name == prefix+"."+extension {
return true
}
}
diff --git a/pkg/chezmoi/format_test.go b/pkg/chezmoi/format_test.go
index 73e97b0d5dc..26a26087429 100644
--- a/pkg/chezmoi/format_test.go
+++ b/pkg/chezmoi/format_test.go
@@ -8,9 +8,10 @@ import (
)
func TestFormats(t *testing.T) {
- assert.Contains(t, Formats, "json")
- assert.Contains(t, Formats, "toml")
- assert.Contains(t, Formats, "yaml")
+ assert.Contains(t, FormatsByName, "json")
+ assert.Contains(t, FormatsByName, "toml")
+ assert.Contains(t, FormatsByName, "yaml")
+ assert.NotContains(t, FormatsByName, "yml")
}
func TestFormatRoundTrip(t *testing.T) {
diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go
index 21b15d22abb..e3d6f767ddd 100644
--- a/pkg/chezmoi/sourcestate.go
+++ b/pkg/chezmoi/sourcestate.go
@@ -1133,9 +1133,9 @@ func (s *SourceState) addExternal(sourceAbsPath AbsPath) error {
parentSourceRelPath := NewSourceRelDirPath(parentRelPath.String())
parentTargetSourceRelPath := parentSourceRelPath.TargetRelPath(s.encryption.EncryptedSuffix())
- format, ok := Formats[strings.TrimPrefix(sourceAbsPath.Ext(), ".")]
- if !ok {
- return fmt.Errorf("%s: unknown format", sourceAbsPath)
+ format, err := FormatFromAbsPath(sourceAbsPath)
+ if err != nil {
+ return err
}
data, err := s.executeTemplate(sourceAbsPath)
if err != nil {
@@ -1201,9 +1201,9 @@ func (s *SourceState) addPatterns(patternSet *patternSet, sourceAbsPath AbsPath,
// addTemplateData adds all template data in sourceAbsPath to s.
func (s *SourceState) addTemplateData(sourceAbsPath AbsPath) error {
- format, ok := Formats[strings.TrimPrefix(sourceAbsPath.Ext(), ".")]
- if !ok {
- return fmt.Errorf("%s: unknown format", sourceAbsPath)
+ format, err := FormatFromAbsPath(sourceAbsPath)
+ if err != nil {
+ return err
}
data, err := s.system.ReadFile(sourceAbsPath)
if err != nil {
@@ -1621,12 +1621,12 @@ func (s *SourceState) newSourceStateFile(
case SourceFileTypeModify:
// If the target has an extension, determine if it indicates an
// interpreter to use.
- ext := strings.ToLower(strings.TrimPrefix(targetRelPath.Ext(), "."))
- interpreter := s.interpreters[ext]
+ extension := strings.ToLower(strings.TrimPrefix(targetRelPath.Ext(), "."))
+ interpreter := s.interpreters[extension]
if interpreter != nil {
// For modify scripts, the script extension is not considered part
// of the target name, so remove it.
- targetRelPath = targetRelPath.Slice(0, targetRelPath.Len()-len(ext)-1)
+ targetRelPath = targetRelPath.Slice(0, targetRelPath.Len()-len(extension)-1)
}
targetStateEntryFunc = s.newModifyTargetStateEntryFunc(sourceRelPath, fileAttr, sourceLazyContents, interpreter)
case SourceFileTypeRemove:
@@ -1634,8 +1634,8 @@ func (s *SourceState) newSourceStateFile(
case SourceFileTypeScript:
// If the script has an extension, determine if it indicates an
// interpreter to use.
- ext := strings.ToLower(strings.TrimPrefix(targetRelPath.Ext(), "."))
- interpreter := s.interpreters[ext]
+ extension := strings.ToLower(strings.TrimPrefix(targetRelPath.Ext(), "."))
+ interpreter := s.interpreters[extension]
targetStateEntryFunc = s.newScriptTargetStateEntryFunc(
sourceRelPath, fileAttr, targetRelPath, sourceLazyContents, interpreter,
)
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index 47629624ab8..640d452fbf9 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -36,9 +36,8 @@ import (
"github.com/muesli/termenv"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
- "github.com/spf13/afero"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
+ "github.com/spf13/pflag"
"github.com/twpayne/go-shell"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-xdg/v6"
@@ -223,18 +222,6 @@ var (
}
whitespaceRx = regexp.MustCompile(`\s+`)
-
- viperDecodeConfigOptions = []viper.DecoderConfigOption{
- viper.DecodeHook(
- mapstructure.ComposeDecodeHookFunc(
- mapstructure.StringToTimeDurationHookFunc(),
- mapstructure.StringToSliceHookFunc(","),
- chezmoi.StringSliceToEntryTypeSetHookFunc(),
- chezmoi.StringToAbsPathHookFunc(),
- StringOrBoolToAutoBoolHookFunc(),
- ),
- ),
- }
)
// newConfig creates a new Config with the given options.
@@ -253,113 +240,14 @@ func newConfig(options ...configOption) (*Config, error) {
return nil, err
}
- cacheDirAbsPath := chezmoi.NewAbsPath(bds.CacheHome).Join(chezmoiRelPath)
-
- configFile := ConfigFile{
- // Global configuration.
- CacheDirAbsPath: cacheDirAbsPath,
- Color: autoBool{
- auto: true,
- },
- Interpreters: defaultInterpreters,
- Pager: os.Getenv("PAGER"),
- PINEntry: pinEntryConfig{
- Options: pinEntryDefaultOptions,
- },
- Safe: true,
- Template: templateConfig{
- Options: chezmoi.DefaultTemplateOptions,
- },
- Umask: chezmoi.Umask,
- UseBuiltinAge: autoBool{
- auto: true,
- },
- UseBuiltinGit: autoBool{
- auto: true,
- },
-
- // Password manager configurations.
- Bitwarden: bitwardenConfig{
- Command: "bw",
- },
- Gopass: gopassConfig{
- Command: "gopass",
- },
- Keepassxc: keepassxcConfig{
- Command: "keepassxc-cli",
- },
- Keeper: keeperConfig{
- Command: "keeper",
- },
- Lastpass: lastpassConfig{
- Command: "lpass",
- },
- Onepassword: onepasswordConfig{
- Command: "op",
- Prompt: true,
- },
- Pass: passConfig{
- Command: "pass",
- },
- Passhole: passholeConfig{
- Command: "ph",
- Prompt: true,
- },
- Vault: vaultConfig{
- Command: "vault",
- },
-
- // Encryption configurations.
- Age: defaultAgeEncryptionConfig,
- GPG: defaultGPGEncryptionConfig,
-
- // Command configurations.
- Add: addCmdConfig{
- exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
- recursive: true,
- },
- Diff: diffCmdConfig{
- Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
- },
- Edit: editCmdConfig{
- Hardlink: true,
- MinDuration: 1 * time.Second,
- exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(
- chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted,
- ),
- },
- Format: defaultWriteDataFormat,
- Git: gitCmdConfig{
- Command: "git",
- },
- Merge: mergeCmdConfig{
- Command: "vimdiff",
- },
- Status: statusCmdConfig{
- Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
- recursive: true,
- },
- Verify: verifyCmdConfig{
- Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll &^ chezmoi.EntryTypeScripts),
- recursive: true,
- },
- }
-
c := &Config{
- ConfigFile: configFile,
+ ConfigFile: newConfigFile(bds),
// Global configuration.
homeDir: userHomeDir,
templateFuncs: sprig.TxtFuncMap(),
- // Password manager data.
-
- // Command configurations, not settable in the config file.
+ // Command configurations.
apply: applyCmdConfig{
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
@@ -555,12 +443,12 @@ func (c *Config) applyArgs(
}
var currentConfigTemplateContentsSHA256 []byte
- configTemplateRelPath, _, configTemplateContents, err := c.findFirstConfigTemplate()
+ configTemplate, err := c.findFirstConfigTemplate()
if err != nil {
return err
}
- if configTemplateRelPath != chezmoi.EmptyRelPath {
- currentConfigTemplateContentsSHA256 = chezmoi.SHA256Sum(configTemplateContents)
+ if configTemplate != nil {
+ currentConfigTemplateContentsSHA256 = chezmoi.SHA256Sum(configTemplate.contents)
}
var previousConfigTemplateContentsSHA256 []byte
if configStateData, err := c.persistentState.Get(chezmoi.ConfigStateBucket, configStateKey); err != nil {
@@ -577,7 +465,7 @@ func (c *Config) applyArgs(
bytes.Equal(currentConfigTemplateContentsSHA256, previousConfigTemplateContentsSHA256)
if !configTemplateContentsUnchanged {
if c.force {
- if configTemplateRelPath == chezmoi.EmptyRelPath {
+ if configTemplate == nil {
if err := c.persistentState.Delete(chezmoi.ConfigStateBucket, configStateKey); err != nil {
return err
}
@@ -710,66 +598,57 @@ func (c *Config) colorAutoFunc() bool {
// template and reloads it.
func (c *Config) createAndReloadConfigFile() error {
// Find config template, execute it, and create config file.
- configTemplateRelPath, ext, configTemplateContents, err := c.findFirstConfigTemplate()
+ configTemplate, err := c.findFirstConfigTemplate()
if err != nil {
return err
}
- var configFileContents []byte
- if configTemplateRelPath == chezmoi.EmptyRelPath {
+
+ if configTemplate == nil {
if err := c.persistentState.Delete(chezmoi.ConfigStateBucket, configStateKey); err != nil {
return err
}
- } else {
- configFileContents, err = c.createConfigFile(configTemplateRelPath, configTemplateContents)
- if err != nil {
- return err
- }
+ return nil
+ }
- // Validate the config.
- v := viper.New()
- v.SetConfigType(ext)
- if err := v.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
- return err
- }
- if err := v.Unmarshal(&Config{}, viperDecodeConfigOptions...); err != nil {
- return err
- }
+ configFileContents, err := c.createConfigFile(configTemplate.targetRelPath, configTemplate.contents)
+ if err != nil {
+ return err
+ }
- // Write the config.
- configPath := c.init.configPath
- if c.init.configPath.Empty() {
- configPath = chezmoi.NewAbsPath(c.bds.ConfigHome).Join(chezmoiRelPath, configTemplateRelPath)
- }
- if err := chezmoi.MkdirAll(c.baseSystem, configPath.Dir(), 0o777); err != nil {
- return err
- }
- if err := c.baseSystem.WriteFile(configPath, configFileContents, 0o600); err != nil {
- return err
- }
+ // Validate the configMap.
+ var configFile ConfigFile
+ if err := c.decodeConfigBytes(configTemplate.format, configFileContents, &configFile); err != nil {
+ return fmt.Errorf("%s: %w", configTemplate.sourceAbsPath, err)
+ }
- configStateValue, err := json.Marshal(configState{
- ConfigTemplateContentsSHA256: chezmoi.HexBytes(chezmoi.SHA256Sum(configTemplateContents)),
- })
- if err != nil {
- return err
- }
- if err := c.persistentState.Set(chezmoi.ConfigStateBucket, configStateKey, configStateValue); err != nil {
- return err
- }
+ // Write the config.
+ configPath := c.init.configPath
+ if c.init.configPath.Empty() {
+ configPath = chezmoi.NewAbsPath(c.bds.ConfigHome).Join(chezmoiRelPath, configTemplate.targetRelPath)
+ }
+ if err := chezmoi.MkdirAll(c.baseSystem, configPath.Dir(), 0o777); err != nil {
+ return err
+ }
+ if err := c.baseSystem.WriteFile(configPath, configFileContents, 0o600); err != nil {
+ return err
}
- // Reload config if it was created.
- if configTemplateRelPath != chezmoi.EmptyRelPath {
- viper.SetConfigType(ext)
- if err := viper.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
- return err
- }
- if err := viper.Unmarshal(&c.ConfigFile, viperDecodeConfigOptions...); err != nil {
- return err
- }
- if err := c.setEncryption(); err != nil {
- return err
- }
+ configStateValue, err := json.Marshal(configState{
+ ConfigTemplateContentsSHA256: chezmoi.HexBytes(chezmoi.SHA256Sum(configTemplate.contents)),
+ })
+ if err != nil {
+ return err
+ }
+ if err := c.persistentState.Set(chezmoi.ConfigStateBucket, configStateKey, configStateValue); err != nil {
+ return err
+ }
+
+ // Reload the config.
+ if err := c.decodeConfigBytes(configTemplate.format, configFileContents, &c.ConfigFile); err != nil {
+ return fmt.Errorf("%s: %w", configTemplate.sourceAbsPath, err)
+ }
+ if err := c.setEncryption(); err != nil {
+ return err
}
return nil
@@ -820,7 +699,7 @@ func (c *Config) defaultConfigFile(
if err != nil {
return chezmoi.EmptyAbsPath, err
}
- for _, extension := range viper.SupportedExts {
+ for _, extension := range chezmoi.FormatExtensions {
configFileAbsPath := configDirAbsPath.JoinString("chezmoi", "chezmoi."+extension)
if _, err := fileSystem.Stat(configFileAbsPath.String()); err == nil {
return configFileAbsPath, nil
@@ -835,6 +714,62 @@ func (c *Config) defaultConfigFile(
return configHomeAbsPath.JoinString("chezmoi", "chezmoi.toml"), nil
}
+// decodeConfigBytes decodes data in format into configFile.
+func (c *Config) decodeConfigBytes(format chezmoi.Format, data []byte, configFile *ConfigFile) error {
+ var configMap map[string]any
+ if err := format.Unmarshal(data, &configMap); err != nil {
+ return err
+ }
+ return c.decodeConfigMap(configMap, configFile)
+}
+
+// decodeConfigFile decodes the config file at configFileAbsPath into
+// configFile.
+func (c *Config) decodeConfigFile(configFileAbsPath chezmoi.AbsPath, configFile *ConfigFile) error {
+ var format chezmoi.Format
+ if c.configFormat == "" {
+ var err error
+ format, err = chezmoi.FormatFromAbsPath(configFileAbsPath)
+ if err != nil {
+ return err
+ }
+ } else {
+ format = c.configFormat.Format()
+ }
+
+ configFileContents, err := c.fileSystem.ReadFile(configFileAbsPath.String())
+ if err != nil {
+ return fmt.Errorf("%s: %w", configFileAbsPath, err)
+ }
+
+ if err := c.decodeConfigBytes(format, configFileContents, configFile); err != nil {
+ return fmt.Errorf("%s: %w", configFileAbsPath, err)
+ }
+
+ return nil
+}
+
+// decodeConfigMap decodes configMap into configFile.
+func (c *Config) decodeConfigMap(configMap map[string]any, configFile *ConfigFile) error {
+ decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
+ DecodeHook: mapstructure.ComposeDecodeHookFunc(
+ mapstructure.StringToTimeDurationHookFunc(),
+ mapstructure.StringToSliceHookFunc(","),
+ chezmoi.StringSliceToEntryTypeSetHookFunc(),
+ chezmoi.StringToAbsPathHookFunc(),
+ StringOrBoolToAutoBoolHookFunc(),
+ ),
+ Result: configFile,
+ })
+ if err != nil {
+ return err
+ }
+ if err := decoder.Decode(configMap); err != nil {
+ return err
+ }
+ return nil
+}
+
// defaultPreApplyFunc is the default pre-apply function. If the target entry
// has changed since chezmoi last wrote it then it prompts the user for the
// action to take.
@@ -1235,26 +1170,39 @@ func (c *Config) filterInput(args []string, f func([]byte) ([]byte, error)) erro
return nil
}
+type configTemplate struct {
+ sourceAbsPath chezmoi.AbsPath
+ format chezmoi.Format
+ targetRelPath chezmoi.RelPath
+ contents []byte
+}
+
// findFirstConfigTemplate searches for a config template, returning the path,
// format, and contents of the first one that it finds.
-func (c *Config) findFirstConfigTemplate() (chezmoi.RelPath, string, []byte, error) {
+func (c *Config) findFirstConfigTemplate() (*configTemplate, error) {
sourceDirAbsPath, err := c.sourceDirAbsPath()
if err != nil {
- return chezmoi.EmptyRelPath, "", nil, err
+ return nil, err
}
- for _, ext := range viper.SupportedExts {
- filename := chezmoi.NewRelPath(chezmoi.Prefix + "." + ext + chezmoi.TemplateSuffix)
- contents, err := c.baseSystem.ReadFile(sourceDirAbsPath.Join(filename))
+ for _, extension := range chezmoi.FormatExtensions {
+ relPath := chezmoi.NewRelPath(chezmoi.Prefix + "." + extension + chezmoi.TemplateSuffix)
+ absPath := sourceDirAbsPath.Join(relPath)
+ contents, err := c.baseSystem.ReadFile(absPath)
switch {
case errors.Is(err, fs.ErrNotExist):
continue
case err != nil:
- return chezmoi.EmptyRelPath, "", nil, err
+ return nil, err
}
- return chezmoi.NewRelPath("chezmoi." + ext), ext, contents, nil
+ return &configTemplate{
+ targetRelPath: chezmoi.NewRelPath("chezmoi." + extension),
+ format: chezmoi.FormatsByExtension[extension],
+ sourceAbsPath: absPath,
+ contents: contents,
+ }, nil
}
- return chezmoi.EmptyRelPath, "", nil, nil
+ return nil, nil
}
func (c *Config) getHTTPClient() (*http.Client, error) {
@@ -1330,16 +1278,7 @@ func (c *Config) makeRunEWithSourceState(
// marshal formats data in dataFormat and writes it to the standard output.
func (c *Config) marshal(dataFormat writeDataFormat, data any) error {
- var format chezmoi.Format
- switch dataFormat {
- case writeDataFormatJSON:
- format = chezmoi.FormatJSON
- case writeDataFormatYAML:
- format = chezmoi.FormatYAML
- default:
- return fmt.Errorf("%s: unknown format", dataFormat)
- }
- marshaledData, err := format.Marshal(data)
+ marshaledData, err := dataFormat.Format().Marshal(data)
if err != nil {
return err
}
@@ -1372,24 +1311,6 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
persistentFlags.Var(&c.UseBuiltinGit, "use-builtin-git", "Use builtin git")
persistentFlags.BoolVarP(&c.Verbose, "verbose", "v", c.Verbose, "Make output more verbose")
persistentFlags.VarP(&c.WorkingTreeAbsPath, "working-tree", "W", "Set working tree directory")
- for viperKey, key := range map[string]string{
- "cacheDir": "cache",
- "color": "color",
- "destDir": "destination",
- "persistentState": "persistent-state",
- "progress": "progress",
- "mode": "mode",
- "safe": "safe",
- "sourceDir": "source",
- "useBuiltinAge": "use-builtin-age",
- "useBuiltinGit": "use-builtin-git",
- "verbose": "verbose",
- "workingTree": "working-tree",
- } {
- if err := viper.BindPFlag(viperKey, persistentFlags.Lookup(key)); err != nil {
- return nil, err
- }
- }
persistentFlags.VarP(&c.configFileAbsPath, "config", "c", "Set config file")
persistentFlags.Var(&c.configFormat, "config-format", "Set config file format")
@@ -1551,13 +1472,22 @@ func (c *Config) persistentPostRunRootE(cmd *cobra.Command, args []string) error
}
if boolAnnotation(cmd, modifiesConfigFile) {
- // Warn the user of any errors reading the config file.
- v := viper.New()
- v.SetFs(afero.FromIOFS{FS: c.fileSystem})
- v.SetConfigFile(c.configFileAbsPath.String())
- err := v.ReadInConfig()
- if err == nil {
- err = v.Unmarshal(&Config{}, viperDecodeConfigOptions...)
+ configFileContents, err := c.baseSystem.ReadFile(c.configFileAbsPath)
+ switch {
+ case errors.Is(err, fs.ErrNotExist):
+ err = nil
+ case err != nil:
+ // err is already set, do nothing.
+ default:
+ var format chezmoi.Format
+ if format, err = chezmoi.FormatFromAbsPath(c.configFileAbsPath); err == nil {
+ var config map[string]any
+ if err = format.Unmarshal(configFileContents, &config); err != nil {
+ // err is already set, do nothing.
+ } else {
+ err = c.decodeConfigMap(config, &ConfigFile{})
+ }
+ }
}
if err != nil {
c.errorf("warning: %s: %v\n", c.configFileAbsPath, err)
@@ -1649,6 +1579,20 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
}
}
+ // Save flags that were set on the command line. Skip some types as
+ // spf13/pflag does not round trip them correctly.
+ changedFlags := make(map[pflag.Value]string)
+ brokenFlagTypes := map[string]bool{
+ "stringToInt": true,
+ "stringToInt64": true,
+ "stringToString": true,
+ }
+ cmd.Flags().VisitAll(func(flag *pflag.Flag) {
+ if flag.Changed && !brokenFlagTypes[flag.Value.Type()] {
+ changedFlags[flag.Value] = flag.Value.String()
+ }
+ })
+
// Read the config file.
if err := c.readConfig(); err != nil {
if !boolAnnotation(cmd, doesNotRequireValidConfig) {
@@ -1657,6 +1601,13 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
c.errorf("warning: %s: %v\n", c.configFileAbsPath, err)
}
+ // Restore flags that were set on the command line.
+ for value, original := range changedFlags {
+ if err := value.Set(original); err != nil {
+ return err
+ }
+ }
+
// Configure the logger.
log.Logger = log.Output(zerolog.NewConsoleWriter(
func(w *zerolog.ConsoleWriter) {
@@ -1867,21 +1818,12 @@ func (c *Config) persistentStateFile() (chezmoi.AbsPath, error) {
// readConfig reads the config file, if it exists.
func (c *Config) readConfig() error {
- viper.SetConfigFile(c.configFileAbsPath.String())
- if c.configFormat != "" {
- viper.SetConfigType(c.configFormat.String())
- }
- viper.SetFs(afero.FromIOFS{FS: c.fileSystem})
- switch err := viper.ReadInConfig(); {
+ switch err := c.decodeConfigFile(c.configFileAbsPath, &c.ConfigFile); {
case errors.Is(err, fs.ErrNotExist):
return nil
- case err != nil:
- return err
- }
- if err := viper.Unmarshal(&c.ConfigFile, viperDecodeConfigOptions...); err != nil {
+ default:
return err
}
- return nil
}
// run runs name with args in dir.
@@ -2188,6 +2130,103 @@ func (c *Config) writeOutputString(data string) error {
return c.writeOutput([]byte(data))
}
+func newConfigFile(bds *xdg.BaseDirectorySpecification) ConfigFile {
+ return ConfigFile{
+ // Global configuration.
+ CacheDirAbsPath: chezmoi.NewAbsPath(bds.CacheHome).Join(chezmoiRelPath),
+ Color: autoBool{
+ auto: true,
+ },
+ Interpreters: defaultInterpreters,
+ Pager: os.Getenv("PAGER"),
+ PINEntry: pinEntryConfig{
+ Options: pinEntryDefaultOptions,
+ },
+ Safe: true,
+ Template: templateConfig{
+ Options: chezmoi.DefaultTemplateOptions,
+ },
+ Umask: chezmoi.Umask,
+ UseBuiltinAge: autoBool{
+ auto: true,
+ },
+ UseBuiltinGit: autoBool{
+ auto: true,
+ },
+
+ // Password manager configurations.
+ Bitwarden: bitwardenConfig{
+ Command: "bw",
+ },
+ Gopass: gopassConfig{
+ Command: "gopass",
+ },
+ Keepassxc: keepassxcConfig{
+ Command: "keepassxc-cli",
+ },
+ Keeper: keeperConfig{
+ Command: "keeper",
+ },
+ Lastpass: lastpassConfig{
+ Command: "lpass",
+ },
+ Onepassword: onepasswordConfig{
+ Command: "op",
+ Prompt: true,
+ },
+ Pass: passConfig{
+ Command: "pass",
+ },
+ Passhole: passholeConfig{
+ Command: "ph",
+ Prompt: true,
+ },
+ Vault: vaultConfig{
+ Command: "vault",
+ },
+
+ // Encryption configurations.
+ Age: defaultAgeEncryptionConfig,
+ GPG: defaultGPGEncryptionConfig,
+
+ // Command configurations.
+ Add: addCmdConfig{
+ exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
+ recursive: true,
+ },
+ Diff: diffCmdConfig{
+ Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
+ },
+ Edit: editCmdConfig{
+ Hardlink: true,
+ MinDuration: 1 * time.Second,
+ exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ include: chezmoi.NewEntryTypeSet(
+ chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted,
+ ),
+ },
+ Format: defaultWriteDataFormat,
+ Git: gitCmdConfig{
+ Command: "git",
+ },
+ Merge: mergeCmdConfig{
+ Command: "vimdiff",
+ },
+ Status: statusCmdConfig{
+ Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
+ recursive: true,
+ },
+ Verify: verifyCmdConfig{
+ Exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll &^ chezmoi.EntryTypeScripts),
+ recursive: true,
+ },
+ }
+}
+
func parseCommand(command string, args []string) (string, []string, error) {
// If command is found, then return it.
if path, err := chezmoi.LookPath(command); err == nil {
diff --git a/pkg/cmd/dataformat.go b/pkg/cmd/dataformat.go
index 6d1fb502996..9847827da8b 100644
--- a/pkg/cmd/dataformat.go
+++ b/pkg/cmd/dataformat.go
@@ -56,6 +56,11 @@ func (f *readDataFormat) Set(s string) error {
return nil
}
+// Format returns f's format.
+func (f readDataFormat) Format() chezmoi.Format {
+ return chezmoi.FormatsByName[string(f)]
+}
+
// String implements github.com/spf13/pflag.Value.String.
func (f readDataFormat) String() string {
return string(f)
@@ -66,6 +71,11 @@ func (f readDataFormat) Type() string {
return "json|toml|yaml"
}
+// Format returns f's format.
+func (f writeDataFormat) Format() chezmoi.Format {
+ return chezmoi.FormatsByName[string(f)]
+}
+
// Set implements github.com/spf13/pflag.Value.Set.
func (f *writeDataFormat) Set(s string) error {
switch strings.ToLower(s) {
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go
index 1353f2a1e99..f86a49cda25 100644
--- a/pkg/cmd/doctorcmd.go
+++ b/pkg/cmd/doctorcmd.go
@@ -21,7 +21,6 @@ import (
"github.com/coreos/go-semver/semver"
"github.com/google/go-github/v45/github"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
"github.com/twpayne/go-shell"
"github.com/twpayne/go-xdg/v6"
@@ -474,7 +473,7 @@ func (c *configFileCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsP
if err != nil {
return checkResultFailed, err.Error()
}
- for _, extension := range viper.SupportedExts {
+ for _, extension := range chezmoi.FormatExtensions {
filenameAbsPath := configDirAbsPath.Join(c.basename, chezmoi.NewRelPath(c.basename.String()+"."+extension))
if _, err := system.Stat(filenameAbsPath); err == nil {
filenameAbsPaths[filenameAbsPath] = struct{}{}
diff --git a/pkg/cmd/testdata/scripts/data.txtar b/pkg/cmd/testdata/scripts/data.txtar
index 643fd623fc4..53eb69500d2 100644
--- a/pkg/cmd/testdata/scripts/data.txtar
+++ b/pkg/cmd/testdata/scripts/data.txtar
@@ -1,17 +1,17 @@
# test that chezmoi data includes data set in config file
exec chezmoi data
stdout '"chezmoi":'
-stdout '"uniquekey": "uniqueValue"' # viper downcases uniqueKey
+stdout '"uniqueKey": "uniqueValue"'
# test that chezmoi data --format=json includes data set in config file
exec chezmoi data --format=json
stdout '"chezmoi":'
-stdout '"uniquekey": "uniqueValue"'
+stdout '"uniqueKey": "uniqueValue"'
# test that chezmoi data --format=yaml includes data set in config file
exec chezmoi data --format=yaml
stdout 'chezmoi:'
-stdout 'uniquekey: uniqueValue'
+stdout 'uniqueKey: uniqueValue'
-- home/user/.config/chezmoi/chezmoi.toml --
[data]
diff --git a/pkg/cmd/testdata/scripts/edgecases.txtar b/pkg/cmd/testdata/scripts/edgecases.txtar
index 6ee1ba83ab3..e4f3a08e278 100644
--- a/pkg/cmd/testdata/scripts/edgecases.txtar
+++ b/pkg/cmd/testdata/scripts/edgecases.txtar
@@ -47,8 +47,16 @@ chhome home4/user
! exec chezmoi status
! stderr 'not allowed in \.chezmoitemplates directory'
+# test that chezmoi data returns an error if an unknown read format is specified
+! exec chezmoi init --config-format=yml
+stderr 'invalid or unsupported data format'
+
+# test that chezmoi data returns an error if an unknown write format is specified
+! exec chezmoi data --format=yml
+stderr 'invalid or unsupported data format'
+
skip 'FIXME make the following test pass'
-chhome home5/user
+chhome home6/user
# test that chezmoi reports an inconsistent state error when a file should be both removed and present, even if the file is not already present
! exec chezmoi apply
@@ -67,5 +75,5 @@ stderr 'chezmoi: \.file: inconsistent state
-- home4/user/.local/share/chezmoi/.chezmoitemplates/.chezmoiignore --
-- home5/user/.local/share/chezmoi/.chezmoiremove --
.file
--- home5/user/.local/share/chezmoi/dot_file --
+-- home6/user/.local/share/chezmoi/dot_file --
# contents of .file
diff --git a/pkg/cmd/testdata/scripts/init.txtar b/pkg/cmd/testdata/scripts/init.txtar
index acadfd411fa..ab32312bb8e 100644
--- a/pkg/cmd/testdata/scripts/init.txtar
+++ b/pkg/cmd/testdata/scripts/init.txtar
@@ -73,7 +73,7 @@ chhome home8/user
# test that chezmoi init fails if the generated config is not valid
mkgitconfig
! exec chezmoi init
-stderr 'While parsing config:'
+stderr '\.chezmoi\.toml\.tmpl: toml: expected character ='
! exists .config/chezmoi
chhome home/user
@@ -114,6 +114,16 @@ chhome home12/user
exec chezmoi init --promptBool bool=true --promptInt int=1 --promptString bool=string
cmp $CHEZMOICONFIGDIR/chezmoi.yaml golden/chezmoi.yaml
+chhome home13/user
+
+# test that chezmoi init creates a config file with a .yml extension
+exec chezmoi init
+exists $CHEZMOICONFIGDIR/chezmoi.yml
+
+# test that chezmoi reads a config file with a .yml extension
+exec chezmoi execute-template '{{ .key }}'
+stdout ^value$
+
-- golden/chezmoi.toml --
[data]
email = "[email protected]"
@@ -149,3 +159,6 @@ data:
bool: {{ promptBool "bool" }}
int: {{ promptInt "int" }}
string: {{ promptString "bool" }}
+-- home13/user/.local/share/chezmoi/.chezmoi.yml.tmpl --
+data:
+ key: value
|
fix
|
Preserve case in user template data
|
f8458416db83a8c55feb79ad801cd75d1b7fb5f9
|
2024-11-30 06:00:12
|
Tom Payne
|
chore: Update tools
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index bec0382d416..89b65554144 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -27,7 +27,7 @@ env:
GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases
PYTHON_VERSION: '3.10' # https://www.python.org/downloads/
RAGE_VERSION: 0.11.0 # https://github.com/str4d/rage/releases
- UV_VERSION: 0.5.4 # https://github.com/astral-sh/uv/releases
+ UV_VERSION: 0.5.5 # https://github.com/astral-sh/uv/releases
jobs:
changes:
runs-on: ubuntu-22.04
|
chore
|
Update tools
|
bd75ca97bcf707174e07d7c5c5f7ed9979735191
|
2022-04-02 15:32:33
|
Tom Payne
|
chore: Bump golangci-lint to version 1.45.2
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 797841e27b4..b94372896d9 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -12,7 +12,7 @@ env:
AGE_VERSION: 1.0.0
GO_VERSION: 1.18
GOFUMPT_VERSION: 0.3.1
- GOLANGCI_LINT_VERSION: 1.45.0
+ GOLANGCI_LINT_VERSION: 1.45.2
jobs:
build-website:
runs-on: ubuntu-latest
|
chore
|
Bump golangci-lint to version 1.45.2
|
ba5fb53bb7300c7104564963da2fb7b78dae5731
|
2023-03-18 01:23:31
|
Raphaël Beamonte
|
feat: Add support for ejson
| false
|
diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
index 128e762961d..854ef5cad44 100644
--- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
+++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
@@ -165,6 +165,13 @@ sections:
watch:
type: bool
description: Automatically apply changes when files are saved
+ ejson:
+ keyDir:
+ type: 'string'
+ description: Path to directory containing private keys. Defaults to /opt/ejson/keys. Setting the EJSON_KEYDIR environment will also set this value, with lower precedence.
+ key:
+ type: 'string'
+ description: The private key to use for decryption, will supersede using the keyDir if set.
git:
autoAdd:
type: bool
diff --git a/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecrypt.md b/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecrypt.md
new file mode 100644
index 00000000000..d884e2be8e4
--- /dev/null
+++ b/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecrypt.md
@@ -0,0 +1,16 @@
+# `ejsonDecrypt` *filePath*
+
+`ejsonDecrypt` returns the decrypted content of an
+[ejson](https://github.com/Shopify/ejson)-encrypted file.
+
+*filePath* indicates where the encrypted file is located.
+
+The decrypted file is cached so calling `ejsonDecrypt` multiple
+times with the same *filePath* will only run through the decryption
+process once. The cache is shared with `ejsonDecryptWithKey`.
+
+!!! example
+
+ ```
+ {{ (ejsonDecrypt "my-secrets.ejson").password }}
+ ```
diff --git a/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecryptWithKey.md b/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecryptWithKey.md
new file mode 100644
index 00000000000..78fe501f44b
--- /dev/null
+++ b/assets/chezmoi.io/docs/reference/templates/ejson-functions/ejsonDecryptWithKey.md
@@ -0,0 +1,17 @@
+# `ejsonDecryptWithKey` *filePath* *key*
+
+`ejsonDecryptWithKey` returns the decrypted content of an
+[ejson](https://github.com/Shopify/ejson)-encrypted file.
+
+*filePath* indicates where the encrypted file is located,
+and *key* is used to decrypt the file.
+
+The decrypted file is cached so calling `ejsonDecryptWithKey` multiple
+times with the same *filePath* will only run through the decryption
+process once. The cache is shared with `ejsonDecrypt`.
+
+!!! example
+
+ ```
+ {{ (ejsonDecryptWithKey "my-secrets.ejson" "top-secret-key").password }}
+ ```
diff --git a/assets/chezmoi.io/docs/reference/templates/ejson-functions/index.md b/assets/chezmoi.io/docs/reference/templates/ejson-functions/index.md
new file mode 100644
index 00000000000..7dcd02d2b21
--- /dev/null
+++ b/assets/chezmoi.io/docs/reference/templates/ejson-functions/index.md
@@ -0,0 +1,4 @@
+# ejson functions
+
+The `ejson*` functions return data from
+[ejson](https://github.com/Shopify/ejson)-encrypted files.
diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/ejson.md b/assets/chezmoi.io/docs/user-guide/password-managers/ejson.md
new file mode 100644
index 00000000000..f396e53eb45
--- /dev/null
+++ b/assets/chezmoi.io/docs/user-guide/password-managers/ejson.md
@@ -0,0 +1,18 @@
+# ejson
+
+chezmoi includes support for [ejson](https://github.com/Shopify/ejson).
+
+Structured data can be retrieved with the `ejsonDecrypt` template function,
+for example:
+
+```
+examplePassword = {{ (ejsonDecrypt "my-secrets.ejson").password }}
+```
+
+If you want to specify the private key to use for the decryption,
+structured data can be retrieved with the `ejsonDecryptWithKey` template
+function, for example:
+
+```
+examplePassword = {{ (ejsonDecryptWithKey "my-secrets.ejson" "top-secret-key").password }}
+```
diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml
index 6319f7753f7..c9ee5d7fc3e 100644
--- a/assets/chezmoi.io/mkdocs.yml
+++ b/assets/chezmoi.io/mkdocs.yml
@@ -63,6 +63,7 @@ nav:
- AWS Secrets Manager: user-guide/password-managers/aws-secrets-manager.md
- Bitwarden: user-guide/password-managers/bitwarden.md
- Dashlane: user-guide/password-managers/dashlane.md
+ - ejson: user-guide/password-managers/ejson.md
- gopass: user-guide/password-managers/gopass.md
- KeePassXC: user-guide/password-managers/keepassxc.md
- Keychain and Windows Credentials Manager: user-guide/password-managers/keychain-and-windows-credentials-manager.md
@@ -240,14 +241,18 @@ nav:
- bitwardenFields: reference/templates/bitwarden-functions/bitwardenFields.md
- rbw: reference/templates/bitwarden-functions/rbw.md
- rbwFields: reference/templates/bitwarden-functions/rbwFields.md
- - gopass functions:
- - reference/templates/gopass-functions/index.md
- - gopass: reference/templates/gopass-functions/gopass.md
- - gopassRaw: reference/templates/gopass-functions/gopassRaw.md
- Dashlane functions:
- reference/templates/dashlane-functions/index.md
- dashlaneNote: reference/templates/dashlane-functions/dashlaneNote.md
- dashlanePassword: reference/templates/dashlane-functions/dashlanePassword.md
+ - ejson functions:
+ - reference/templates/ejson-functions/index.md
+ - ejsonDecrypt: reference/templates/ejson-functions/ejsonDecrypt.md
+ - ejsonDecryptWithKey: reference/templates/ejson-functions/ejsonDecryptWithKey.md
+ - gopass functions:
+ - reference/templates/gopass-functions/index.md
+ - gopass: reference/templates/gopass-functions/gopass.md
+ - gopassRaw: reference/templates/gopass-functions/gopassRaw.md
- KeePassXC functions:
- reference/templates/keepassxc-functions/index.md
- keepassxc: reference/templates/keepassxc-functions/keepassxc.md
diff --git a/go.mod b/go.mod
index 116e74ac3ff..01a46b7dfae 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,7 @@ go 1.19
require (
filippo.io/age v1.1.1
github.com/Masterminds/sprig/v3 v3.2.3
+ github.com/Shopify/ejson v1.3.3
github.com/aws/aws-sdk-go-v2 v1.17.6
github.com/aws/aws-sdk-go-v2/config v1.18.16
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.0
@@ -80,6 +81,7 @@ require (
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.8.1 // indirect
+ github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
@@ -115,6 +117,7 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/skeema/knownhosts v1.1.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
+ github.com/stretchr/objx v0.5.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/yuin/goldmark v1.5.4 // indirect
github.com/yuin/goldmark-emoji v1.0.1 // indirect
diff --git a/go.sum b/go.sum
index 562762bc02c..9bcbafad402 100644
--- a/go.sum
+++ b/go.sum
@@ -12,6 +12,8 @@ github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2B
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
+github.com/Shopify/ejson v1.3.3 h1:dPzgmvFhUPTJIzwdF5DaqbwW1dWaoR8ADKRdSTy6Mss=
+github.com/Shopify/ejson v1.3.3/go.mod h1:VZMUtDzvBW/PAXRUF5fzp1ffb1ucT8MztrZXXLYZurw=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
@@ -94,6 +96,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0=
github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
+github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad h1:Qk76DOWdOp+GlyDKBAG3Klr9cn7N+LcYc82AZ2S7+cA=
+github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad/go.mod h1:mPKfmRa823oBIgl2r20LeMSpTAteW5j7FLkc0vjmzyQ=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
@@ -135,6 +139,7 @@ github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxeh
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
@@ -154,6 +159,7 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
@@ -246,6 +252,8 @@ github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0=
github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag=
+github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index daac08e07e8..2c0640cc306 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -120,6 +120,7 @@ type ConfigFile struct {
AWSSecretsManager awsSecretsManagerConfig `json:"awsSecretsManager" mapstructure:"awsSecretsManager" yaml:"awsSecretsManager"` //nolint:lll
Bitwarden bitwardenConfig `json:"bitwarden" mapstructure:"bitwarden" yaml:"bitwarden"`
Dashlane dashlaneConfig `json:"dashlane" mapstructure:"dashlane" yaml:"dashlane"`
+ Ejson ejsonConfig `json:"ejson" mapstructure:"ejson" yaml:"ejson"`
Gopass gopassConfig `json:"gopass" mapstructure:"gopass" yaml:"gopass"`
Keepassxc keepassxcConfig `json:"keepassxc" mapstructure:"keepassxc" yaml:"keepassxc"`
Keeper keeperConfig `json:"keeper" mapstructure:"keeper" yaml:"keeper"`
@@ -379,6 +380,8 @@ func newConfig(options ...configOption) (*Config, error) {
"dashlanePassword": c.dashlanePasswordTemplateFunc,
"decrypt": c.decryptTemplateFunc,
"deleteValueAtPath": c.deleteValueAtPathTemplateFunc,
+ "ejsonDecrypt": c.ejsonDecryptTemplateFunc,
+ "ejsonDecryptWithKey": c.ejsonDecryptWithKeyTemplateFunc,
"encrypt": c.encryptTemplateFunc,
"eqFold": c.eqFoldTemplateFunc,
"fromIni": c.fromIniTemplateFunc,
@@ -2450,6 +2453,7 @@ func newConfigFile(bds *xdg.BaseDirectorySpecification) ConfigFile {
Dashlane: dashlaneConfig{
Command: "dcli",
},
+ Ejson: ejsonConfig{},
Gopass: gopassConfig{
Command: "gopass",
},
diff --git a/pkg/cmd/ejsontemplatefuncs.go b/pkg/cmd/ejsontemplatefuncs.go
new file mode 100644
index 00000000000..d493bd12311
--- /dev/null
+++ b/pkg/cmd/ejsontemplatefuncs.go
@@ -0,0 +1,60 @@
+package cmd
+
+import (
+ "encoding/json"
+ "os"
+
+ "github.com/Shopify/ejson"
+)
+
+const (
+ ejsonDefaultKeyDir = "/opt/ejson/keys"
+ ejsonEnvKeyDir = "EJSON_KEYDIR"
+)
+
+type ejsonConfig struct {
+ KeyDir string `json:"keyDir" mapstructure:"keyDir" yaml:"keyDir"`
+ Key string `json:"key" mapstructure:"key" yaml:"key"`
+ cache map[string]any
+}
+
+func (c *Config) ejsonDecryptWithKeyTemplateFunc(filePath, key string) any {
+ if data, ok := c.Ejson.cache[filePath]; ok {
+ return data
+ }
+
+ if c.Ejson.cache == nil {
+ c.Ejson.cache = make(map[string]any)
+ }
+
+ /* We accept here that an empty string is considered as if
+ the value was not provided; in reality, someone could
+ provide an empty value, but ejson would then look into
+ the root of the filesystem; this means that this is not
+ a real limitation, since people could simply set '/'
+ if wanting to use the filesystem root (or equivalent) */
+ keyDir := c.Ejson.KeyDir
+ if keyDir == "" {
+ keyDir = os.Getenv(ejsonEnvKeyDir)
+ }
+ if keyDir == "" {
+ keyDir = ejsonDefaultKeyDir
+ }
+
+ decrypted, err := ejson.DecryptFile(filePath, keyDir, key)
+ if err != nil {
+ panic(err)
+ }
+
+ var data any
+ if err := json.Unmarshal(decrypted, &data); err != nil {
+ panic(err)
+ }
+
+ c.Ejson.cache[filePath] = data
+ return data
+}
+
+func (c *Config) ejsonDecryptTemplateFunc(filePath string) any {
+ return c.ejsonDecryptWithKeyTemplateFunc(filePath, c.Ejson.Key)
+}
diff --git a/pkg/cmd/testdata/scripts/ejson.txtar b/pkg/cmd/testdata/scripts/ejson.txtar
new file mode 100644
index 00000000000..096d638c1f5
--- /dev/null
+++ b/pkg/cmd/testdata/scripts/ejson.txtar
@@ -0,0 +1,51 @@
+# test ejsonDecrypt uses default parameters
+! exec chezmoi execute-template '{{ (ejsonDecrypt "golden/my-file.ejson") }}'
+stderr 'couldn''t read key file'
+stderr '/opt/ejson/keys/df82a403a3b58ebedd09758d3b131ff3113b39bdbfb92110940eb57832774345'
+
+# test ejsonDecrypt uses EJSON_KEYDIR when set
+env EJSON_KEYDIR=golden/keys
+exec chezmoi execute-template '{{ (ejsonDecrypt "golden/my-file.ejson").key1 }}'
+stdout ^value1$
+
+# test ejsonDecrypt uses configuration's keyDir when set
+chhome home_set_valid_keydir/user
+env EJSON_KEYDIR=invalid/keys
+exec chezmoi execute-template '{{ (ejsonDecrypt "golden/my-file.ejson").key2 }}'
+stdout ^value2$
+
+# test ejsonDecrypt uses configuration's key when set, and succeeds if valid
+chhome home_set_valid_key/user
+exec chezmoi execute-template '{{ (ejsonDecrypt "golden/my-file.ejson").key1 }}'
+stdout ^value1$
+
+# test ejsonDecrypt uses configuration's key when set, and fails if invalid
+chhome home_set_invalid_key/user
+! exec chezmoi execute-template '{{ (ejsonDecrypt "golden/my-file.ejson") }}'
+
+# test ejsonDecryptWithKey uses the key passed as parameter, and succeeds if valid
+chhome home_set_invalid_key/user
+exec chezmoi execute-template '{{ (ejsonDecryptWithKey "golden/my-file.ejson" "4fed3b88a33a4621b30230f1ad17e175e10f8587e37e84da740711c9fecfe16d").key2 }}'
+stdout ^value2$
+
+# test ejsonDecryptWithKey uses the key passed as parameter, and fails if invalid
+chhome home_set_valid_key/user
+! exec chezmoi execute-template '{{ (ejsonDecryptWithKey "golden/my-file.ejson" "invalid") }}'
+
+-- golden/keys/df82a403a3b58ebedd09758d3b131ff3113b39bdbfb92110940eb57832774345 --
+4fed3b88a33a4621b30230f1ad17e175e10f8587e37e84da740711c9fecfe16d
+-- golden/my-file.ejson --
+{
+ "_public_key": "df82a403a3b58ebedd09758d3b131ff3113b39bdbfb92110940eb57832774345",
+ "key1": "EJ[1:t1Ql8sPo+fpQxHSxarJYDctfjXwfB9+OMH4BK/0CQEE=:9lajUfn0rbr/fbVYHi0yF/BH64htU4yF:8ydfFcJ7UO6rg7TGO2vqT19NBSk02Q==]",
+ "key2": "EJ[1:t1Ql8sPo+fpQxHSxarJYDctfjXwfB9+OMH4BK/0CQEE=:vmOdZjp4gqY0pmjeVb/BQQaFzW17wK5f:7UtzdtHcrwvwZdjqm4Jmn9GHxFkR1Q==]"
+}
+-- home_set_invalid_key/user/.config/chezmoi/chezmoi.yaml --
+ejson:
+ key: "foo"
+-- home_set_valid_key/user/.config/chezmoi/chezmoi.yaml --
+ejson:
+ key: "4fed3b88a33a4621b30230f1ad17e175e10f8587e37e84da740711c9fecfe16d"
+-- home_set_valid_keydir/user/.config/chezmoi/chezmoi.yaml --
+ejson:
+ keyDir: "golden/keys"
|
feat
|
Add support for ejson
|
ec2b92af9f0516dd34aae61f28f6c9979e3a61cd
|
2021-11-28 16:53:56
|
Tom Payne
|
feat: Add edit.hardlink config var and edit --hardlink flag
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index 6a2ee862627..3bc3db13667 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -381,6 +381,7 @@ The following configuration variables are available:
| | `pager` | string | *none* | Docs-specific pager |
| `edit` | `args` | []string | *none* | Extra args to edit command |
| | `command` | string | `$EDITOR` / `$VISUAL` | Edit command |
+| | `hardlink` | bool | `true` | Invoke editor with a hardlink to the source file |
| | `minDuration` | duration | `1s` | Minimum duration for edit command |
| `secret` | `command` | string | *none* | Generic secret command |
| `git` | `autoAdd ` | bool | `false` | Add changes to the source state after any change |
@@ -1284,7 +1285,9 @@ invoked with the decrypted file. When the editor exits the edited decrypted file
is re-encrypted and replaces the original file in the source state.
If the operating system supports hard links, then the edit command invokes the
-editor with filenames which match the target filename.
+editor with filenames which match the target filename, unless the
+`edit.hardlink` configuration variable is set to `false` the `--hardlink=false`
+command line flag is set.
chezmoi will emit a warning if the editor returns in less than
`edit.minDuration` (default `1s`). To disable this warning, set
@@ -1294,6 +1297,11 @@ chezmoi will emit a warning if the editor returns in less than
Apply target immediately after editing. Ignored if there are no targets.
+#### `--hardlink` *bool*
+
+Invoke the editor with a hard link to the source file with a name matching the
+target filename. This can help the editor determine the type of the file
+correctly. This is the default.
#### `edit` examples
```console
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 0b39bc57f40..680352f5499 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -306,6 +306,7 @@ func newConfig(options ...configOption) (*Config, error) {
MaxWidth: 80,
},
Edit: editCmdConfig{
+ Hardlink: true,
MinDuration: 1 * time.Second,
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
include: chezmoi.NewEntryTypeSet(
diff --git a/internal/cmd/editcmd.go b/internal/cmd/editcmd.go
index f17a762db3d..04bec6e6361 100644
--- a/internal/cmd/editcmd.go
+++ b/internal/cmd/editcmd.go
@@ -13,6 +13,7 @@ import (
type editCmdConfig struct {
Command string `mapstructure:"command"`
Args []string `mapstructure:"args"`
+ Hardlink bool `mapstructure:"hardlink"`
MinDuration time.Duration `mapstructure:"minDuration"`
apply bool
exclude *chezmoi.EntryTypeSet
@@ -39,6 +40,7 @@ func (c *Config) newEditCmd() *cobra.Command {
flags := editCmd.Flags()
flags.BoolVarP(&c.Edit.apply, "apply", "a", c.Edit.apply, "Apply after editing")
flags.VarP(c.Edit.exclude, "exclude", "x", "Exclude entry types")
+ flags.BoolVar(&c.Edit.Hardlink, "hardlink", c.Edit.Hardlink, "Invoke editor with a hardlink to the source file")
flags.VarP(c.Edit.include, "include", "i", "Include entry types")
flags.BoolVar(&c.Edit.init, "init", c.update.init, "Recreate config file from template")
@@ -110,7 +112,7 @@ TARGETRELPATH:
}
transparentlyDecryptedFiles = append(transparentlyDecryptedFiles, transparentlyDecryptedFile)
editorArgs = append(editorArgs, decryptedAbsPath.String())
- case ok && runtime.GOOS != "windows":
+ case ok && c.Edit.Hardlink && runtime.GOOS != "windows":
// If the operating system supports hard links and the file is not
// encrypted, then create a hard link to the file in the source
// directory in the temporary edit directory. This means that the
diff --git a/internal/cmd/testdata/scripts/edithardlink.txt b/internal/cmd/testdata/scripts/edithardlink.txt
new file mode 100644
index 00000000000..cc481ac1f1f
--- /dev/null
+++ b/internal/cmd/testdata/scripts/edithardlink.txt
@@ -0,0 +1,15 @@
+[windows] skip 'Windows does not support hardlinks'
+
+# test that chezmoi edit uses a hardlink by default
+chezmoi edit $HOME${/}.file
+stdout /\.file$
+
+# test that chezmoi edit --hardlink=false does not use a hardlink
+chezmoi edit --hardlink=false $HOME${/}.file
+stdout ${CHEZMOISOURCEDIR@R}/dot_file$
+
+-- home/user/.config/chezmoi/chezmoi.toml --
+[edit]
+ command = "echo"
+-- home/user/.local/share/chezmoi/dot_file --
+# contents of .file
|
feat
|
Add edit.hardlink config var and edit --hardlink flag
|
562177ae26a2869599a722f4dd5cf8e064b8a0d5
|
2024-12-23 23:43:47
|
Tom Payne
|
chore: Update tools
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 672472f5375..d4ca77d675d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -27,7 +27,7 @@ env:
GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases
PYTHON_VERSION: '3.10' # https://www.python.org/downloads/
RAGE_VERSION: 0.11.1 # https://github.com/str4d/rage/releases
- UV_VERSION: 0.5.10 # https://github.com/astral-sh/uv/releases
+ UV_VERSION: 0.5.11 # https://github.com/astral-sh/uv/releases
jobs:
changes:
runs-on: ubuntu-22.04
|
chore
|
Update tools
|
b9fae1fbd3047e77e7d46ecd88d8ef95731e816e
|
2023-02-21 15:45:02
|
Tom Payne
|
docs: Improve documentation on git-repo externals
| false
|
diff --git a/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/externals.md b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/externals.md
new file mode 100644
index 00000000000..7aab9350ccc
--- /dev/null
+++ b/assets/chezmoi.io/docs/user-guide/frequently-asked-questions/externals.md
@@ -0,0 +1,8 @@
+# Externals
+
+## Why do files in `git-repo` externals appear in `chezmoi unmanaged`?
+
+chezmoi's support for `git-repo` externals is limited to running `git init` and
+`git pull` in the directory. This means that the directory is managed by chezmoi
+but its contents are not. Consequently, `git-repo` directories are listed by
+`chezmoi managed` but their contents are listed in `chezmoi unmanaged`.
diff --git a/assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md b/assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md
index b4d0548143c..a0da9cbc6c3 100644
--- a/assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md
+++ b/assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md
@@ -207,7 +207,8 @@ pull`) by passing the `--refresh-externals`/`-R` flag to `chezmoi apply`.
directory to git. chezmoi cannot manage any other files in that directory.
The contents of `git-repo` externals will not be manifested in commands
- like `chezmoi archive` or `chezmoi dump`.
+ like `chezmoi diff` or `chezmoi dump`, and will be listed by `chezmoi
+ unmanaged`.
!!! hint
diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml
index 13d8e89f90b..96684cb61e5 100644
--- a/assets/chezmoi.io/mkdocs.yml
+++ b/assets/chezmoi.io/mkdocs.yml
@@ -88,6 +88,7 @@ nav:
- Frequently asked questions:
- Usage: user-guide/frequently-asked-questions/usage.md
- Encryption: user-guide/frequently-asked-questions/encryption.md
+ - Externals: user-guide/frequently-asked-questions/externals.md
- Troubleshooting: user-guide/frequently-asked-questions/troubleshooting.md
- Design: user-guide/frequently-asked-questions/design.md
- General: user-guide/frequently-asked-questions/general.md
|
docs
|
Improve documentation on git-repo externals
|
d3a9098c9621035d396e44c73433e2e1d2331f50
|
2023-01-09 05:19:50
|
Tom Payne
|
docs: Update documentation on encryption
| false
|
diff --git a/assets/chezmoi.io/docs/user-guide/encryption/age.md b/assets/chezmoi.io/docs/user-guide/encryption/age.md
index 7f4e34ae783..5c0a3c64ca3 100644
--- a/assets/chezmoi.io/docs/user-guide/encryption/age.md
+++ b/assets/chezmoi.io/docs/user-guide/encryption/age.md
@@ -56,8 +56,8 @@ the `age` command is not found in `$PATH`.
!!! info
- The builtin age encryption not support passphrases, symmetric encryption,
- or SSH keys.
+ The builtin age encryption does not support passphrases, symmetric
+ encryption, or SSH keys.
Passphrases are not supported because chezmoi needs to decrypt files
regularly, e.g. when running a `chezmoi diff` or a `chezmoi status`
@@ -68,8 +68,8 @@ the `age` command is not found in `$PATH`.
issue](https://github.com/twpayne/chezmoi/issues/new?assignees=&labels=enhancement&template=02_feature_request.md&title=)
if you want this.
- SSH keys are not supported as the author of age [explicitly recommends not
- using them](https://pkg.go.dev/filippo.io/age#hdr-Key_management):
+ SSH keys are not supported as the [age documentation explicitly recommends
+ not using them](https://pkg.go.dev/filippo.io/age#hdr-Key_management):
> When integrating age into a new system, it's recommended that you only
> support X25519 keys, and not SSH keys. The latter are supported for
diff --git a/assets/chezmoi.io/docs/user-guide/encryption/gpg.md b/assets/chezmoi.io/docs/user-guide/encryption/gpg.md
index 1a58a5d9f7a..3ee1f2f416f 100644
--- a/assets/chezmoi.io/docs/user-guide/encryption/gpg.md
+++ b/assets/chezmoi.io/docs/user-guide/encryption/gpg.md
@@ -2,7 +2,7 @@
chezmoi supports encrypting files with [gpg](https://www.gnupg.org/). Encrypted
files are stored in the source state and automatically be decrypted when
-generating the target state or printing a file's contents with `chezmoi cat`.
+generating the target state or editing a file contents with `chezmoi edit`.
## Asymmetric (private/public-key) encryption
@@ -24,25 +24,6 @@ gpg --armor --recipient $RECIPIENT --encrypt
and store the encrypted file in the source state. The file will automatically
be decrypted when generating the target state.
-!!! hint
-
- The `gpg.recipient` key must be ultimately trusted, otherwise encryption
- will fail because gpg will prompt for input, which chezmoi does not handle.
- You can check the trust level by running:
-
- ```console
- $ gpg --export-ownertrust
- ```
-
- The trust level for the recipient's key should be `6`. If it is not, you
- can change the trust level by running:
-
- ```console
- $ gpg --edit-key $RECIPIENT
- ```
-
- Enter `trust` at the prompt and chose `5 = I trust ultimately`.
-
## Symmetric encryption
Specify symmetric encryption in your configuration file:
diff --git a/assets/chezmoi.io/docs/user-guide/encryption/index.md b/assets/chezmoi.io/docs/user-guide/encryption/index.md
index d76b09f91c9..932ddd67bb8 100644
--- a/assets/chezmoi.io/docs/user-guide/encryption/index.md
+++ b/assets/chezmoi.io/docs/user-guide/encryption/index.md
@@ -1,9 +1,10 @@
# Encryption
-chezmoi supports encrypting whole files with [age](https://age-encryption.org)
-and [gpg](https://www.gnupg.com/). Encrypted files are stored in ASCII-armored
-format in the source directory with the `encrypted_` attribute and are
-automatically decrypted when needed.
+chezmoi supports encrypting files with [age](https://age-encryption.org)
+and [gpg](https://www.gnupg.com/).
+
+Encrypted files are stored in ASCII-armored format in the source directory with
+the `encrypted_` attribute and are automatically decrypted when needed.
Add files to be encrypted with the `--encrypt` flag, for example:
|
docs
|
Update documentation on encryption
|
772211ff20f9cb609cdf1fb196fff23f7b39f94d
|
2021-10-26 04:33:30
|
Tom Payne
|
chore: Minor fixes
| false
|
diff --git a/internal/chezmoi/archivereadersystem.go b/internal/chezmoi/archivereadersystem.go
index bdefbc92da5..b51b9925824 100644
--- a/internal/chezmoi/archivereadersystem.go
+++ b/internal/chezmoi/archivereadersystem.go
@@ -57,7 +57,7 @@ type ArchiveReaderSystemOptions struct {
}
// NewArchiveReaderSystem returns a new ArchiveReaderSystem reading from data
-// and using archiePath as a hint for the archive format.
+// and using archivePath as a hint for the archive format.
func NewArchiveReaderSystem(archivePath string, data []byte, format ArchiveFormat, options ArchiveReaderSystemOptions) (*ArchiveReaderSystem, error) {
s := &ArchiveReaderSystem{
fileInfos: make(map[AbsPath]fs.FileInfo),
diff --git a/internal/cmd/catcmd.go b/internal/cmd/catcmd.go
index f5a03db2824..79582536930 100644
--- a/internal/cmd/catcmd.go
+++ b/internal/cmd/catcmd.go
@@ -54,7 +54,8 @@ func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezm
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
- builder.WriteString(linkname + "\n")
+ builder.WriteString(linkname)
+ builder.WriteByte('\n')
default:
return fmt.Errorf("%s: not a file, script, or symlink", targetRelPath)
}
diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go
index 62dadca615f..f31643dfd41 100644
--- a/internal/cmd/unmanagedcmd.go
+++ b/internal/cmd/unmanagedcmd.go
@@ -36,7 +36,8 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState
_, managed := sourceState.Entry(targeRelPath)
ignored := sourceState.Ignore(targeRelPath)
if !managed && !ignored {
- builder.WriteString(string(targeRelPath) + "\n")
+ builder.WriteString(targeRelPath.String())
+ builder.WriteByte('\n')
}
if info.IsDir() && (!managed || ignored) {
return vfs.SkipDir
|
chore
|
Minor fixes
|
b52704d1b7e74324c2eb5ce21cc5c7210721ca32
|
2024-11-07 23:26:01
|
Tom Payne
|
chore: Tidy up completion test
| false
|
diff --git a/internal/cmd/testdata/scripts/completion.txtar b/internal/cmd/testdata/scripts/completion.txtar
index fa766869e9d..affabeff533 100644
--- a/internal/cmd/testdata/scripts/completion.txtar
+++ b/internal/cmd/testdata/scripts/completion.txtar
@@ -34,14 +34,14 @@ cmp stdout golden/secrets
exec chezmoi __complete apply --exclude=
cmp stdout golden/entry-type-set
-# test that apply --refresh-externals flags are completed
-exec chezmoi __complete apply --refresh-externals=
-cmp stdout golden/refresh-externals
-
-# test that entry type set values are completed
+# test that apply --include values are completed
exec chezmoi __complete apply --include=
cmp stdout golden/entry-type-set
+# test that apply --refresh-externals values are completed
+exec chezmoi __complete apply --refresh-externals=
+cmp stdout golden/refresh-externals
+
# test that archive --format values are completed
exec chezmoi __complete archive --format=
cmp stdout golden/archive-format
|
chore
|
Tidy up completion test
|
c1aeb45fe86431abdf935608b8f4033a5f63d6c7
|
2021-10-28 03:54:24
|
Tom Payne
|
chore: Re-enable gops
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index d410b5091c2..03d44f9d567 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -31,6 +31,7 @@ Manage your dotfiles across multiple machines, securely.
* [Developer command line flags](#developer-command-line-flags)
* [`--cpu-profile` *filename*](#--cpu-profile-filename)
* [`--debug`](#--debug)
+ * [`--gops`](#--gops)
* [Configuration file](#configuration-file)
* [Variables](#variables)
* [Examples](#examples)
@@ -302,6 +303,10 @@ Write a [Go CPU profile](https://blog.golang.org/pprof) to *filename*.
Log information helpful for debugging.
+### `--gops`
+
+Enable the [gops](https://github.com/google/gops) agent.
+
---
## Configuration file
diff --git a/go.mod b/go.mod
index 2a8b4c5c1b4..769fb1ce92e 100644
--- a/go.mod
+++ b/go.mod
@@ -53,6 +53,7 @@ require (
require (
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/godbus/dbus/v5 v5.0.5 // indirect
+ github.com/google/gops v0.3.22 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/shopspring/decimal v1.3.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
diff --git a/go.sum b/go.sum
index 07ac68c5b97..d5143ccdc06 100644
--- a/go.sum
+++ b/go.sum
@@ -74,6 +74,7 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7 h1:DSqTh6nEes/uO8BlNcGk8PzZsxY2sN9ZL//veWBdTRI=
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
+github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
@@ -189,6 +190,8 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
+github.com/go-ole/go-ole v1.2.6-0.20210915003542-8b1f7f90f6b1/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.5 h1:9Eg0XUhQxtkV8ykTMKtMMYY72g4NgxtRq4jgh4Ih5YM=
@@ -253,6 +256,8 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/gops v0.3.22 h1:lyvhDxfPLHAOR2xIYwjPhN387qHxyU21Sk9sz/GhmhQ=
+github.com/google/gops v0.3.22/go.mod h1:7diIdLsqpCihPSX3fQagksT/Ku/y4RL9LHTlKyEUDl8=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -365,6 +370,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kevinburke/ssh_config v1.1.0 h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o=
github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19/go.mod h1:hY+WOq6m2FpbvyrI93sMaypsttvaIL5nhVR92dTMUcQ=
github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
@@ -493,6 +499,7 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
+github.com/shirou/gopsutil/v3 v3.21.9/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9JdiUF9LlKzQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.0 h1:KK3gWIXskZ2O1U/JNTisNcvH+jveJxZYrjbTsrbbnh8=
github.com/shopspring/decimal v1.3.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
@@ -534,6 +541,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
+github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/twpayne/go-shell v0.3.1 h1:JIC6cyDpG/p8mRnFUleH07roi90q0J9QC8PnvtmYLRo=
github.com/twpayne/go-shell v0.3.1/go.mod h1:H/gzux0DOH5jsjQSHXs6rs2Onxy+V4j6ycZTOulC0l8=
github.com/twpayne/go-vfs/v3 v3.0.0 h1:rMFBISZVhSowKeX1BxL8utM64V7CuUw9/rfekPdS7to=
@@ -547,6 +556,7 @@ github.com/twpayne/go-xdg/v6 v6.0.0/go.mod h1:XlfiGBU0iBxudVRWh+SXF+I1Cfb7rMq1IF
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/xanzy/ssh-agent v0.3.1 h1:AmzO1SSWxw73zxFZPRwaMN1MohDw8UyHnmuxyceTEGo=
github.com/xanzy/ssh-agent v0.3.1/go.mod h1:QIE4lCeL7nkC25x+yA3LBIYfwCc1TFziCtG7cBAac6w=
+github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -776,9 +786,11 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1032,6 +1044,7 @@ howett.net/plist v0.0.0-20201203080718-1454fab16a06 h1:QDxUo/w2COstK1wIBYpzQlHX/
howett.net/plist v0.0.0-20201203080718-1454fab16a06/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/goversion v1.2.0/go.mod h1:Eih9y/uIBS3ulggl7KNJ09xGSLcuNaLgmvvqa07sgfo=
rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index fb374784014..5b21e272375 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -27,6 +27,7 @@ import (
"github.com/coreos/go-semver/semver"
gogit "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/format/diff"
+ "github.com/google/gops/agent"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
@@ -84,6 +85,7 @@ type Config struct {
debug bool
dryRun bool
force bool
+ gops bool
homeDir string
keepGoing bool
noPager bool
@@ -580,6 +582,7 @@ func (c *Config) close() error {
err = multierr.Append(err, err2)
}
pprof.StopCPUProfile()
+ agent.Close()
return err
}
@@ -1197,6 +1200,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
persistentFlags.BoolVar(&c.debug, "debug", c.debug, "Include debug information in output")
persistentFlags.BoolVarP(&c.dryRun, "dry-run", "n", c.dryRun, "Do not make any modifications to the destination directory")
persistentFlags.BoolVar(&c.force, "force", c.force, "Make all changes without prompting")
+ persistentFlags.BoolVar(&c.gops, "gops", c.gops, "Enable gops agent")
persistentFlags.BoolVarP(&c.keepGoing, "keep-going", "k", c.keepGoing, "Keep going as far as possible after an error")
persistentFlags.BoolVar(&c.noPager, "no-pager", c.noPager, "Do not use the pager")
persistentFlags.BoolVar(&c.noTTY, "no-tty", c.noTTY, "Do not attempt to get a TTY for reading passwords")
@@ -1210,6 +1214,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
rootCmd.MarkPersistentFlagFilename("cpu-profile"),
persistentFlags.MarkHidden("cpu-profile"),
rootCmd.MarkPersistentFlagDirname("destination"),
+ persistentFlags.MarkHidden("gops"),
rootCmd.MarkPersistentFlagFilename("output"),
persistentFlags.MarkHidden("safe"),
rootCmd.MarkPersistentFlagDirname("source"),
@@ -1378,6 +1383,13 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
}
}
+ // Enable gops if configured.
+ if c.gops {
+ if err := agent.Listen(agent.Options{}); err != nil {
+ return err
+ }
+ }
+
// Read the config file.
if err := c.readConfig(); err != nil {
if !boolAnnotation(cmd, doesNotRequireValidConfig) {
|
chore
|
Re-enable gops
|
b525c5040f115d2718cd24c4b2385a13ff013ca7
|
2022-05-05 05:31:53
|
Tom Payne
|
feat: Add --guess-repo option to init command
| false
|
diff --git a/assets/chezmoi.io/docs/reference/commands/init.md b/assets/chezmoi.io/docs/reference/commands/init.md
index 002d46da3af..c365b521b4f 100644
--- a/assets/chezmoi.io/docs/reference/commands/init.md
+++ b/assets/chezmoi.io/docs/reference/commands/init.md
@@ -1,9 +1,11 @@
# `init` [*repo*]
Setup the source directory, generate the config file, and optionally update the
-destination directory to match the target state. *repo* is expanded to a full
-git repo URL, using HTTPS by default, or SSH if the `--ssh` option is
-specified, according to the following patterns:
+destination directory to match the target state.
+
+By default, if *repo* is given, chezmoi will guess the full git repo URL, using
+HTTPS by default, or SSH if the `--ssh` option is specified, according to the
+following patterns:
| Pattern | HTTPS Repo | SSH repo |
| ------------------ | -------------------------------------- | ---------------------------------- |
@@ -13,6 +15,8 @@ specified, according to the following patterns:
| `~sr.ht/user` | `https://git.sr.ht/~user/dotfiles` | `[email protected]:~user/dotfiles.git` |
| `~sr.ht/user/repo` | `https://git.sr.ht/~user/repo` | `[email protected]:~/user/repo.git` |
+To disable git repo URL guessing pass the `--guess-repo-url=false` option.
+
First, if the source directory is not already contain a repository, then if
*repo* is given it is checked out into the source directory, otherwise a new
repository is initialized in the source directory.
@@ -51,6 +55,10 @@ existing template data.
Clone the repo with depth *depth*.
+## `--guess-repo-url` *bool*
+
+Guess the repo URL from the *repo* argument. This defaults to `true`.
+
## `--one-shot`
`--one-shot` is the equivalent of `--apply`, `--depth=1`, `--force`, `--purge`,
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index e9768cbd340..504f321e440 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -367,8 +367,9 @@ func newConfig(options ...configOption) (*Config, error) {
include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll),
},
init: initCmdConfig{
- data: true,
- exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ data: true,
+ exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
+ guessRepoURL: true,
},
managed: managedCmdConfig{
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
diff --git a/pkg/cmd/initcmd.go b/pkg/cmd/initcmd.go
index a02eb9a2857..393345526f7 100644
--- a/pkg/cmd/initcmd.go
+++ b/pkg/cmd/initcmd.go
@@ -19,16 +19,17 @@ import (
)
type initCmdConfig struct {
- apply bool
- branch string
- configPath chezmoi.AbsPath
- data bool
- depth int
- exclude *chezmoi.EntryTypeSet
- oneShot bool
- purge bool
- purgeBinary bool
- ssh bool
+ apply bool
+ branch string
+ configPath chezmoi.AbsPath
+ data bool
+ depth int
+ exclude *chezmoi.EntryTypeSet
+ guessRepoURL bool
+ oneShot bool
+ purge bool
+ purgeBinary bool
+ ssh bool
}
var dotfilesRepoGuesses = []struct {
@@ -110,14 +111,15 @@ func (c *Config) newInitCmd() *cobra.Command {
flags := initCmd.Flags()
flags.BoolVarP(&c.init.apply, "apply", "a", c.init.apply, "update destination directory")
+ flags.StringVar(&c.init.branch, "branch", c.init.branch, "Set initial branch to checkout")
flags.VarP(&c.init.configPath, "config-path", "C", "Path to write generated config file")
flags.BoolVar(&c.init.data, "data", c.init.data, "Include existing template data")
flags.IntVarP(&c.init.depth, "depth", "d", c.init.depth, "Create a shallow clone")
flags.VarP(c.init.exclude, "exclude", "x", "Exclude entry types")
+ flags.BoolVarP(&c.init.guessRepoURL, "guess-repo-url", "g", c.init.guessRepoURL, "Guess the repo URL")
flags.BoolVar(&c.init.oneShot, "one-shot", c.init.oneShot, "Run in one-shot mode")
flags.BoolVarP(&c.init.purge, "purge", "p", c.init.purge, "Purge config and source directories after running")
flags.BoolVarP(&c.init.purgeBinary, "purge-binary", "P", c.init.purgeBinary, "Purge chezmoi binary after running")
- flags.StringVar(&c.init.branch, "branch", c.init.branch, "Set initial branch to checkout")
flags.BoolVar(&c.init.ssh, "ssh", false, "Use ssh instead of https when guessing dotfile repo URL")
return initCmd
@@ -155,7 +157,12 @@ func (c *Config) runInitCmd(cmd *cobra.Command, args []string) error {
return err
}
} else {
- username, dotfilesRepoURL := guessDotfilesRepoURL(args[0], c.init.ssh)
+ var username, dotfilesRepoURL string
+ if c.init.guessRepoURL {
+ username, dotfilesRepoURL = guessDotfilesRepoURL(args[0], c.init.ssh)
+ } else {
+ dotfilesRepoURL = args[0]
+ }
if useBuiltinGit {
if err := c.builtinGitClone(username, dotfilesRepoURL, workingTreeRawPath); err != nil {
return err
|
feat
|
Add --guess-repo option to init command
|
61ba75219b20ac85b8c23a8b2b35dc66d5baf175
|
2021-12-16 01:36:04
|
Tom Payne
|
chore: Add test infrastructure to filter on Go version
| false
|
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go
index b1971309597..2668b81e9be 100644
--- a/internal/cmd/main_test.go
+++ b/internal/cmd/main_test.go
@@ -19,6 +19,7 @@ import (
"testing"
"time"
+ "github.com/coreos/go-semver/semver"
"github.com/rogpeppe/go-internal/imports"
"github.com/rogpeppe/go-internal/testscript"
"github.com/twpayne/go-vfs/v4"
@@ -30,6 +31,7 @@ import (
var (
envConditionRx = regexp.MustCompile(`\Aenv:(\w+)\z`)
+ goConditionRx = regexp.MustCompile(`\Ago:(\d+)\.(\d+)(?:\.(\d+))?\z`)
umaskConditionRx = regexp.MustCompile(`\Aumask:([0-7]{3})\z`)
)
@@ -69,6 +71,9 @@ func TestScript(t *testing.T) {
"unix2dos": cmdUNIX2DOS,
},
Condition: func(cond string) (bool, error) {
+ if result, valid := goCondition(cond); valid {
+ return result, nil
+ }
if result, valid := goosCondition(cond); valid {
return result, nil
}
@@ -520,6 +525,27 @@ func cmdUNIX2DOS(ts *testscript.TestScript, neg bool, args []string) {
}
}
+// goCondition evaluates cond as a Go version.
+func goCondition(cond string) (result, value bool) {
+ m := goConditionRx.FindStringSubmatch(cond)
+ if m == nil {
+ return false, false
+ }
+ major, _ := strconv.ParseInt(m[1], 10, 64)
+ minor, _ := strconv.ParseInt(m[2], 10, 64)
+ patch, _ := strconv.ParseInt(m[3], 10, 64)
+ minVersion := &semver.Version{
+ Major: major,
+ Minor: minor,
+ Patch: patch,
+ }
+ goVersion, err := cmd.ParseGoVersion(runtime.Version())
+ if err != nil {
+ return true, true
+ }
+ return !goVersion.LessThan(*minVersion), true
+}
+
// goosCondition evaluates cond as a logical OR of GOARCHes or GOOSes enclosed
// in parentheses, returning true if any of them match.
func goosCondition(cond string) (result, valid bool) {
diff --git a/internal/cmd/util.go b/internal/cmd/util.go
index 6cf15eef5ec..365ef8fe335 100644
--- a/internal/cmd/util.go
+++ b/internal/cmd/util.go
@@ -6,15 +6,19 @@ import (
"net/http"
"os"
"regexp"
+ "runtime"
"strconv"
"strings"
"unicode"
+ "github.com/coreos/go-semver/semver"
"github.com/google/go-github/v41/github"
"golang.org/x/oauth2"
)
var (
+ goVersionRx = regexp.MustCompile(`\Ago(\d+)(?:\.(\d+)(?:\.(\d+))?)?\z`)
+
wellKnownAbbreviations = map[string]struct{}{
"ANSI": {},
"CPE": {},
@@ -30,6 +34,21 @@ var (
}
)
+func ParseGoVersion(goVersion string) (*semver.Version, error) {
+ m := goVersionRx.FindStringSubmatch(goVersion)
+ if m == nil {
+ return nil, fmt.Errorf("%s: invalid Go version", goVersion)
+ }
+ major, _ := strconv.ParseInt(m[1], 10, 64)
+ minor, _ := strconv.ParseInt(m[2], 10, 64)
+ patch, _ := strconv.ParseInt(m[3], 10, 64)
+ return &semver.Version{
+ Major: major,
+ Minor: minor,
+ Patch: patch,
+ }, nil
+}
+
// englishList returns ss formatted as a list, including an Oxford comma.
func englishList(ss []string) string {
switch n := len(ss); n {
@@ -72,6 +91,14 @@ func firstNonEmptyString(ss ...string) string {
return ""
}
+func goVersionAtLeast(minVersion *semver.Version) bool {
+ goVersion, err := ParseGoVersion(runtime.Version())
+ if err != nil {
+ return true
+ }
+ return !goVersion.LessThan(*minVersion)
+}
+
// newGitHubClient returns a new github.Client configured with an access token
// and a http client, if available.
func newGitHubClient(ctx context.Context, httpClient *http.Client) *github.Client {
diff --git a/internal/cmd/util_test.go b/internal/cmd/util_test.go
index 8e0379dd93e..36621f96e4b 100644
--- a/internal/cmd/util_test.go
+++ b/internal/cmd/util_test.go
@@ -4,6 +4,7 @@ import (
"strings"
"testing"
+ "github.com/coreos/go-semver/semver"
"github.com/stretchr/testify/assert"
)
@@ -110,6 +111,28 @@ func TestEnglishListWithNoun(t *testing.T) {
}
}
+func TestParseGoVersion(t *testing.T) {
+ for _, tc := range []struct {
+ goVersion string
+ expected *semver.Version
+ }{
+ {
+ goVersion: "go1.17",
+ expected: semver.Must(semver.NewVersion("1.17.0")),
+ },
+ {
+ goVersion: "go1.17.5",
+ expected: semver.Must(semver.NewVersion("1.17.5")),
+ },
+ } {
+ t.Run(tc.goVersion, func(t *testing.T) {
+ actual, err := ParseGoVersion(tc.goVersion)
+ assert.NoError(t, err)
+ assert.Equal(t, tc.expected, actual)
+ })
+ }
+}
+
func TestUniqueAbbreviations(t *testing.T) {
for _, tc := range []struct {
values []string
|
chore
|
Add test infrastructure to filter on Go version
|
251d78bfdc45fe8b67212ee9762c0ebbcd21ded2
|
2021-11-12 04:18:50
|
Tom Payne
|
chore: Reduce severity of missing age or gpg in doctor command
| false
|
diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go
index 6e8afdca468..7e5f5b76285 100644
--- a/internal/cmd/doctorcmd.go
+++ b/internal/cmd/doctorcmd.go
@@ -193,6 +193,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
versionArgs: []string{"-version"},
versionRx: regexp.MustCompile(`v(\d+\.\d+\.\d+\S*)`),
ifNotSet: checkResultWarning,
+ ifNotExist: checkResultInfo,
},
&binaryCheck{
name: "gpg-command",
@@ -200,6 +201,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
versionArgs: []string{"--version"},
versionRx: regexp.MustCompile(`(?m)^gpg\s+\(.*?\)\s+(\d+\.\d+\.\d+)`),
ifNotSet: checkResultWarning,
+ ifNotExist: checkResultInfo,
},
&binaryCheck{
name: "pinentry-command",
|
chore
|
Reduce severity of missing age or gpg in doctor command
|
da407b600f2e74907aa422ba2a55c31672521d7e
|
2022-09-24 22:25:30
|
Tom Payne
|
fix: Avoid double read of source state in merge-all and status commands
| false
|
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index 98883385066..16f895cb453 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -190,6 +190,8 @@ type Config struct {
// Computed configuration.
homeDirAbsPath chezmoi.AbsPath
encryption chezmoi.Encryption
+ sourceState *chezmoi.SourceState
+ sourceStateErr error
stdin io.Reader
stdout io.Writer
@@ -490,7 +492,7 @@ func (c *Config) applyArgs(
}
}
- sourceState, err := c.newSourceState(ctx)
+ sourceState, err := c.getSourceState(ctx)
if err != nil {
return err
}
@@ -1226,6 +1228,14 @@ func (c *Config) getHTTPClient() (*http.Client, error) {
return c.httpClient, nil
}
+func (c *Config) getSourceState(ctx context.Context) (*chezmoi.SourceState, error) {
+ if c.sourceState != nil || c.sourceStateErr != nil {
+ return c.sourceState, c.sourceStateErr
+ }
+ c.sourceState, c.sourceStateErr = c.newSourceState(ctx)
+ return c.sourceState, c.sourceStateErr
+}
+
// gitAutoAdd adds all changes to the git index and returns the new git status.
func (c *Config) gitAutoAdd() (*git.Status, error) {
if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, []string{"add", "."}); err != nil {
@@ -1273,7 +1283,7 @@ func (c *Config) makeRunEWithSourceState(
runE func(*cobra.Command, []string, *chezmoi.SourceState) error,
) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
- sourceState, err := c.newSourceState(cmd.Context())
+ sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
return err
}
@@ -1442,7 +1452,7 @@ func (c *Config) newSourceState(
return nil, err
}
- s := chezmoi.NewSourceState(append([]chezmoi.SourceStateOption{
+ sourceState := chezmoi.NewSourceState(append([]chezmoi.SourceStateOption{
chezmoi.WithBaseSystem(c.baseSystem),
chezmoi.WithCacheDir(c.CacheDirAbsPath),
chezmoi.WithDefaultTemplateDataFunc(c.defaultTemplateData),
@@ -1460,14 +1470,14 @@ func (c *Config) newSourceState(
chezmoi.WithVersion(c.version),
}, options...)...)
- if err := s.Read(ctx, &chezmoi.ReadOptions{
+ if err := sourceState.Read(ctx, &chezmoi.ReadOptions{
RefreshExternals: c.refreshExternals,
ReadHTTPResponse: c.readHTTPResponse,
}); err != nil {
return nil, err
}
- return s, nil
+ return sourceState, nil
}
// persistentPostRunRootE performs post-run actions for the root command.
@@ -2042,7 +2052,7 @@ func (c *Config) targetValidArgs(
return nil, cobra.ShellCompDirectiveError
}
- sourceState, err := c.newSourceState(cmd.Context())
+ sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
cobra.CompErrorln(err.Error())
return nil, cobra.ShellCompDirectiveError
diff --git a/pkg/cmd/editcmd.go b/pkg/cmd/editcmd.go
index 2a3b1354bf8..7454d8731ce 100644
--- a/pkg/cmd/editcmd.go
+++ b/pkg/cmd/editcmd.go
@@ -30,7 +30,7 @@ func (c *Config) newEditCmd() *cobra.Command {
Long: mustLongHelp("edit"),
Example: example("edit"),
ValidArgsFunction: c.targetValidArgs,
- RunE: c.makeRunEWithSourceState(c.runEditCmd),
+ RunE: c.runEditCmd,
Annotations: map[string]string{
modifiesDestinationDirectory: "true",
modifiesSourceDirectory: "true",
@@ -51,7 +51,7 @@ func (c *Config) newEditCmd() *cobra.Command {
return editCmd
}
-func (c *Config) runEditCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
+func (c *Config) runEditCmd(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
if err := c.runEditor([]string{c.WorkingTreeAbsPath.String()}); err != nil {
return err
@@ -70,6 +70,11 @@ func (c *Config) runEditCmd(cmd *cobra.Command, args []string, sourceState *chez
return nil
}
+ sourceState, err := c.newSourceState(cmd.Context())
+ if err != nil {
+ return err
+ }
+
targetRelPaths, err := c.targetRelPaths(sourceState, args, targetRelPathsOptions{
mustBeInSourceState: true,
})
diff --git a/pkg/cmd/mergeallcmd.go b/pkg/cmd/mergeallcmd.go
index 1990d66f516..aa383e7929e 100644
--- a/pkg/cmd/mergeallcmd.go
+++ b/pkg/cmd/mergeallcmd.go
@@ -17,7 +17,7 @@ func (c *Config) newMergeAllCmd() *cobra.Command {
Short: "Perform a three-way merge for each modified file",
Long: mustLongHelp("merge-all"),
Example: example("merge-all"),
- RunE: c.makeRunEWithSourceState(c.runMergeAllCmd),
+ RunE: c.runMergeAllCmd,
Annotations: map[string]string{
modifiesSourceDirectory: "true",
requiresSourceDirectory: "true",
@@ -31,7 +31,7 @@ func (c *Config) newMergeAllCmd() *cobra.Command {
return mergeAllCmd
}
-func (c *Config) runMergeAllCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
+func (c *Config) runMergeAllCmd(cmd *cobra.Command, args []string) error {
var targetRelPaths []chezmoi.RelPath
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
preApplyFunc := func(
@@ -52,6 +52,11 @@ func (c *Config) runMergeAllCmd(cmd *cobra.Command, args []string, sourceState *
return err
}
+ sourceState, err := c.getSourceState(cmd.Context())
+ if err != nil {
+ return err
+ }
+
for _, targetRelPath := range targetRelPaths {
sourceStateEntry := sourceState.MustEntry(targetRelPath)
if err := c.doMerge(targetRelPath, sourceStateEntry); err != nil {
diff --git a/pkg/cmd/sourcepathcmd.go b/pkg/cmd/sourcepathcmd.go
index ca82a21dcf3..49a3d3a9d2b 100644
--- a/pkg/cmd/sourcepathcmd.go
+++ b/pkg/cmd/sourcepathcmd.go
@@ -29,7 +29,7 @@ func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string) error {
return c.writeOutputString(sourceDirAbsPath.String() + "\n")
}
- sourceState, err := c.newSourceState(cmd.Context())
+ sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
return err
}
diff --git a/pkg/cmd/statuscmd.go b/pkg/cmd/statuscmd.go
index fa23d0df98a..67599be618a 100644
--- a/pkg/cmd/statuscmd.go
+++ b/pkg/cmd/statuscmd.go
@@ -23,7 +23,7 @@ func (c *Config) newStatusCmd() *cobra.Command {
Long: mustLongHelp("status"),
Example: example("status"),
ValidArgsFunction: c.targetValidArgs,
- RunE: c.makeRunEWithSourceState(c.runStatusCmd),
+ RunE: c.runStatusCmd,
Annotations: map[string]string{
modifiesDestinationDirectory: "true",
persistentStateMode: persistentStateModeReadMockWrite,
@@ -40,7 +40,7 @@ func (c *Config) newStatusCmd() *cobra.Command {
return statusCmd
}
-func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
+func (c *Config) runStatusCmd(cmd *cobra.Command, args []string) error {
builder := strings.Builder{}
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
preApplyFunc := func(
|
fix
|
Avoid double read of source state in merge-all and status commands
|
dc97563a557485badf58beb9849f0c32f80a4f35
|
2025-03-12 22:54:48
|
Jan-Peter Alten
|
fix: Doc on declaratve package installation
| false
|
diff --git a/assets/chezmoi.io/docs/user-guide/advanced/install-packages-declaratively.md b/assets/chezmoi.io/docs/user-guide/advanced/install-packages-declaratively.md
index df841d0e150..cecab9f84e5 100644
--- a/assets/chezmoi.io/docs/user-guide/advanced/install-packages-declaratively.md
+++ b/assets/chezmoi.io/docs/user-guide/advanced/install-packages-declaratively.md
@@ -27,7 +27,7 @@ the package manager to install those packages, for example:
{{ if eq .chezmoi.os "darwin" -}}
#!/bin/bash
-brew bundle --no-lock --file=/dev/stdin <<EOF
+brew bundle --file=/dev/stdin <<EOF
{{ range .packages.darwin.brews -}}
brew {{ . | quote }}
{{ end -}}
|
fix
|
Doc on declaratve package installation
|
bb4837b99677f52b043d069fc071342995f4d8b5
|
2023-01-12 05:26:24
|
Tom Payne
|
chore: Remove dependency on tparse
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a960822932e..31daff27b7f 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -14,7 +14,6 @@ env:
GOFUMPT_VERSION: 0.4.0
GOLANGCI_LINT_VERSION: 1.50.1
GOVERSIONINFO_VERSION: 1.4.0
- TPARSE_VERSION: 0.11.1
jobs:
changes:
runs-on: ubuntu-20.04
@@ -263,23 +262,18 @@ jobs:
- name: run
run: |
go run . --version
- - name: install-tparse
- run: |
- curl -fsLO https://github.com/mfridman/tparse/releases/download/v${TPARSE_VERSION}/tparse_linux_x86_64
- chmod a+x tparse_linux_x86_64
- sudo mv tparse_linux_x86_64 /usr/local/bin/tparse
- name: test-umask-022
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
- go test -cover -json -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o022" -race ./... | tparse
+ go test -cover -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o022" -race ./...
- name: test-umask-002
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
- go test -cover -json -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o002" -race ./... | tparse
+ go test -cover -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o002" -race ./...
- name: test-install.sh
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
run: |
|
chore
|
Remove dependency on tparse
|
eecf01556642c0b63d01792d75408685f6f545ec
|
2023-10-09 04:02:09
|
Tom Payne
|
fix: Only invoke diff pager if command modifies filesystem
| false
|
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index ae8d1f115f2..ba5287994b7 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -1992,7 +1992,9 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
c.sourceSystem = chezmoi.NewDryRunSystem(c.sourceSystem)
c.destSystem = chezmoi.NewDryRunSystem(c.destSystem)
}
- if c.Verbose || annotations.hasTag(outputsDiff) {
+ if annotations.hasTag(outputsDiff) ||
+ c.Verbose &&
+ (annotations.hasTag(modifiesDestinationDirectory) || annotations.hasTag(modifiesSourceDirectory)) {
// If the user has configured a diff pager, then start it as a process.
// Otherwise, write the diff output directly to stdout.
var writer io.Writer
diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go
index 83bee626434..3dd4aeac2a3 100644
--- a/internal/cmd/statuscmd.go
+++ b/internal/cmd/statuscmd.go
@@ -28,7 +28,6 @@ func (c *Config) newStatusCmd() *cobra.Command {
RunE: c.runStatusCmd,
Annotations: newAnnotations(
dryRun,
- modifiesDestinationDirectory,
persistentStateModeReadMockWrite,
requiresSourceDirectory,
),
diff --git a/internal/cmd/testdata/scripts/issue3257.txtar b/internal/cmd/testdata/scripts/issue3257.txtar
new file mode 100644
index 00000000000..a0baeec2278
--- /dev/null
+++ b/internal/cmd/testdata/scripts/issue3257.txtar
@@ -0,0 +1,26 @@
+[windows] skip 'UNIX only'
+
+chmod 755 bin/custom-pager
+
+# test that chezmoi add invokes the pager when verbose is set
+exec chezmoi add $HOME${/}.file
+stdout custom-pager
+
+# test chat chezmoi chattr invokes the pager when verbose is set
+exec chezmoi chattr +private $HOME${/}.file
+stdout custom-pager
+
+# test that chezmoi status does not invoke the pager when verbose is set
+exec chezmoi status
+! stdout custom-pager
+
+-- bin/custom-pager --
+#!/bin/sh
+
+echo custom-pager
+-- home/user/.config/chezmoi/chezmoi.yaml --
+pager: custom-pager
+verbose: true
+-- home/user/.file --
+# contents of .file
+-- home/user/.local/share/chezmoi/.keep --
|
fix
|
Only invoke diff pager if command modifies filesystem
|
94a27eed984a72c95103df49733c957242528e4f
|
2024-09-09 16:28:28
|
Tom Payne
|
chore: Use simple framework for mock password managers
| false
|
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go
index 3f5bef893b9..3f3861755f4 100644
--- a/internal/cmd/main_test.go
+++ b/internal/cmd/main_test.go
@@ -3,6 +3,7 @@ package cmd_test
import (
"bufio"
"bytes"
+ _ "embed"
"errors"
"fmt"
"io/fs"
@@ -17,6 +18,7 @@ import (
"strconv"
"strings"
"testing"
+ "text/template"
"time"
"github.com/rogpeppe/go-internal/imports"
@@ -34,6 +36,12 @@ var (
envVarRx = regexp.MustCompile(`\$\w+`)
lookupRx = regexp.MustCompile(`\Alookup:(.*)\z`)
umaskConditionRx = regexp.MustCompile(`\Aumask:([0-7]{3})\z`)
+
+ //go:embed mockcommand.tmpl
+ mockcommandTmplText string
+
+ //go:embed mockcommand.cmd.tmpl
+ mockcommandCmdTmplText string
)
func TestMain(m *testing.M) {
@@ -68,6 +76,7 @@ func TestScript(t *testing.T) {
"mkgpgconfig": cmdMkGPGConfig,
"mkhomedir": cmdMkHomeDir,
"mksourcedir": cmdMkSourceDir,
+ "mockcommand": cmdMockCommand,
"prependline": cmdPrependLine,
"readlink": cmdReadLink,
"removeline": cmdRemoveLine,
@@ -491,6 +500,117 @@ func cmdMkSourceDir(ts *testscript.TestScript, neg bool, args []string) {
}
}
+// cmdMockCommand creates a mock command from a definition.
+func cmdMockCommand(ts *testscript.TestScript, neg bool, args []string) {
+ if neg {
+ ts.Fatalf("unsupported: ! mockcommand")
+ }
+ if len(args) != 1 {
+ ts.Fatalf("usage: mockcommand command")
+ }
+
+ command := ts.MkAbs(args[0])
+ definitionYAML, err := os.ReadFile(command + ".yaml")
+ ts.Check(err)
+
+ // Parse the definition.
+ type response struct {
+ Args string `yaml:"args"`
+ OrArgs []string `yaml:"orArgs"`
+ WindowsArgs string `yaml:"windowsArgs"`
+ Response string `yaml:"response"`
+ Destination string `yaml:"destination"`
+ EscapeChars bool `yaml:"escapeChars"`
+ SuppressLastNewline bool `yaml:"suppressLastNewline"`
+ ExitCode int `yaml:"exitCode"`
+ }
+ var definition struct {
+ Responses []response `yaml:"responses"`
+ Default response `yaml:"default"`
+ }
+ ts.Check(chezmoi.FormatYAML.Unmarshal(definitionYAML, &definition))
+
+ // Parse the mock command template.
+ var templateName, templateText string
+ var renderResponseFunc func(response) string
+ switch runtime.GOOS {
+ case "windows":
+ templateName = "mockcommand.cmd.tmpl"
+ templateText = mockcommandCmdTmplText
+ escapeCharsRx := regexp.MustCompile(`[\\&|><^]`)
+ escapeChars := func(s string) string {
+ return escapeCharsRx.ReplaceAllString(s, "^$0")
+ }
+ renderResponseFunc = func(r response) string {
+ var builder strings.Builder
+ var redirect string
+ if r.Destination == "stderr" {
+ redirect = " 1>&2"
+ }
+ lines := strings.Split(strings.TrimSuffix(r.Response, "\n"), "\n")
+ for i, line := range lines {
+ if r.EscapeChars {
+ line = escapeChars(line)
+ }
+ if r.SuppressLastNewline && i == len(lines)-1 {
+ fmt.Fprintf(&builder, " echo | set /p=%s%s\n", line, redirect)
+ } else {
+ fmt.Fprintf(&builder, " echo.%s%s\n", line, redirect)
+ }
+ }
+ fmt.Fprintf(&builder, " exit /b %d", r.ExitCode)
+ return builder.String()
+ }
+ default:
+ templateName = "mockcommand.tmpl"
+ templateText = mockcommandTmplText
+ renderResponseFunc = func(r response) string {
+ var builder strings.Builder
+ var redirect string
+ if r.Destination == "stderr" {
+ redirect = " 1>&2"
+ }
+ if strings.Contains(r.Response, "\n") {
+ fmt.Fprintf(&builder, " cat%s <<EOF\n%sEOF\n", redirect, r.Response)
+ } else {
+ fmt.Fprintf(&builder, " echo %q%s\n", r.Response, redirect)
+ }
+ fmt.Fprintf(&builder, " exit %d", r.ExitCode)
+ return builder.String()
+ }
+ }
+ tmpl, err := template.New(templateName).Funcs(template.FuncMap{
+ "default": func(def, s string) string {
+ if s == "" {
+ return def
+ }
+ return s
+ },
+ "quote": strconv.Quote,
+ "renderResponse": renderResponseFunc,
+ "replaceAll": func(old, new, s string) string { //nolint:predeclared
+ return strings.ReplaceAll(s, old, new)
+ },
+ }).Parse(templateText)
+ ts.Check(err)
+
+ // Create the mock command contents.
+ buffer := bytes.NewBuffer(make([]byte, 0, 1024))
+ ts.Check(tmpl.Execute(buffer, definition))
+ data := buffer.Bytes()
+ if runtime.GOOS == "windows" {
+ data = bytes.ReplaceAll(data, []byte("\n"), []byte("\r\n"))
+ }
+
+ // Write the mock command.
+ switch runtime.GOOS {
+ case "windows":
+ ts.Check(os.WriteFile(ts.MkAbs(command+".cmd"), data, 0o666))
+ default:
+ ts.Check(os.WriteFile(ts.MkAbs(command), data, 0o777))
+ }
+}
+
// cmdPrependLine prepends lines to a file.
func cmdPrependLine(ts *testscript.TestScript, neg bool, args []string) {
if neg {
diff --git a/internal/cmd/mockcommand.cmd.tmpl b/internal/cmd/mockcommand.cmd.tmpl
new file mode 100644
index 00000000000..3dfa1d1623f
--- /dev/null
+++ b/internal/cmd/mockcommand.cmd.tmpl
@@ -0,0 +1,12 @@
+@echo off
+{{ range $index, $response := .Responses }}
+{{ if $index }}) ELSE {{ end }}IF "%*" == {{ $response.WindowsArgs | default $response.Args | quote }} (
+{{ $response | renderResponse }}
+{{ range $_, $arg := $response.OrArgs }}
+) ELSE IF "%*" == {{ $arg | quote }} (
+{{ $response | renderResponse }}
+{{ end }}
+{{- end }}
+) ELSE (
+{{ .Default | renderResponse | replaceAll "$*" "%*" }}
+)
diff --git a/internal/cmd/mockcommand.tmpl b/internal/cmd/mockcommand.tmpl
new file mode 100644
index 00000000000..6689a1bc091
--- /dev/null
+++ b/internal/cmd/mockcommand.tmpl
@@ -0,0 +1,12 @@
+#!/bin/sh
+{{ range $index, $response := .Responses }}
+{{ if $index }}elif{{ else }}if{{ end }} [ "$*" = {{ $response.Args | quote }} ]; then
+{{ $response | renderResponse }}
+{{ range $_, $arg := .OrArgs }}
+elif [ "$*" = {{ $arg | quote }} ]; then
+{{ $response | renderResponse }}
+{{ end }}
+{{- end }}
+else
+{{ .Default | renderResponse }}
+fi
diff --git a/internal/cmd/testdata/scripts/bitwarden.txtar b/internal/cmd/testdata/scripts/bitwarden.txtar
index d9cfd78c8f9..31326ad0ea0 100644
--- a/internal/cmd/testdata/scripts/bitwarden.txtar
+++ b/internal/cmd/testdata/scripts/bitwarden.txtar
@@ -1,7 +1,5 @@
-[unix] chmod 755 bin/bw
-[unix] chmod 755 bin/bws
-[windows] unix2dos bin/bw.cmd
-[windows] unix2dos bin/bws.cmd
+mockcommand bin/bw
+mockcommand bin/bws
[windows] unix2dos golden/bitwarden-attachment
# test bitwarden template function
@@ -24,139 +22,65 @@ cmp stdout golden/bitwarden-attachment
exec chezmoi execute-template '{{ (bitwardenSecrets "be8e0ad8-d545-4017-a55a-b02f014d4158" "0.48c78342-1635-48a6-accd-afbe01336365.C0tMmQqHnAp1h0gL8bngprlPOYutt0:B3h5D+YgLvFiQhWkIq6Bow==").value }}'
stdout '^0\.982492bc-7f37-4475-9e60$'
--- bin/bw --
-#!/bin/sh
-
-case "$*" in
-"get item example.com")
- cat <<EOF
-{
- "object": "item",
- "id": "bf22e4b4-ae4a-4d1c-8c98-ac620004b628",
- "organizationId": null,
- "folderId": null,
- "type": 1,
- "name": "example.com",
- "notes": null,
- "favorite": false,
- "fields": [
+-- bin/bw.yaml --
+responses:
+- args: 'get item example.com'
+ response: |
{
- "name": "Text",
- "value": "text-value",
- "type": 0
- },
+ "object": "item",
+ "id": "bf22e4b4-ae4a-4d1c-8c98-ac620004b628",
+ "organizationId": null,
+ "folderId": null,
+ "type": 1,
+ "name": "example.com",
+ "notes": null,
+ "favorite": false,
+ "fields": [
+ {
+ "name": "Text",
+ "value": "text-value",
+ "type": 0
+ },
+ {
+ "name": "Hidden",
+ "value": "hidden-value",
+ "type": 1
+ }
+ ],
+ "login": {
+ "username": "username-value",
+ "password": "password-value",
+ "totp": null,
+ "passwordRevisionDate": null
+ },
+ "collectionIds": [],
+ "revisionDate": "2020-10-28T00:21:02.690Z"
+ }
+- args: 'get attachment filename --itemid item-id --raw'
+ response: 'hidden-file-value'
+- args: 'get attachment filename --itemid bf22e4b4-ae4a-4d1c-8c98-ac620004b628 --raw'
+ response: 'hidden-file-value'
+default:
+ response: |
+ Invalid command: $*
+ See --help for a list of available commands.
+ exitCode: 1
+-- bin/bws.yaml --
+responses:
+- args: 'secret get be8e0ad8-d545-4017-a55a-b02f014d4158 --access-token 0.48c78342-1635-48a6-accd-afbe01336365.C0tMmQqHnAp1h0gL8bngprlPOYutt0:B3h5D+YgLvFiQhWkIq6Bow=='
+ response: |
{
- "name": "Hidden",
- "value": "hidden-value",
- "type": 1
+ "object": "secret",
+ "id": "be8e0ad8-d545-4017-a55a-b02f014d4158",
+ "organizationId": "10e8cbfa-7bd2-4361-bd6f-b02e013f9c41",
+ "projectId": "e325ea69-a3ab-4dff-836f-b02e013fe530",
+ "key": "SES_KEY",
+ "value": "0.982492bc-7f37-4475-9e60",
+ "note": "",
+ "creationDate": "2023-06-28T20:13:20.643567Z",
+ "revisionDate": "2023-06-28T20:13:20.643567Z"
}
- ],
- "login": {
- "username": "username-value",
- "password": "password-value",
- "totp": null,
- "passwordRevisionDate": null
- },
- "collectionIds": [],
- "revisionDate": "2020-10-28T00:21:02.690Z"
-}
-EOF
- ;;
-"get attachment filename --itemid item-id --raw")
- cat <<EOF
-hidden-file-value
-EOF
- ;;
-"get attachment filename --itemid bf22e4b4-ae4a-4d1c-8c98-ac620004b628 --raw")
- cat <<EOF
-hidden-file-value
-EOF
- ;;
-*)
- echo "Invalid command: $*"
- echo "See --help for a list of available commands."
- exit 1
-esac
--- bin/bw.cmd --
-@echo off
-IF "%*" == "get item example.com" (
- echo.{
- echo. "object": "item",
- echo. "id": "bf22e4b4-ae4a-4d1c-8c98-ac620004b628",
- echo. "organizationId": null,
- echo. "folderId": null,
- echo. "type": 1,
- echo. "name": "example.com",
- echo. "notes": null,
- echo. "favorite": false,
- echo. "fields": [
- echo. {
- echo. "name": "Text",
- echo. "value": "text-value",
- echo. "type": 0
- echo. },
- echo. {
- echo. "name": "Hidden",
- echo. "value": "hidden-value",
- echo. "type": 1
- echo. }
- echo. ],
- echo. "login": {
- echo. "username": "username-value",
- echo. "password": "password-value",
- echo. "totp": null,
- echo. "passwordRevisionDate": null
- echo. },
- echo. "collectionIds": [],
- echo. "revisionDate": "2020-10-28T00:21:02.690Z"
- echo.}
-) ELSE IF "%*" == "get attachment filename --itemid item-id --raw" (
- echo.hidden-file-value
-) ELSE IF "%*" == "get attachment filename --itemid bf22e4b4-ae4a-4d1c-8c98-ac620004b628 --raw" (
- echo.hidden-file-value
-) ELSE (
- echo Invalid command: $*
- echo "See --help for a list of available commands."
- exit /b 1
-)
--- bin/bws --
-#!/bin/sh
-
-case "$*" in
-"secret get be8e0ad8-d545-4017-a55a-b02f014d4158 --access-token 0.48c78342-1635-48a6-accd-afbe01336365.C0tMmQqHnAp1h0gL8bngprlPOYutt0:B3h5D+YgLvFiQhWkIq6Bow==")
- cat <<EOF
-{
- "object": "secret",
- "id": "be8e0ad8-d545-4017-a55a-b02f014d4158",
- "organizationId": "10e8cbfa-7bd2-4361-bd6f-b02e013f9c41",
- "projectId": "e325ea69-a3ab-4dff-836f-b02e013fe530",
- "key": "SES_KEY",
- "value": "0.982492bc-7f37-4475-9e60",
- "note": "",
- "creationDate": "2023-06-28T20:13:20.643567Z",
- "revisionDate": "2023-06-28T20:13:20.643567Z"
-}
-EOF
- ;;
-*)
- exit 1
-esac
--- bin/bws.cmd --
-@echo off
-IF "%*" == "secret get be8e0ad8-d545-4017-a55a-b02f014d4158 --access-token 0.48c78342-1635-48a6-accd-afbe01336365.C0tMmQqHnAp1h0gL8bngprlPOYutt0:B3h5D+YgLvFiQhWkIq6Bow==" (
- echo.{
- echo. "object": "secret",
- echo. "id": "be8e0ad8-d545-4017-a55a-b02f014d4158",
- echo. "organizationId": "10e8cbfa-7bd2-4361-bd6f-b02e013f9c41",
- echo. "projectId": "e325ea69-a3ab-4dff-836f-b02e013fe530",
- echo. "key": "SES_KEY",
- echo. "value": "0.982492bc-7f37-4475-9e60",
- echo. "note": "",
- echo. "creationDate": "2023-06-28T20:13:20.643567Z",
- echo. "revisionDate": "2023-06-28T20:13:20.643567Z"
- echo.}
-) ELSE (
- exit /b 1
-)
+default:
+ exitCode: 1
-- golden/bitwarden-attachment --
hidden-file-value
diff --git a/internal/cmd/testdata/scripts/dashlane.txtar b/internal/cmd/testdata/scripts/dashlane.txtar
index 891ac6656aa..04a859fbc4a 100644
--- a/internal/cmd/testdata/scripts/dashlane.txtar
+++ b/internal/cmd/testdata/scripts/dashlane.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/dcli
-[windows] unix2dos bin/dcli.cmd
+mockcommand bin/dcli
[windows] unix2dos golden/dashlane-note
# test dashlanePassword template function
@@ -10,75 +9,37 @@ stdout ^<password>$
exec chezmoi execute-template '{{ dashlaneNote "filter" }}'
cmp stdout golden/dashlane-note
--- bin/dcli --
-#!/bin/sh
-
-case "$*" in
-"password --output json filter")
- cat <<EOF
-[
- {
- "title": "<name of the entry>",
- "useFixedUrl": false,
- "login": "<login>",
- "status": "ACCOUNT_NOT_VERIFIED",
- "note": "<any note>",
- "autoLogin": false,
- "modificationDatetime": "<timestamp>",
- "checked": false,
- "id": "<id>",
- "anonId": "<anonymous id>",
- "localeFormat": "UNIVERSAL",
- "password": "<password>",
- "creationDatetime": "<timestamp>",
- "userModificationDatetime": "<timestamp>",
- "lastBackupTime": "<timestamp>",
- "autoProtected": false,
- "strength": 0,
- "subdomainOnly": false
- }
-]
-EOF
- ;;
-"note filter")
- cat <<EOF
-<note>
-EOF
- ;;
-*)
- echo "error: unknown command '$*'"
- exit 1
-esac
--- bin/dcli.cmd --
-@echo off
-IF "%*" == "password --output json filter" (
- echo.[
- echo. {
- echo. "title": "<name of the entry>",
- echo. "useFixedUrl": false,
- echo. "login": "<login>",
- echo. "status": "ACCOUNT_NOT_VERIFIED",
- echo. "note": "<any note>",
- echo. "autoLogin": false,
- echo. "modificationDatetime": "<timestamp>",
- echo. "checked": false,
- echo. "id": "<id>",
- echo. "anonId": "<anonymous id>",
- echo. "localeFormat": "UNIVERSAL",
- echo. "password": "<password>",
- echo. "creationDatetime": "<timestamp>",
- echo. "userModificationDatetime": "<timestamp>",
- echo. "lastBackupTime": "<timestamp>",
- echo. "autoProtected": false,
- echo. "strength": 0,
- echo. "subdomainOnly": false
- echo. }
- echo.]
-) ELSE IF "%*" == "note filter" (
- echo.^<note^>
-) ELSE (
- echo error: unknown command '$*'
- exit /b 1
-)
+-- bin/dcli.yaml --
+responses:
+- args: 'password --output json filter'
+ response: |
+ [
+ {
+ "title": "<name of the entry>",
+ "useFixedUrl": false,
+ "login": "<login>",
+ "status": "ACCOUNT_NOT_VERIFIED",
+ "note": "<any note>",
+ "autoLogin": false,
+ "modificationDatetime": "<timestamp>",
+ "checked": false,
+ "id": "<id>",
+ "anonId": "<anonymous id>",
+ "localeFormat": "UNIVERSAL",
+ "password": "<password>",
+ "creationDatetime": "<timestamp>",
+ "userModificationDatetime": "<timestamp>",
+ "lastBackupTime": "<timestamp>",
+ "autoProtected": false,
+ "strength": 0,
+ "subdomainOnly": false
+ }
+ ]
+- args: 'note filter'
+ response: '<note>'
+ escapeChars: true
+default:
+ response: "error: unknown command '$*'"
+ exitCode: 1
-- golden/dashlane-note --
<note>
diff --git a/internal/cmd/testdata/scripts/doppler.txtar b/internal/cmd/testdata/scripts/doppler.txtar
index c0ff3eb15f3..af8194ad205 100644
--- a/internal/cmd/testdata/scripts/doppler.txtar
+++ b/internal/cmd/testdata/scripts/doppler.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/doppler
-[windows] unix2dos bin/doppler.cmd
+mockcommand bin/doppler
# test doppler template function (global configuration)
exec chezmoi execute-template '{{ doppler "PASSWORD_123"}}'
@@ -55,95 +54,40 @@ stdout ^default-config$
exec chezmoi execute-template '{{ (dopplerProjectJson).DOPPLER_PROJECT }}'
stdout ^default-project$
--- bin/doppler --
-#!/bin/sh
-
-case "$*" in
-"secrets download --json --no-file --project project --config config"|"secrets download --json --no-file --project project"|"secrets download --json --no-file")
- cat <<EOF
-{
- "DOPPLER_CONFIG": "config",
- "DOPPLER_ENVIRONMENT": "config",
- "DOPPLER_PROJECT": "project",
- "PASSWORD": "correcthorsebatterystaple",
- "PASSWORD_123": "staplebatteryhorsecorrect",
- "JSON_SECRET": "{\n \"created_at\": \"2023-06-09T13:14:28.140Z\",\n \"created_by\": {\n \"email\": \"[email protected]\",\n \"name\": \"example\",\n \"type\": \"TYPE_USER\"\n },\n \"latest_version\": \"2\",\n \"name\": \"password\"\n}"
-}
-EOF
- ;;
-"secrets download --json --no-file --project default-project --config default-config")
- cat <<EOF
-{
- "DOPPLER_CONFIG": "default-config",
- "DOPPLER_ENVIRONMENT": "default-config",
- "DOPPLER_PROJECT": "default-project",
- "PASSWORD": "default-project-password"
-}
-EOF
- ;;
-"secrets download --json --no-file --project other-project --config default-config")
- cat <<EOF
-{
- "DOPPLER_CONFIG": "default-config",
- "DOPPLER_ENVIRONMENT": "default-config",
- "DOPPLER_PROJECT": "other-project",
- "PASSWORD": "other-project-password"
-}
-EOF
- ;;
-*)
- echo "$*: unknown command"
- exit 1
- ;;
-esac
--- bin/doppler.cmd --
-@echo off
-IF "%*" == "secrets download --json --no-file --project project --config config" (
- goto download-project
-) ELSE IF "%*" == "secrets download --json --no-file --project project" (
- goto download-project
-) ELSE IF "%*" == "secrets download --json --no-file" (
- goto download-project
-) ELSE IF "%*" == "secrets download --json --no-file --project default-project --config default-config" (
- goto download-default-project
-) ELSE IF "%*" == "secrets download --json --no-file --project other-project --config default-config" (
- goto download-other-project
-) ELSE (
- echo unknown command: $*
- exit /b 1
-)
-
-exit /b 0
-
-:download-project
-echo.{
-echo. "DOPPLER_CONFIG": "config",
-echo. "DOPPLER_ENVIRONMENT": "config",
-echo. "DOPPLER_PROJECT": "project",
-echo. "PASSWORD": "correcthorsebatterystaple",
-echo. "PASSWORD_123": "staplebatteryhorsecorrect",
-echo. "JSON_SECRET": "{\n \"created_at\": \"2023-06-09T13:14:28.140Z\",\n \"created_by\": {\n \"email\": \"[email protected]\",\n \"name\": \"example\",\n \"type\": \"TYPE_USER\"\n },\n \"latest_version\": \"2\",\n \"name\": \"password\"\n}"
-echo.}
-exit /b 0
-
-:download-default-project
-echo.{
-echo. "DOPPLER_CONFIG": "default-config",
-echo. "DOPPLER_ENVIRONMENT": "default-config",
-echo. "DOPPLER_PROJECT": "default-project",
-echo. "PASSWORD": "default-project-password"
-echo.}
-exit /b 0
-
-:download-other-project
-echo.{
-echo. "DOPPLER_CONFIG": "default-config",
-echo. "DOPPLER_ENVIRONMENT": "default-config",
-echo. "DOPPLER_PROJECT": "other-project",
-echo. "PASSWORD": "other-project-password"
-echo.}
-exit /b 0
-
+-- bin/doppler.yaml --
+responses:
+- args: 'secrets download --json --no-file --project project --config config'
+ orArgs:
+ - 'secrets download --json --no-file --project project'
+ - 'secrets download --json --no-file'
+ response: |
+ {
+ "DOPPLER_CONFIG": "config",
+ "DOPPLER_ENVIRONMENT": "config",
+ "DOPPLER_PROJECT": "project",
+ "PASSWORD": "correcthorsebatterystaple",
+ "PASSWORD_123": "staplebatteryhorsecorrect",
+ "JSON_SECRET": "{\n \"created_at\": \"2023-06-09T13:14:28.140Z\",\n \"created_by\": {\n \"email\": \"[email protected]\",\n \"name\": \"example\",\n \"type\": \"TYPE_USER\"\n },\n \"latest_version\": \"2\",\n \"name\": \"password\"\n}"
+ }
+- args: 'secrets download --json --no-file --project default-project --config default-config'
+ response: |
+ {
+ "DOPPLER_CONFIG": "default-config",
+ "DOPPLER_ENVIRONMENT": "default-config",
+ "DOPPLER_PROJECT": "default-project",
+ "PASSWORD": "default-project-password"
+ }
+- args: 'secrets download --json --no-file --project other-project --config default-config'
+ response: |
+ {
+ "DOPPLER_CONFIG": "default-config",
+ "DOPPLER_ENVIRONMENT": "default-config",
+ "DOPPLER_PROJECT": "other-project",
+ "PASSWORD": "other-project-password"
+ }
+default:
+ response: '$*: unknown command'
+ exitCode: 1
-- home/user/.keep --
-- home3/user/.config/chezmoi/chezmoi.toml --
[doppler]
diff --git a/internal/cmd/testdata/scripts/gopass.txtar b/internal/cmd/testdata/scripts/gopass.txtar
index 6a92c3c49eb..7f275750503 100644
--- a/internal/cmd/testdata/scripts/gopass.txtar
+++ b/internal/cmd/testdata/scripts/gopass.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/gopass
-[windows] unix2dos bin/gopass.cmd
+mockcommand bin/gopass
[windows] unix2dos golden/gopass-raw
# test gopass template function
@@ -10,42 +9,22 @@ stdout ^examplepassword$
exec chezmoi execute-template '{{ gopassRaw "misc/example.com" }}'
cmp stdout golden/gopass-raw
--- bin/gopass --
-#!/bin/sh
+-- bin/gopass.yaml --
+responses:
+- args: '--version'
+ response: 'gopass 1.10.1 go1.15 linux amd64'
+- args: 'show --noparsing misc/example.com'
+ response: |
+ Secret: misc/example.com
-case "$*" in
-"--version")
- echo "gopass 1.10.1 go1.15 linux amd64"
- ;;
-"show --noparsing misc/example.com")
- echo "Secret: misc/example.com"
- echo
- echo "examplepassword"
- echo "key: value"
- ;;
-"show --password misc/example.com")
- echo "examplepassword"
- ;;
-*)
- echo "gopass: invalid command: $*"
- exit 1
-esac
--- bin/gopass.cmd --
-@echo off
-IF "%*" == "--version" (
- echo "gopass 1.10.1 go1.15 windows amd64"
-) ELSE IF "%*" == "show --noparsing misc/example.com" (
- echo.Secret: misc/example.com
- echo.
- echo.examplepassword
- echo.key: value
-) ELSE IF "%*" == "show --password misc/example.com" (
- echo | set /p=examplepassword
- exit /b 0
-) ELSE (
- echo gopass: invalid command: %*
- exit /b 1
-)
+ examplepassword
+ key: value
+- args: 'show --password misc/example.com'
+ response: 'examplepassword'
+ suppressLastNewline: true
+default:
+ response: 'gopass: invalid command: $*'
+ exitCode: 1
-- golden/gopass-raw --
Secret: misc/example.com
diff --git a/internal/cmd/testdata/scripts/keepassxc.txtar b/internal/cmd/testdata/scripts/keepassxc.txtar
index 0c6425ebec3..8ff643c47e4 100644
--- a/internal/cmd/testdata/scripts/keepassxc.txtar
+++ b/internal/cmd/testdata/scripts/keepassxc.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/keepassxc-cli
-[windows] unix2dos bin/keepassxc-cli.cmd
+mockcommand bin/keepassxc-cli
# test keepassxcAttachment template function
stdin $HOME/input
@@ -16,50 +15,27 @@ stdin $HOME/input
exec chezmoi execute-template --no-tty '{{ (keepassxc "example.com").UserName }}/{{ (keepassxc "example.com").Password }}'
stdout examplelogin/examplepassword$
--- bin/keepassxc-cli --
-#!/bin/sh
-
-case "$*" in
-"--version")
- echo "2.7.0"
- ;;
-"attachment-export --key-file /secrets.key /secrets.kdbx --quiet --stdout example.com attachment")
- echo "# contents of attachment"
- ;;
-"show --key-file /secrets.key /secrets.kdbx --quiet --show-protected example.com")
- cat <<EOF
-Title: example.com
-UserName: examplelogin
-Password: examplepassword
-URL:
-Notes:
-EOF
- ;;
-"show --key-file /secrets.key /secrets.kdbx example.com --attributes host-name --quiet --show-protected")
- echo "example.com"
- ;;
-*)
- echo "keepass-test: invalid command: $*"
- exit 1
-esac
--- bin/keepassxc-cli.cmd --
-@echo off
-IF "%*" == "--version" (
- echo 2.7.0
-) ELSE IF "%*" == "attachment-export --key-file /secrets.key C:/secrets.kdbx --quiet --stdout example.com attachment" (
- echo.# contents of attachment
-) ELSE IF "%*" == "show --key-file /secrets.key C:/secrets.kdbx --quiet --show-protected example.com" (
- echo.Title: example.com
- echo.UserName: examplelogin
- echo.Password: examplepassword
- echo.URL:
- echo.Notes:
-) ELSE IF "%*" == "show --key-file /secrets.key C:/secrets.kdbx example.com --attributes host-name --quiet --show-protected" (
- echo.example.com
-) ELSE (
- echo keepass-test: invalid command: %*
- exit /b 1
-)
+-- bin/keepassxc-cli.yaml --
+responses:
+- args: '--version'
+ response: '2.7.0'
+- args: 'attachment-export --key-file /secrets.key /secrets.kdbx --quiet --stdout example.com attachment'
+ windowsArgs: 'attachment-export --key-file /secrets.key C:/secrets.kdbx --quiet --stdout example.com attachment'
+ response: '# contents of attachment'
+- args: 'show --key-file /secrets.key /secrets.kdbx --quiet --show-protected example.com'
+ windowsArgs: 'show --key-file /secrets.key C:/secrets.kdbx --quiet --show-protected example.com'
+ response: |
+ Title: example.com
+ UserName: examplelogin
+ Password: examplepassword
+ URL:
+ Notes:
+- args: 'show --key-file /secrets.key /secrets.kdbx example.com --attributes host-name --quiet --show-protected'
+ windowsArgs: 'show --key-file /secrets.key C:/secrets.kdbx example.com --attributes host-name --quiet --show-protected'
+ response: 'example.com'
+default:
+ response: 'keepassxc-cli: invalid command: $*'
+ exitCode: 1
-- home/user/.config/chezmoi/chezmoi.toml --
[keepassxc]
args = ["--key-file", "/secrets.key"]
diff --git a/internal/cmd/testdata/scripts/keeper.txtar b/internal/cmd/testdata/scripts/keeper.txtar
index 0601aece2d4..5794abb54bd 100644
--- a/internal/cmd/testdata/scripts/keeper.txtar
+++ b/internal/cmd/testdata/scripts/keeper.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/keeper
-[windows] unix2dos bin/keeper.cmd
+mockcommand bin/keeper
# test keeper template function
exec chezmoi execute-template '{{ (keeper "QOahgRH_dSTvSvhRBqzCzQ").record_uid }}'
@@ -13,105 +12,52 @@ stdout ^mypassword$
exec chezmoi execute-template '{{ keeperFindPassword "Example" }}'
stdout ^mypassword$
--- bin/keeper --
-#!/bin/sh
-
-case "$*" in
-"get --format=json QOahgRH_dSTvSvhRBqzCzQ --config /path/to/config.json")
- cat <<EOF
-{
- "record_uid": "QOahgRH_dSTvSvhRBqzCzQ",
- "data": {
- "title": "Example",
- "type": "login",
- "fields": [
- {
+-- bin/keeper.yaml --
+responses:
+- args: 'get --format=json QOahgRH_dSTvSvhRBqzCzQ --config /path/to/config.json'
+ response: |
+ {
+ "record_uid": "QOahgRH_dSTvSvhRBqzCzQ",
+ "data": {
+ "title": "Example",
"type": "login",
- "value": [
- "mylogin"
- ]
- },
- {
- "type": "password",
- "value": [
- "mypassword"
- ]
- },
- {
- "type": "url",
- "value": []
- },
- {
- "type": "fileRef",
- "value": []
- },
- {
- "type": "oneTimeCode",
- "value": []
+ "fields": [
+ {
+ "type": "login",
+ "value": [
+ "mylogin"
+ ]
+ },
+ {
+ "type": "password",
+ "value": [
+ "mypassword"
+ ]
+ },
+ {
+ "type": "url",
+ "value": []
+ },
+ {
+ "type": "fileRef",
+ "value": []
+ },
+ {
+ "type": "oneTimeCode",
+ "value": []
+ }
+ ],
+ "custom": []
}
- ],
- "custom": []
- }
-}
-EOF
- ;;
-"find-password Example --config /path/to/config.json")
- echo "mypassword"
- ;;
-*)
- cat <<EOF
-Commands:
- search ... Search the vault. Can use a regular expression.
+ }
+- args: 'find-password Example --config /path/to/config.json'
+ response: 'mypassword'
+default:
+ response: |
+ Commands:
+ search ... Search the vault. Can use a regular expression.
-Type 'command -h' to display help on command
-EOF
-esac
--- bin/keeper.cmd --
-@echo off
-IF "%*" == "get --format=json QOahgRH_dSTvSvhRBqzCzQ --config /path/to/config.json" (
- echo.{
- echo. "record_uid": "QOahgRH_dSTvSvhRBqzCzQ",
- echo. "data": {
- echo. "title": "Example",
- echo. "type": "login",
- echo. "fields": [
- echo. {
- echo. "type": "login",
- echo. "value": [
- echo. "mylogin"
- echo. ]
- echo. },
- echo. {
- echo. "type": "password",
- echo. "value": [
- echo. "mypassword"
- echo. ]
- echo. },
- echo. {
- echo. "type": "url",
- echo. "value": []
- echo. },
- echo. {
- echo. "type": "fileRef",
- echo. "value": []
- echo. },
- echo. {
- echo. "type": "oneTimeCode",
- echo. "value": []
- echo. }
- echo. ],
- echo. "custom": []
- echo. }
- echo.}
-) ELSE IF "%*" == "find-password Example --config /path/to/config.json" (
- echo.mypassword
- ;;
-) ELSE (
- echo.Commands:
- echo. search ... Search the vault. Can use a regular expression.
- echo.
- echo.Type 'command -h' to display help on command
-)
+ Type 'command -h' to display help on command
-- home/user/.config/chezmoi/chezmoi.toml --
[keeper]
args = ["--config", "/path/to/config.json"]
diff --git a/internal/cmd/testdata/scripts/lastpass.txtar b/internal/cmd/testdata/scripts/lastpass.txtar
index e78337fb498..c5fb1fa5b8f 100644
--- a/internal/cmd/testdata/scripts/lastpass.txtar
+++ b/internal/cmd/testdata/scripts/lastpass.txtar
@@ -1,59 +1,29 @@
-[unix] chmod 755 bin/lpass
-[windows] unix2dos bin/lpass.cmd
+mockcommand bin/lpass
# test lastpass template function
exec chezmoi execute-template '{{ (index (lastpass "example.com") 0).password }}'
stdout ^examplepassword$
--- bin/lpass --
-#!/bin/sh
-
-case "$*" in
-"--version")
- echo "LastPass CLI v1.3.3.GIT"
- ;;
-"show --json example.com")
- cat <<EOF
-[
- {
- "id": "0",
- "name": "example.com",
- "fullname": "Examples/example.com",
- "username": "examplelogin",
- "password": "examplepassword",
- "last_modified_gmt": "0",
- "last_touch": "0",
- "group": "Examples",
- "url": "",
- "note": ""
- }
-]
-EOF
- ;;
-*)
- echo "lpass: invalid command: $*"
- exit 1
-esac
--- bin/lpass.cmd --
-@echo off
-IF "%*" == "--version" (
- echo LastPass CLI v1.3.3.GIT
-) ELSE IF "%*" == "show --json example.com" (
- echo.[
- echo. {
- echo. "id": "0",
- echo. "name": "example.com",
- echo. "fullname": "Examples/example.com",
- echo. "username": "examplelogin",
- echo. "password": "examplepassword",
- echo. "last_modified_gmt": "0",
- echo. "last_touch": "0",
- echo. "group": "Examples",
- echo. "url": "",
- echo. "note": ""
- echo. }
- echo.]
-) ELSE (
- echo lpass: invalid command: %*
- exit /b 1
-)
+-- bin/lpass.yaml --
+responses:
+- args: '--version'
+ response: 'LastPass CLI v1.3.3.GIT'
+- args: 'show --json example.com'
+ response: |
+ [
+ {
+ "id": "0",
+ "name": "example.com",
+ "fullname": "Examples/example.com",
+ "username": "examplelogin",
+ "password": "examplepassword",
+ "last_modified_gmt": "0",
+ "last_touch": "0",
+ "group": "Examples",
+ "url": "",
+ "note": ""
+ }
+ ]
+default:
+ response: 'lpass: invalid command: $*'
+ exitCode: 1
diff --git a/internal/cmd/testdata/scripts/onepassword2.txtar b/internal/cmd/testdata/scripts/onepassword2.txtar
index c1f9316b649..8c822744b66 100644
--- a/internal/cmd/testdata/scripts/onepassword2.txtar
+++ b/internal/cmd/testdata/scripts/onepassword2.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/op
-[windows] unix2dos bin/op.cmd
+mockcommand bin/op
# test onepassword template function
exec chezmoi execute-template '{{ (onepassword "ExampleLogin").id }}'
@@ -73,100 +72,51 @@ env OP_CONNECT_TOKEN=y
! exec chezmoi execute-template '{{ (onepassword "ExampleLogin").id }}'
stderr 'OP_CONNECT_HOST and OP_CONNECT_TOKEN'
--- bin/op --
-#!/bin/sh
-
-if [ "$*" = "--version" ]; then
- echo 2.0.0
-elif [ "$*" = "item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "item get --format json ExampleLogin --account account_uuid" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "item get --format json ExampleLogin" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "account list --format=json" ]; then
- echo '[{"url":"account.1password.com","email":"[email protected]","user_uuid":"user_uuid","account_uuid":"account_uuid"}]'
-elif [ "$*" = "signin --account account_uuid --raw" ]; then
- echo 'thisIsAFakeSessionToken'
-elif [ "$*" = "signin --raw" ]; then
- echo 'thisIsAFakeSessionToken'
-elif [ "$*" = "read --no-newline op://vault/item/field" ]; then
- echo 'exampleField'
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" ]; then
- echo 'exampleField'
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" ]; then
- echo 'exampleAccountField'
-elif [ "$*" = "document get exampleDocument" ]; then
- echo 'OK-COMPUTER'
-elif [ "$*" = "document get exampleDocument --vault vault" ]; then
- echo 'OK-VAULT'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument" ]; then
- echo 'OK-COMPUTER'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" ]; then
- echo 'OK-VAULT'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" ]; then
- echo 'OK-ACCOUNT'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" ]; then
- echo 'OK-VAULT-ACCOUNT'
-else
- echo [ERROR] 2020/01/01 00:00:00 unknown command \"$*\" for \"op\" 1>&2
- exit 1
-fi
--- bin/op.cmd --
-@echo off
-IF "%*" == "--version" (
- echo 2.0.0
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin --account account_uuid" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "account list --format=json" (
- echo.[{"url":"account.1password.com","email":"[email protected]","user_uuid":"user_uuid","account_uuid":"account_uuid"}]
-) ELSE IF "%*" == "signin --account account_uuid --raw" (
- echo thisIsAFakeSessionToken
-) ELSE IF "%*" == "signin --raw" (
- echo thisIsAFakeSessionToken
-) ELSE IF "%*" == "document get exampleDocument" (
- echo.OK-COMPUTER
-) ELSE IF "%*" == "document get exampleDocument --vault vault" (
- echo.OK-VAULT
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument" (
- echo.OK-COMPUTER
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" (
- echo.OK-VAULT
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" (
- echo.OK-ACCOUNT
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" (
- echo.OK-VAULT-ACCOUNT
-) ELSE IF "%*" == "read --no-newline op://vault/item/field" (
- echo.exampleField
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" (
- echo.exampleField
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" (
- echo.exampleAccountField
-) ELSE (
- echo.[ERROR] 2020/01/01 00:00:00 unknown command "%*" for "op" 1>&2
- exit /b 1
-)
+-- bin/op.yaml --
+responses:
+- args: '--version'
+ response: '2.0.0'
+- args: 'item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: 'item get --format json ExampleLogin --account account_uuid'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: 'item get --format json ExampleLogin'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: 'account list --format=json'
+ response: '[{"url":"account.1password.com","email":"[email protected]","user_uuid":"user_uuid","account_uuid":"account_uuid"}]'
+- args: 'signin --account account_uuid --raw'
+ response: 'thisIsAFakeSessionToken'
+- args: 'signin --raw'
+ response: 'thisIsAFakeSessionToken'
+- args: 'read --no-newline op://vault/item/field'
+ response: 'exampleField'
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field'
+ response: 'exampleField'
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid'
+ response: 'exampleAccountField'
+- args: 'document get exampleDocument'
+ response: 'OK-COMPUTER'
+- args: 'document get exampleDocument --vault vault'
+ response: 'OK-VAULT'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument'
+ response: 'OK-COMPUTER'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault'
+ response: 'OK-VAULT'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid'
+ response: 'OK-ACCOUNT'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid'
+ response: 'OK-VAULT-ACCOUNT'
+default:
+ response: '[ERROR] 2020/01/01 00:00:00 unknown command "$*" for "op"'
+ destination: stderr
+ exitCode: 1
diff --git a/internal/cmd/testdata/scripts/onepassword2connect.txtar b/internal/cmd/testdata/scripts/onepassword2connect.txtar
index b79e1388a37..39e7c748116 100644
--- a/internal/cmd/testdata/scripts/onepassword2connect.txtar
+++ b/internal/cmd/testdata/scripts/onepassword2connect.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/op
-[windows] unix2dos bin/op.cmd
+mockcommand bin/op
mkhomedir
@@ -60,130 +59,84 @@ env OP_SERVICE_ACCOUNT_TOKEN=x
! exec chezmoi execute-template '{{ (onepassword "ExampleLogin").id }}'
stderr 'OP_SERVICE_ACCOUNT_TOKEN is set'
--- bin/op --
-#!/bin/sh
-
-if [ "$*" = "--version" ]; then
- echo 2.0.0
-elif [ "$*" = "item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "item get --format json ExampleLogin --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "item get --format json ExampleLogin" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "item get --format json ExampleLogin --vault vault" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" ]; then
- echo "[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin" ]; then
- echo "[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "account list --format=json" ]; then
- echo "[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "signin --account account_uuid --raw" ]; then
- echo "[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "signin --raw" ]; then
- echo "[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "read --no-newline op://vault/item/field" ]; then
- echo 'exampleField'
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" ]; then
- echo "[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" ]; then
- echo "[ERROR] cannot use session tokens or accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "document get exampleDocument" ]; then
- echo "[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument" ]; then
- echo "[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" ]; then
- echo "[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" ]; then
- echo "[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set" 1>&2
- exit 1
-else
- echo "[ERROR] 2020/01/01 00:00:00 unknown command \"$*\" for \"op\"" 1>&2
- exit 1
-fi
--- bin/op.cmd --
-@echo off
-IF "%*" == "--version" (
- echo 2.0.0
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "item get --format json ExampleLogin --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "item get --format json ExampleLogin" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" (
- echo.[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin" (
- echo.[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "account list --format=json" (
- echo.[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "signin --account account_uuid --raw" (
- echo.[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "signin --raw" (
- echo.[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
-) ELSE IF "%*" == "document get exampleDocument" (
- echo.[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument" (
- echo.[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" (
- echo.[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" (
- echo.[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" (
- echo.[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "read --no-newline op://vault/item/field" (
- echo.exampleField
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" (
- echo.[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" (
- echo.[ERROR] cannot use session tokens or accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set 1>&2
- exit /b 1
-) ELSE (
- echo "[ERROR] 2020/01/01 00:00:00 unknown command \"%*\" for \"op\"" 1>&2
- exit /b 1
-)
+-- bin/op.yaml --
+responses:
+- args: '--version'
+ response: 2.0.0
+- args: 'item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'item get --format json ExampleLogin --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'item get --format json ExampleLogin'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: 'item get --format json ExampleLogin --vault vault'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault'
+ response: '[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin'
+ response: '[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'account list --format=json'
+ response: '[ERROR] cannot use accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'signin --account account_uuid --raw'
+ response: '[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'signin --raw'
+ response: '[ERROR] cannot sign in with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'read --no-newline op://vault/item/field'
+ response: 'exampleField'
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field'
+ response: '[ERROR] cannot use session tokens with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid'
+ response: '[ERROR] cannot use session tokens or accounts with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'document get exampleDocument'
+ response: '[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument'
+ response: '[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault'
+ response: '[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid'
+ response: '[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid'
+ response: '[ERROR] cannot use document get with OP_CONNECT_HOST and OP_CONNECT_TOKEN set'
+ destination: stderr
+ exitCode: 1
+default:
+ response: '[ERROR] 2020/01/01 00:00:00 unknown command "$*" for "op"'
+ destination: stderr
+ exitCode: 1
-- home/user/.config/chezmoi/chezmoi.toml --
[onepassword]
mode = "connect"
diff --git a/internal/cmd/testdata/scripts/onepassword2service.txtar b/internal/cmd/testdata/scripts/onepassword2service.txtar
index 7aae04a1976..f439b13b031 100644
--- a/internal/cmd/testdata/scripts/onepassword2service.txtar
+++ b/internal/cmd/testdata/scripts/onepassword2service.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/op
-[windows] unix2dos bin/op.cmd
+mockcommand bin/op
mkhomedir
@@ -67,132 +66,82 @@ env OP_CONNECT_TOKEN=y
! exec chezmoi execute-template '{{ (onepassword "ExampleLogin").id }}'
stderr 'OP_CONNECT_HOST and OP_CONNECT_TOKEN'
--- bin/op --
-#!/bin/sh
-
-if [ "$*" = "--version" ]; then
- echo 2.0.0
-elif [ "$*" = "item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "item get --format json ExampleLogin --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "item get --format json ExampleLogin" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "item get --format json ExampleLogin --vault vault" ]; then
- echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" ]; then
- echo "[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken item get --format json ExampleLogin" ]; then
- echo "[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "account list --format=json" ]; then
- echo "[ERROR] cannot use accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "signin --account account_uuid --raw" ]; then
- echo "[ERROR] cannot sign in with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "signin --raw" ]; then
- echo "[ERROR] cannot sign in with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "document get exampleDocument" ]; then
- echo 'OK-COMPUTER'
-elif [ "$*" = "document get exampleDocument --vault vault" ]; then
- echo 'OK-VAULT'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument" ]; then
- echo "[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" ]; then
- echo 'OK-VAULT'
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" ]; then
- echo "[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "read --no-newline op://vault/item/field" ]; then
- echo 'exampleField'
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" ]; then
- echo "[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-elif [ "$*" = "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" ]; then
- echo "[ERROR] cannot use session tokens or accounts with OP_SERVICE_TOKEN set" 1>&2
- exit 1
-else
- echo "[ERROR] 2020/01/01 00:00:00 unknown command \"$*\" for \"op\"" 1>&2
- exit 1
-fi
--- bin/op.cmd --
-@echo off
-IF "%*" == "--version" (
- echo 2.0.0
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "item get --format json ExampleLogin --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid" (
- echo.[ERROR] cannot use accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "item get --format json ExampleLogin" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault" (
- echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault" (
- echo.[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin" (
- echo.[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "account list --format=json" (
- echo.[ERROR] cannot use accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "signin --account account_uuid --raw" (
- echo.[ERROR] cannot sign in with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "signin --raw" (
- echo.[ERROR] cannot sign in with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "document get exampleDocument" (
- echo.OK-COMPUTER
-) ELSE IF "%*" == "document get exampleDocument --vault vault" (
- echo.OK-VAULT
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument" (
- echo.[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault" (
- echo.[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid" (
- echo.[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set 1>&2
- exit 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid" (
- echo.[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set 1>&2
- exit 1
-) ELSE IF "%*" == "read --no-newline op://vault/item/field" (
- echo.exampleField
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field" (
- echo.[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid" (
- echo.[ERROR] cannot use session tokens or accounts with OP_SERVICE_TOKEN set 1>&2
- exit /b 1
-) ELSE (
- echo "[ERROR] 2020/01/01 00:00:00 unknown command \"%*\" for \"op\"" 1>&2
- exit /b 1
-)
+-- bin/op.yaml --
+responses:
+- args: '--version'
+ response: '2.0.0'
+- args: 'item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'item get --format json ExampleLogin --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account_uuid'
+ response: '[ERROR] cannot use accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'item get --format json ExampleLogin'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: 'item get --format json ExampleLogin --vault vault'
+ response: '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault'
+ response: '[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken item get --format json ExampleLogin'
+ response: '[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'account list --format=json'
+ response: '[ERROR] cannot use accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'signin --account account_uuid --raw'
+ response: '[ERROR] cannot sign in with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'signin --raw'
+ response: '[ERROR] cannot sign in with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'document get exampleDocument'
+ response: 'OK-COMPUTER'
+- args: 'document get exampleDocument --vault vault'
+ response: 'OK-VAULT'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument'
+ response: '[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault'
+ response: 'OK-VAULT'
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --account account_uuid'
+ response: '[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken document get exampleDocument --vault vault --account account_uuid'
+ response: '[ERROR] cannot use accounts or session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: 'read --no-newline op://vault/item/field'
+ response: 'exampleField'
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field'
+ response: '[ERROR] cannot use session tokens with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+- args: '--session thisIsAFakeSessionToken read --no-newline op://vault/item/field --account account_uuid'
+ response: '[ERROR] cannot use session tokens or accounts with OP_SERVICE_TOKEN set'
+ destination: stderr
+ exitCode: 1
+default:
+ response: '[ERROR] 2020/01/01 00:00:00 unknown command "$*" for "op"'
+ destination: stderr
+ exitCode: 1
-- home/user/.config/chezmoi/chezmoi.toml --
[onepassword]
mode = "service"
diff --git a/internal/cmd/testdata/scripts/pass.txtar b/internal/cmd/testdata/scripts/pass.txtar
index 076412168ed..3696245ef57 100644
--- a/internal/cmd/testdata/scripts/pass.txtar
+++ b/internal/cmd/testdata/scripts/pass.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/pass
-[windows] unix2dos bin/pass.cmd
+mockcommand bin/pass
[windows] unix2dos golden/pass-raw
# test pass template function
@@ -14,28 +13,15 @@ stdout ^examplelogin$
exec chezmoi execute-template '{{ passRaw "misc/example.com" }}'
cmp stdout golden/pass-raw
--- bin/pass --
-#!/bin/sh
-
-case "$*" in
-"show misc/example.com")
- echo "examplepassword"
- echo "login: examplelogin"
- ;;
-*)
- echo "pass: invalid command: $*"
- exit 1
-esac
--- bin/pass.cmd --
-@echo off
-IF "%*" == "show misc/example.com" (
- echo.examplepassword
- echo.login: examplelogin
- exit /b 0
-) ELSE (
- echo pass: invalid command: %*
- exit /b 1
-)
+-- bin/pass.yaml --
+responses:
+- args: 'show misc/example.com'
+ response: |
+ examplepassword
+ login: examplelogin
+default:
+ response: 'pass: invalid command: $*'
+ exitCode: 1
-- golden/pass-raw --
examplepassword
login: examplelogin
diff --git a/internal/cmd/testdata/scripts/passhole.txtar b/internal/cmd/testdata/scripts/passhole.txtar
index 977589967b1..3dbc78abf21 100644
--- a/internal/cmd/testdata/scripts/passhole.txtar
+++ b/internal/cmd/testdata/scripts/passhole.txtar
@@ -1,33 +1,18 @@
-[unix] chmod 755 bin/ph
-[windows] unix2dos bin/ph.cmd
+mockcommand bin/ph
# test passhole template function
stdin golden/stdin
exec chezmoi execute-template --no-tty '{{ passhole "example.com" "password" }}'
stdout examplepassword
--- bin/ph --
-#!/bin/sh
-case "$*" in
-"--version")
- echo "1.9.9"
- ;;
-"--password - show --field password example.com")
- echo "examplepassword"
- ;;
-*)
- echo "ph: error: argument command: invalid choice:"
- exit 1
-esac
--- bin/ph.cmd --
-@echo off
-IF "%*" == "--version" (
- echo 1.9.9
-) ELSE IF "%*" == "--password - show --field password example.com" (
- echo examplepassword
-) ELSE (
- echo ph: error: argument command: invalid choice:
- exit /b 1
-)
+-- bin/ph.yaml --
+responses:
+- args: '--version'
+ response: '1.9.9'
+- args: '--password - show --field password example.com'
+ response: 'examplepassword'
+default:
+ response: 'ph: error: argument command: invalid choice:'
+ exitCode: 1
-- golden/stdin --
fakepassword
diff --git a/internal/cmd/testdata/scripts/rbw.txtar b/internal/cmd/testdata/scripts/rbw.txtar
index b59229eafa6..da9b572c4b5 100644
--- a/internal/cmd/testdata/scripts/rbw.txtar
+++ b/internal/cmd/testdata/scripts/rbw.txtar
@@ -1,5 +1,4 @@
-[unix] chmod 755 bin/rbw
-[windows] unix2dos bin/rbw.cmd
+mockcommand bin/rbw
# test rbw template function
exec chezmoi execute-template '{{ (rbw "test-entry").data.password }}'
@@ -17,142 +16,69 @@ stdout ^secret$
exec chezmoi execute-template '{{ (rbwFields "test-entry" "--folder" "my-folder").something.value }}'
stdout ^enigma$
--- bin/rbw --
-#!/bin/sh
-
-case "$*" in
-"get --raw test-entry")
- cat <<EOF
-{
- "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
- "folder": null,
- "name": "test-entry",
- "data": {
- "username": "foo",
- "password": "hunter2",
- "totp": null,
- "uris": [
- {
- "uri": "example.com",
- "match_type": null
- }
- ]
- },
- "fields": [
- {
- "name": "something",
- "value": "secret"
- }
- ],
- "notes": "blah",
- "history": [
- {
- "last_used_date": "2022-08-18T23:24:47.994Z",
- "password": "hunter2"
- }
- ]
-}
-EOF
- ;;
-"get --raw test-entry --folder my-folder")
- cat <<EOF
-{
- "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
- "folder": null,
- "name": "test-entry",
- "data": {
- "username": "foo",
- "password": "correcthorsebatterystaple",
- "totp": null,
- "uris": [
- {
- "uri": "example.com",
- "match_type": null
- }
- ]
- },
- "fields": [
+-- bin/rbw.yaml --
+responses:
+- args: 'get --raw test-entry'
+ response: |
{
- "name": "something",
- "value": "enigma"
+ "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
+ "folder": null,
+ "name": "test-entry",
+ "data": {
+ "username": "foo",
+ "password": "hunter2",
+ "totp": null,
+ "uris": [
+ {
+ "uri": "example.com",
+ "match_type": null
+ }
+ ]
+ },
+ "fields": [
+ {
+ "name": "something",
+ "value": "secret"
+ }
+ ],
+ "notes": "blah",
+ "history": [
+ {
+ "last_used_date": "2022-08-18T23:24:47.994Z",
+ "password": "hunter2"
+ }
+ ]
}
- ],
- "notes": "blah",
- "history": [
+- args: 'get --raw test-entry --folder my-folder'
+ response: |
{
- "last_used_date": "2022-08-18T23:24:47.994Z",
- "password": "hunter2"
+ "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
+ "folder": null,
+ "name": "test-entry",
+ "data": {
+ "username": "foo",
+ "password": "correcthorsebatterystaple",
+ "totp": null,
+ "uris": [
+ {
+ "uri": "example.com",
+ "match_type": null
+ }
+ ]
+ },
+ "fields": [
+ {
+ "name": "something",
+ "value": "enigma"
+ }
+ ],
+ "notes": "blah",
+ "history": [
+ {
+ "last_used_date": "2022-08-18T23:24:47.994Z",
+ "password": "hunter2"
+ }
+ ]
}
- ]
-}
-EOF
- ;;
-*)
- exit 1
- ;;
-esac
--- bin/rbw.cmd --
-@echo off
-IF "%*" == "get --raw test-entry" (
- echo.{
- echo. "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
- echo. "folder": null,
- echo. "name": "test-entry",
- echo. "data": {
- echo. "username": "foo",
- echo. "password": "hunter2",
- echo. "totp": null,
- echo. "uris": [
- echo. {
- echo. "uri": "example.com",
- echo. "match_type": null
- echo. }
- echo. ]
- echo. },
- echo. "fields": [
- echo. {
- echo. "name": "something",
- echo. "value": "secret"
- echo. }
- echo. ],
- echo. "notes": "blah",
- echo. "history": [
- echo. {
- echo. "last_used_date": "2022-08-18T23:24:47.994Z",
- echo. "password": "hunter2"
- echo. }
- echo. ]
- echo.}
-) ELSE IF "%*" == "get --raw test-entry --folder my-folder" (
- echo.{
- echo. "id": "adf723e1-ab03-4ff3-81aa-f5f3c2b68a5f",
- echo. "folder": null,
- echo. "name": "test-entry",
- echo. "data": {
- echo. "username": "foo",
- echo. "password": "correcthorsebatterystaple",
- echo. "totp": null,
- echo. "uris": [
- echo. {
- echo. "uri": "example.com",
- echo. "match_type": null
- echo. }
- echo. ]
- echo. },
- echo. "fields": [
- echo. {
- echo. "name": "something",
- echo. "value": "enigma"
- echo. }
- echo. ],
- echo. "notes": "blah",
- echo. "history": [
- echo. {
- echo. "last_used_date": "2022-08-18T23:24:47.994Z",
- echo. "password": "hunter2"
- echo. }
- echo. ]
- echo.}
-) ELSE (
- exit /b 1
-)
+default:
+ exitCode: 1
diff --git a/internal/cmd/testdata/scripts/vault.txtar b/internal/cmd/testdata/scripts/vault.txtar
index e58f9f92afc..f5c0c9e433e 100644
--- a/internal/cmd/testdata/scripts/vault.txtar
+++ b/internal/cmd/testdata/scripts/vault.txtar
@@ -1,62 +1,31 @@
-[unix] chmod 755 bin/vault
-[windows] unix2dos bin/vault.cmd
+mockcommand bin/vault
# test vault template function
exec chezmoi execute-template '{{ (vault "secret/examplesecret").data.data.password }}'
stdout ^examplepassword$
--- bin/vault --
-#!/bin/sh
-
-case "$*" in
-"kv get -format=json secret/examplesecret")
-cat <<EOF
-{
- "request_id": "d90311b6-2f3f-768e-656c-ce768e773b09",
- "lease_id": "",
- "lease_duration": 0,
- "renewable": false,
- "data": {
- "data": {
- "password": "examplepassword"
- },
- "metadata": {
- "created_time": "2021-01-11T21:48:46.961974384Z",
- "deletion_time": "",
- "destroyed": false,
- "version": 1
+-- bin/vault.yaml --
+responses:
+- args: 'kv get -format=json secret/examplesecret'
+ response: |
+ {
+ "request_id": "d90311b6-2f3f-768e-656c-ce768e773b09",
+ "lease_id": "",
+ "lease_duration": 0,
+ "renewable": false,
+ "data": {
+ "data": {
+ "password": "examplepassword"
+ },
+ "metadata": {
+ "created_time": "2021-01-11T21:48:46.961974384Z",
+ "deletion_time": "",
+ "destroyed": false,
+ "version": 1
+ }
+ },
+ "warnings": null
}
- },
- "warnings": null
-}
-EOF
- ;;
-*)
- echo "Usage: vault <command> [args]"
- exit 127
-esac
--- bin/vault.cmd --
-@echo off
-IF "%*" == "kv get -format=json secret/examplesecret" (
- echo.{
- echo. "request_id": "d90311b6-2f3f-768e-656c-ce768e773b09",
- echo. "lease_id": "",
- echo. "lease_duration": 0,
- echo. "renewable": false,
- echo. "data": {
- echo. "data": {
- echo. "password": "examplepassword"
- echo. },
- echo. "metadata": {
- echo. "created_time": "2021-01-11T21:48:46.961974384Z",
- echo. "deletion_time": "",
- echo. "destroyed": false,
- echo. "version": 1
- echo. }
- echo. },
- echo. "warnings": null
- echo.}
-) ELSE (
- echo "Usage: vault <command> [args]"
- exit /b 127
-)
+default:
+ response: 'Usage: vault <command> [args]'
+ exitCode: 127
|
chore
|
Use simple framework for mock password managers
|
b4df44dc69ee545aca436f78950a46bde3199e2f
|
2024-04-12 17:21:15
|
Tom Payne
|
fix: Fix panic on empty external
| false
|
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index 26e67582fd2..f0aa8d82547 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -1319,19 +1319,20 @@ func (s *SourceState) addExternal(sourceAbsPath, parentAbsPath AbsPath) error {
if err != nil {
return fmt.Errorf("%s: %w", sourceAbsPath, err)
}
- externals := make(map[string]*External)
+ externals := make(map[string]External)
if err := format.Unmarshal(data, &externals); err != nil {
return fmt.Errorf("%s: %w", sourceAbsPath, err)
}
s.Lock()
defer s.Unlock()
for path, external := range externals {
+ external := external
if strings.HasPrefix(path, "/") || filepath.IsAbs(path) {
return fmt.Errorf("%s: %s: path is not relative", sourceAbsPath, path)
}
targetRelPath := parentTargetSourceRelPath.JoinString(path)
external.sourceAbsPath = sourceAbsPath
- s.externals[targetRelPath] = append(s.externals[targetRelPath], external)
+ s.externals[targetRelPath] = append(s.externals[targetRelPath], &external)
}
return nil
}
@@ -2222,6 +2223,8 @@ func (s *SourceState) readExternal(
return s.readExternalFile(ctx, externalRelPath, parentSourceRelPath, external, options)
case ExternalTypeGitRepo:
return nil, nil
+ case "":
+ return nil, fmt.Errorf("%s: missing external type", externalRelPath)
default:
return nil, fmt.Errorf("%s: unknown external type: %s", externalRelPath, external.Type)
}
diff --git a/internal/cmd/testdata/scripts/issue3693.txtar b/internal/cmd/testdata/scripts/issue3693.txtar
new file mode 100644
index 00000000000..8d78d85487d
--- /dev/null
+++ b/internal/cmd/testdata/scripts/issue3693.txtar
@@ -0,0 +1,6 @@
+# test that chezmoi apply does not panic when given an external with an empty configuration
+! exec chezmoi apply
+stderr 'missing external type'
+
+-- home/user/.local/share/chezmoi/.chezmoiexternal.toml --
+[".config"]
|
fix
|
Fix panic on empty external
|
b366e6e04a835737ee508c8d736bc9ff16ccaf2b
|
2024-02-07 15:25:08
|
Tom Payne
|
chore: Build with Go 1.22
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b8ab90148cc..ad47fdde1bd 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -16,7 +16,7 @@ env:
CHOCOLATEY_VERSION: 2.2.2
EDITORCONFIG_CHECKER_VERSION: 2.7.2
FIND_TYPOS_VERSION: 0.0.3
- GO_VERSION: 1.21.6
+ GO_VERSION: 1.22.0
GOFUMPT_VERSION: 0.5.0
GOLANGCI_LINT_VERSION: 1.55.2
GOLINES_VERSION: 0.11.0
diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl
index 2a3343bd7ca..fd72767e796 100644
--- a/assets/chezmoi.io/docs/install.md.tmpl
+++ b/assets/chezmoi.io/docs/install.md.tmpl
@@ -244,7 +244,7 @@ pre-built binary and shell completions.
=== "OpenBSD"
-{{ range $arch := list "amd64" "arm" "arm64" "i386" }}
+{{ range $arch := list "amd64" "arm" "arm64" "i386" "ppc64" }}
[`{{ $arch }}`](https://github.com/twpayne/chezmoi/releases/download/v{{ $version }}/chezmoi_{{ $version }}_openbsd_{{ $arch }}.tar.gz)
{{- end }}
diff --git a/assets/scripts/install-local-bin.sh b/assets/scripts/install-local-bin.sh
index 5fa4f2bdbeb..6b8dbd9f1c5 100644
--- a/assets/scripts/install-local-bin.sh
+++ b/assets/scripts/install-local-bin.sh
@@ -172,6 +172,7 @@ check_goos_goarch() {
openbsd/amd64) return 0 ;;
openbsd/arm) return 0 ;;
openbsd/arm64) return 0 ;;
+ openbsd/ppc64) return 0 ;;
windows/386) return 0 ;;
windows/amd64) return 0 ;;
windows/arm) return 0 ;;
diff --git a/assets/scripts/install.sh b/assets/scripts/install.sh
index 0d190a218bc..038e4fb0273 100644
--- a/assets/scripts/install.sh
+++ b/assets/scripts/install.sh
@@ -172,6 +172,7 @@ check_goos_goarch() {
openbsd/amd64) return 0 ;;
openbsd/arm) return 0 ;;
openbsd/arm64) return 0 ;;
+ openbsd/ppc64) return 0 ;;
windows/386) return 0 ;;
windows/amd64) return 0 ;;
windows/arm) return 0 ;;
|
chore
|
Build with Go 1.22
|
86f9d94497e57ecac81b352af49b35b1924caefd
|
2022-01-09 22:06:33
|
Tom Payne
|
chore: Update dependencies
| false
|
diff --git a/go.mod b/go.mod
index 3a17bdc5e02..323c585939a 100644
--- a/go.mod
+++ b/go.mod
@@ -40,7 +40,7 @@ require (
github.com/spf13/viper v1.10.1
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
- github.com/twpayne/go-pinentry v0.0.2
+ github.com/twpayne/go-pinentry v0.1.0
github.com/twpayne/go-shell v0.3.1
github.com/twpayne/go-vfs/v4 v4.1.0
github.com/twpayne/go-xdg/v6 v6.0.0
@@ -50,7 +50,7 @@ require (
go.etcd.io/bbolt v1.3.6
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0
- golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98 // indirect
+ golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
diff --git a/go.sum b/go.sum
index f77c6155297..0fc9854c7bd 100644
--- a/go.sum
+++ b/go.sum
@@ -632,8 +632,8 @@ github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2bi
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
-github.com/twpayne/go-pinentry v0.0.2 h1:xncgnq3VGWgOq5gMx1SmK++7PrfvkvqZZY00SijBASs=
-github.com/twpayne/go-pinentry v0.0.2/go.mod h1:OUbsOnVXqvfSr8PZzFkSNJdBTJOPepfM0NSlDmR5paY=
+github.com/twpayne/go-pinentry v0.1.0 h1:Mp4/A85+WylApidOt0BKhuq+n0BThlAmn6FcCReCbuE=
+github.com/twpayne/go-pinentry v0.1.0/go.mod h1:r6buhMwARxnnL0VRBqfd1tE6Fadk1kfP00GRMutEspY=
github.com/twpayne/go-shell v0.3.1 h1:JIC6cyDpG/p8mRnFUleH07roi90q0J9QC8PnvtmYLRo=
github.com/twpayne/go-shell v0.3.1/go.mod h1:H/gzux0DOH5jsjQSHXs6rs2Onxy+V4j6ycZTOulC0l8=
github.com/twpayne/go-vfs/v3 v3.0.0 h1:rMFBISZVhSowKeX1BxL8utM64V7CuUw9/rfekPdS7to=
@@ -791,8 +791,8 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98 h1:+6WJMRLHlD7X7frgp7TUZ36RnQzSf9wVVTNakEp+nqY=
-golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
+golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
chore
|
Update dependencies
|
e3ddf11aa316c18af55b8fd33b3c3e8a68716d7b
|
2025-02-13 03:48:30
|
Tom Payne
|
chore: Tweak macOS test shards
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 930d74bed3e..3988a24fb81 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -171,9 +171,9 @@ jobs:
elif [ "${{ matrix.test-index }}" = "1" ]; then
go test ./internal/cmd -run=TestScript -filter='^[e-hE-H]' -race
elif [ "${{ matrix.test-index }}" = "2" ]; then
- go test ./internal/cmd -run=TestScript -filter='^[i-qI-Q]' -race
+ go test ./internal/cmd -run=TestScript -filter='^[i-lI-L]' -race
else
- go test ./internal/cmd -run=TestScript -filter='^[r-zR-Z]' -race
+ go test ./internal/cmd -run=TestScript -filter='^[m-zM-Z]' -race
fi
test-oldstable-go:
needs: changes
|
chore
|
Tweak macOS test shards
|
6fbb6aaa91fde0e9d1e668da30d326fce34401ed
|
2021-10-20 03:09:51
|
Tom Payne
|
chore: Add {Abs,Rel}Path.JoinStr functions
| false
|
diff --git a/internal/chezmoi/abspath.go b/internal/chezmoi/abspath.go
index 6461a05f899..7a3d9cd3847 100644
--- a/internal/chezmoi/abspath.go
+++ b/internal/chezmoi/abspath.go
@@ -54,14 +54,22 @@ func (p AbsPath) Ext() string {
return path.Ext(p.absPath)
}
-// Join appends elems to p.
-func (p AbsPath) Join(elems ...RelPath) AbsPath {
- elemStrs := make([]string, 0, len(elems)+1)
- elemStrs = append(elemStrs, p.absPath)
- for _, elem := range elems {
- elemStrs = append(elemStrs, string(elem))
+// Join returns a new AbsPath with relPaths appended.
+func (p AbsPath) Join(relPaths ...RelPath) AbsPath {
+ relPathStrs := make([]string, 0, len(relPaths)+1)
+ relPathStrs = append(relPathStrs, p.absPath)
+ for _, relPath := range relPaths {
+ relPathStrs = append(relPathStrs, string(relPath))
}
- return NewAbsPath(path.Join(elemStrs...))
+ return NewAbsPath(path.Join(relPathStrs...))
+}
+
+// JoinStr returns a new AbsPath with ss appended.
+func (p AbsPath) JoinStr(ss ...string) AbsPath {
+ strs := make([]string, 0, len(ss)+1)
+ strs = append(strs, p.absPath)
+ strs = append(strs, ss...)
+ return NewAbsPath(path.Join(strs...))
}
// Len returns the length of p.
diff --git a/internal/chezmoi/archivereadersystem.go b/internal/chezmoi/archivereadersystem.go
index 5a744e755f7..bdefbc92da5 100644
--- a/internal/chezmoi/archivereadersystem.go
+++ b/internal/chezmoi/archivereadersystem.go
@@ -80,7 +80,7 @@ func NewArchiveReaderSystem(archivePath string, data []byte, format ArchiveForma
if name == "" {
return nil
}
- nameAbsPath := options.RootAbsPath.Join(RelPath(name))
+ nameAbsPath := options.RootAbsPath.JoinStr(name)
s.fileInfos[nameAbsPath] = info
switch {
diff --git a/internal/chezmoi/gpgencryption.go b/internal/chezmoi/gpgencryption.go
index 75af134f47b..4806a13a64a 100644
--- a/internal/chezmoi/gpgencryption.go
+++ b/internal/chezmoi/gpgencryption.go
@@ -21,7 +21,7 @@ type GPGEncryption struct {
func (e *GPGEncryption) Decrypt(ciphertext []byte) ([]byte, error) {
var plaintext []byte
if err := withPrivateTempDir(func(tempDirAbsPath AbsPath) error {
- ciphertextAbsPath := tempDirAbsPath.Join(RelPath("ciphertext" + e.EncryptedSuffix()))
+ ciphertextAbsPath := tempDirAbsPath.JoinStr("ciphertext" + e.EncryptedSuffix())
if err := os.WriteFile(ciphertextAbsPath.String(), ciphertext, 0o600); err != nil {
return err
}
@@ -44,7 +44,7 @@ func (e *GPGEncryption) Decrypt(ciphertext []byte) ([]byte, error) {
// DecryptToFile implements Encryption.DecryptToFile.
func (e *GPGEncryption) DecryptToFile(plaintextFilename AbsPath, ciphertext []byte) error {
return withPrivateTempDir(func(tempDirAbsPath AbsPath) error {
- ciphertextAbsPath := tempDirAbsPath.Join(RelPath("ciphertext" + e.EncryptedSuffix()))
+ ciphertextAbsPath := tempDirAbsPath.JoinStr("ciphertext" + e.EncryptedSuffix())
if err := os.WriteFile(ciphertextAbsPath.String(), ciphertext, 0o600); err != nil {
return err
}
@@ -61,7 +61,7 @@ func (e *GPGEncryption) Encrypt(plaintext []byte) ([]byte, error) {
if err := os.WriteFile(plaintextAbsPath.String(), plaintext, 0o600); err != nil {
return err
}
- ciphertextAbsPath := tempDirAbsPath.Join(RelPath("ciphertext" + e.EncryptedSuffix()))
+ ciphertextAbsPath := tempDirAbsPath.JoinStr("ciphertext" + e.EncryptedSuffix())
args := e.encryptArgs(plaintextAbsPath, ciphertextAbsPath)
if err := e.run(args); err != nil {
@@ -81,7 +81,7 @@ func (e *GPGEncryption) Encrypt(plaintext []byte) ([]byte, error) {
func (e *GPGEncryption) EncryptFile(plaintextFilename AbsPath) ([]byte, error) {
var ciphertext []byte
if err := withPrivateTempDir(func(tempDirAbsPath AbsPath) error {
- ciphertextAbsPath := tempDirAbsPath.Join(RelPath("ciphertext" + e.EncryptedSuffix()))
+ ciphertextAbsPath := tempDirAbsPath.JoinStr("ciphertext" + e.EncryptedSuffix())
args := e.encryptArgs(plaintextFilename, ciphertextAbsPath)
if err := e.run(args); err != nil {
diff --git a/internal/chezmoi/path_unix.go b/internal/chezmoi/path_unix.go
index 5664cd4d170..fefce469bf3 100644
--- a/internal/chezmoi/path_unix.go
+++ b/internal/chezmoi/path_unix.go
@@ -38,7 +38,7 @@ func expandTilde(path string, homeDirAbsPath AbsPath) string {
case path == "~":
return homeDirAbsPath.String()
case strings.HasPrefix(path, "~/"):
- return homeDirAbsPath.Join(RelPath(path[2:])).String()
+ return homeDirAbsPath.JoinStr(path[2:]).String()
default:
return path
}
diff --git a/internal/chezmoi/path_windows.go b/internal/chezmoi/path_windows.go
index 0276c7b8852..89f94bcde6e 100644
--- a/internal/chezmoi/path_windows.go
+++ b/internal/chezmoi/path_windows.go
@@ -42,7 +42,7 @@ func expandTilde(path string, homeDirAbsPath AbsPath) string {
case path == "~":
return homeDirAbsPath.String()
case len(path) >= 2 && path[0] == '~' && isSlash(path[1]):
- return homeDirAbsPath.Join(RelPath(path[2:])).String()
+ return homeDirAbsPath.JoinStr(path[2:]).String()
default:
return path
}
diff --git a/internal/chezmoi/relpath.go b/internal/chezmoi/relpath.go
index b0aac32f304..f39fa5a439a 100644
--- a/internal/chezmoi/relpath.go
+++ b/internal/chezmoi/relpath.go
@@ -29,13 +29,21 @@ func (p RelPath) HasDirPrefix(dirPrefix RelPath) bool {
}
// Join appends elems to p.
-func (p RelPath) Join(elems ...RelPath) RelPath {
- elemStrs := make([]string, 0, len(elems)+1)
- elemStrs = append(elemStrs, string(p))
- for _, elem := range elems {
- elemStrs = append(elemStrs, string(elem))
+func (p RelPath) Join(relPaths ...RelPath) RelPath {
+ relPathStrs := make([]string, 0, len(relPaths)+1)
+ relPathStrs = append(relPathStrs, string(p))
+ for _, relPath := range relPaths {
+ relPathStrs = append(relPathStrs, string(relPath))
}
- return RelPath(path.Join(elemStrs...))
+ return RelPath(path.Join(relPathStrs...))
+}
+
+// JoinStr returns a new RelPath with ss appended.
+func (p RelPath) JoinStr(ss ...string) RelPath {
+ strs := make([]string, 0, len(ss)+1)
+ strs = append(strs, string(p))
+ strs = append(strs, ss...)
+ return RelPath(path.Join(strs...))
}
// Split returns p's directory and path.
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index 41ac196f9e0..0103643ac5e 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -744,7 +744,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
targetParentRelPath := parentSourceRelPath.TargetRelPath(s.encryption.EncryptedSuffix())
matches = matches[:n]
for _, match := range matches {
- targetRelPath := targetParentRelPath.Join(RelPath(match))
+ targetRelPath := targetParentRelPath.JoinStr(match)
sourceStateEntry := &SourceStateRemove{
targetRelPath: targetRelPath,
}
@@ -845,7 +845,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
if name == "." || name == ".." {
continue
}
- destEntryRelPath := targetRelPath.Join(RelPath(name))
+ destEntryRelPath := targetRelPath.JoinStr(name)
if _, ok := allSourceStateEntries[destEntryRelPath]; ok {
continue
}
@@ -995,7 +995,7 @@ func (s *SourceState) addPatterns(patternSet *patternSet, sourceAbsPath AbsPath,
include = false
text = mustTrimPrefix(text, "!")
}
- pattern := string(dir.Join(RelPath(text)))
+ pattern := string(dir.JoinStr(text))
if err := patternSet.add(pattern, include); err != nil {
return fmt.Errorf("%s:%d: %w", sourceAbsPath, lineNumber, err)
}
@@ -1099,7 +1099,7 @@ func (s *SourceState) getExternalDataRaw(ctx context.Context, externalRelPath Re
now = now.UTC()
cacheKey := hex.EncodeToString(SHA256Sum([]byte(external.URL)))
- cachedDataAbsPath := s.cacheDirAbsPath.Join("external", RelPath(cacheKey+"."+externalCacheFormat.Name()))
+ cachedDataAbsPath := s.cacheDirAbsPath.JoinStr("external", cacheKey+"."+externalCacheFormat.Name())
if options == nil || !options.RefreshExternals {
if data, err := s.system.ReadFile(cachedDataAbsPath); err == nil {
var externalCacheEntry externalCacheEntry
@@ -1627,7 +1627,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
if name == "" {
return nil
}
- targetRelPath := externalRelPath.Join(RelPath(name))
+ targetRelPath := externalRelPath.JoinStr(name)
if s.Ignore(targetRelPath) {
return nil
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 12642d24044..6b331c8c805 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -709,7 +709,7 @@ func (c *Config) defaultConfigFile(fileSystem vfs.Stater, bds *xdg.BaseDirectory
return chezmoi.EmptyAbsPath, err
}
for _, extension := range viper.SupportedExts {
- configFileAbsPath := configDirAbsPath.Join("chezmoi", chezmoi.RelPath("chezmoi."+extension))
+ configFileAbsPath := configDirAbsPath.JoinStr("chezmoi", "chezmoi."+extension)
if _, err := fileSystem.Stat(configFileAbsPath.String()); err == nil {
return configFileAbsPath, nil
}
diff --git a/internal/cmd/mergecmd.go b/internal/cmd/mergecmd.go
index f007f306478..fb6ff560b32 100644
--- a/internal/cmd/mergecmd.go
+++ b/internal/cmd/mergecmd.go
@@ -109,7 +109,7 @@ func (c *Config) doMerge(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi
return err
}
- targetStateAbsPath := tempDirAbsPath.Join(chezmoi.RelPath(targetRelPath.Base()))
+ targetStateAbsPath := tempDirAbsPath.JoinStr(targetRelPath.Base())
if err := c.baseSystem.WriteFile(targetStateAbsPath, contents, 0o600); err != nil {
return err
}
diff --git a/internal/cmd/templatefuncs.go b/internal/cmd/templatefuncs.go
index 5cffbc04d30..26d87e05ece 100644
--- a/internal/cmd/templatefuncs.go
+++ b/internal/cmd/templatefuncs.go
@@ -28,7 +28,7 @@ func (c *Config) includeTemplateFunc(filename string) string {
panic(err)
}
} else {
- absPath = c.SourceDirAbsPath.Join(chezmoi.RelPath(filename))
+ absPath = c.SourceDirAbsPath.JoinStr(filename)
}
contents, err := c.fileSystem.ReadFile(absPath.String())
if err != nil {
diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go
index 904ed4061f3..5afef1da280 100644
--- a/internal/cmd/upgradecmd.go
+++ b/internal/cmd/upgradecmd.go
@@ -381,7 +381,7 @@ func (c *Config) upgradePackage(ctx context.Context, rr *github.RepositoryReleas
return err
}
- packageFilename := tempDirAbsPath.Join(chezmoi.RelPath(releaseAsset.GetName()))
+ packageFilename := tempDirAbsPath.JoinStr(releaseAsset.GetName())
if err := c.baseSystem.WriteFile(packageFilename, data, 0o644); err != nil {
return err
}
|
chore
|
Add {Abs,Rel}Path.JoinStr functions
|
bd551abd539d6182c154a75d955cf0661ddcf949
|
2023-03-26 17:06:14
|
Tom Payne
|
chore: Add rbw version check to doctor command
| false
|
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go
index 56cddb22fd7..64be789b147 100644
--- a/pkg/cmd/doctorcmd.go
+++ b/pkg/cmd/doctorcmd.go
@@ -368,10 +368,13 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
minVersion: &passholeMinVersion,
},
&binaryCheck{
- name: "rbw-command",
- binaryname: c.RBW.Command,
- ifNotSet: checkResultWarning,
- ifNotExist: checkResultInfo,
+ name: "rbw-command",
+ binaryname: c.RBW.Command,
+ ifNotSet: checkResultWarning,
+ ifNotExist: checkResultInfo,
+ versionArgs: []string{"--version"},
+ versionRx: regexp.MustCompile(`^rbw\s+(\d+\.\d+\.\d+)`),
+ minVersion: &rbwMinVersion,
},
&binaryCheck{
name: "vault-command",
diff --git a/pkg/cmd/rbwtemplatefuncs.go b/pkg/cmd/rbwtemplatefuncs.go
index 9d3d92c875d..c09c0c41e33 100644
--- a/pkg/cmd/rbwtemplatefuncs.go
+++ b/pkg/cmd/rbwtemplatefuncs.go
@@ -6,6 +6,8 @@ import (
"os/exec"
"strings"
+ "github.com/coreos/go-semver/semver"
+
"github.com/twpayne/chezmoi/v2/pkg/chezmoilog"
)
@@ -14,6 +16,8 @@ type rbwConfig struct {
outputCache map[string][]byte
}
+var rbwMinVersion = semver.Version{Major: 1, Minor: 7, Patch: 0}
+
func (c *Config) rbwFieldsTemplateFunc(name string) map[string]any {
args := []string{"get", "--raw", name}
output, err := c.rbwOutput(args)
diff --git a/pkg/cmd/testdata/scripts/doctor_unix.txtar b/pkg/cmd/testdata/scripts/doctor_unix.txtar
index 33e59e4f931..a2dcb2f4152 100644
--- a/pkg/cmd/testdata/scripts/doctor_unix.txtar
+++ b/pkg/cmd/testdata/scripts/doctor_unix.txtar
@@ -13,6 +13,7 @@ chmod 755 bin/op
chmod 755 bin/pass
chmod 755 bin/ph
chmod 755 bin/pinentry
+chmod 755 bin/rbw
chmod 755 bin/secret
chmod 755 bin/shell
chmod 755 bin/vault
@@ -54,6 +55,7 @@ stdout '^ok\s+passhole-command\s+'
stdout '^ok\s+lastpass-command\s+'
stdout '^ok\s+pass-command\s+'
stdout '^ok\s+vault-command\s+'
+stdout '^ok\s+rbw-command\s+'
stdout '^ok\s+secret-command\s+'
chhome home2/user
@@ -155,6 +157,10 @@ echo "Copyright (C) 2016 g10 Code GmbH"
echo "License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>"
echo "This is free software: you are free to change and redistribute it."
echo "There is NO WARRANTY, to the extent permitted by law."
+-- bin/rbw --
+#!/bin/sh
+
+echo rbw 1.7.0
-- bin/secret --
#!/bin/sh
-- bin/shell --
|
chore
|
Add rbw version check to doctor command
|
1f92965e813aa636150e82c4558302f4620c535e
|
2022-05-30 02:21:31
|
Arvid Norlander
|
docs: Add information about chezmoi_modify_manager
| false
|
diff --git a/assets/chezmoi.io/docs/links/related-software.md b/assets/chezmoi.io/docs/links/related-software.md
index 0bd66d02252..12f65a2b5d0 100644
--- a/assets/chezmoi.io/docs/links/related-software.md
+++ b/assets/chezmoi.io/docs/links/related-software.md
@@ -29,3 +29,9 @@ chezmoi plugin for asdf version manager.
An add-on to synchronize your colorschemes across systems and allow easy
colorscheme switching using chezmoi templates.
+
+### [`github.com/VorpalBlade/chezmoi_modify_manager`](https://github.com/VorpalBlade/chezmoi_modify_manager)
+
+An add-on to deal with config files that contain a mix of settings and
+transient state, such as with GUI program settings files also containing
+recently used files and window positions.
diff --git a/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md b/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md
index a699cf4c9cc..b74a5532fdc 100644
--- a/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md
+++ b/assets/chezmoi.io/docs/user-guide/manage-different-types-of-file.md
@@ -80,6 +80,15 @@ substituted with:
current-context: {{ output "kubectl" "config" "current-context" | trim }}
```
+!!! hint
+
+ For managing ini files with a mix of settings and state (such as recently
+ used files or window positions), there is a third party tool called
+ `chezmoi_modify_manager` that builds upon `modify_` scripts. See
+ [related software](../links/related-software.md#githubcomvorpalbladechezmoi_modify_manager)
+ for more information.
+
+
## Manage a file's permissions, but not its contents
chezmoi's `create_` attributes allows you to tell chezmoi to create a file if
|
docs
|
Add information about chezmoi_modify_manager
|
4249bc195828365a28025485d345d1a016216b72
|
2024-11-04 00:49:40
|
Tom Payne
|
chore: Run shellcheck as a part of lint
| false
|
diff --git a/Makefile b/Makefile
index 64d15b8dd05..c0a3905b0cf 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ PREFIX?=/usr/local
default: build
.PHONY: smoke-test
-smoke-test: run build-all test lint shellcheck format
+smoke-test: run build-all test lint format
.PHONY: build
build:
@@ -115,7 +115,7 @@ generate:
${GO} generate
.PHONY: lint
-lint: ensure-actionlint ensure-editorconfig-checker ensure-find-typos ensure-golangci-lint
+lint: ensure-actionlint ensure-editorconfig-checker ensure-find-typos ensure-golangci-lint shellcheck
./bin/actionlint
./bin/editorconfig-checker
./bin/golangci-lint run
|
chore
|
Run shellcheck as a part of lint
|
153ff486c16ac654298225a15d8131201fe7c154
|
2023-09-04 00:57:58
|
Tom Payne
|
chore: Update dependencies
| false
|
diff --git a/go.mod b/go.mod
index a61167e3b16..4ad24dcc949 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
github.com/Shopify/ejson v1.4.1
github.com/alecthomas/assert/v2 v2.3.0
github.com/aws/aws-sdk-go-v2 v1.21.0
- github.com/aws/aws-sdk-go-v2/config v1.18.37
+ github.com/aws/aws-sdk-go-v2/config v1.18.38
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.3
github.com/bmatcuk/doublestar/v4 v4.6.0
github.com/bradenhilton/mozillainstallhash v1.0.1
@@ -47,8 +47,8 @@ require (
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/oauth2 v0.11.0
golang.org/x/sync v0.3.0
- golang.org/x/sys v0.11.0
- golang.org/x/term v0.11.0
+ golang.org/x/sys v0.12.0
+ golang.org/x/term v0.12.0
gopkg.in/ini.v1 v1.67.0
gopkg.in/yaml.v3 v3.0.1
howett.net/plist v1.0.0
@@ -70,13 +70,13 @@ require (
github.com/alecthomas/repr v0.2.0 // indirect
github.com/alessio/shellescape v1.4.2 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
- github.com/aws/aws-sdk-go-v2/credentials v1.13.35 // indirect
+ github.com/aws/aws-sdk-go-v2/credentials v1.13.36 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect
- github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect
+ github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect
github.com/aws/smithy-go v1.14.2 // indirect
@@ -133,7 +133,7 @@ require (
github.com/yuin/goldmark-emoji v1.0.2 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
- golang.org/x/text v0.12.0 // indirect
+ golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
diff --git a/go.sum b/go.sum
index 75dbb8f4e40..0c57da155a2 100644
--- a/go.sum
+++ b/go.sum
@@ -52,10 +52,10 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc=
github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M=
-github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI=
-github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ=
-github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8=
-github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8=
+github.com/aws/aws-sdk-go-v2/config v1.18.38 h1:CByQCELMgm2tM1lAehx3XNg0R/pfeXsYzqn0Aq2chJQ=
+github.com/aws/aws-sdk-go-v2/config v1.18.38/go.mod h1:vNm9Hf5VgG2fSUWhT3zFrqN/RosGcabFMYgiSoxKFU8=
+github.com/aws/aws-sdk-go-v2/credentials v1.13.36 h1:ps0cPswZjpsOk6sLwG6fdXTzrYjCplgPEyG3OUbbdqE=
+github.com/aws/aws-sdk-go-v2/credentials v1.13.36/go.mod h1:sY2phUzxbygoyDtTXhqi7GjGjCQ1S5a5Rj8u3ksBxCg=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g=
@@ -68,8 +68,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKi
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o=
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.3 h1:H6ZipEknzu7RkJW3w2PP75zd8XOdR35AEY5D57YrJtA=
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.3/go.mod h1:5W2cYXDPabUmwULErlC92ffLhtTuyv4ai+5HhdbhfNo=
-github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0=
-github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4=
+github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 h1:2PylFCfKCEDv6PeSN09pC/VUiRd10wi1VfHG5FrW0/g=
+github.com/aws/aws-sdk-go-v2/service/sso v1.13.6/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4=
github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ=
@@ -414,15 +414,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
-golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
+golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
-golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
-golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
+golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
+golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -431,8 +431,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
-golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
chore
|
Update dependencies
|
b7292bedabceb17d1a8394be86ace17c9fd655e0
|
2022-03-24 13:55:19
|
Austin Ziegler
|
chore: Improve 1Password CLI 2.0.0 support
| false
|
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md b/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md
index 9cc544105ee..d22ce4f5c5c 100644
--- a/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md
+++ b/assets/chezmoi.io/docs/reference/templates/functions/onepassword.md
@@ -2,49 +2,76 @@
`onepassword` returns structured data from [1Password](https://1password.com/)
using the [1Password
-CLI](https://support.1password.com/command-line-getting-started/) (`op`).
-*uuid* is passed to `op get item $UUID` and the output from `op` is parsed as
-JSON. The output from `op` is cached so calling `onepassword` multiple times
-with the same *uuid* will only invoke `op` once. If the optional *vault-uuid*
-is supplied, it will be passed along to the `op get` call, which can
-significantly improve performance. If the optional *account-name* is supplied,
-it will be passed along to the `op get` call, which will help it look in the
-right account, in case you have multiple accounts (eg. personal and work
-accounts). If there is no valid session in the environment, by default you will
-be interactively prompted to sign in.
+CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid*
+is passed to `op item get $UUID --format json` and the output from `op`. The
+output from `op` is cached so calling `onepassword` multiple times with the same
+*uuid* will only invoke `op` once. If the optional *vault-uuid* is supplied, it
+will be passed along to the `op item get` call, which can significantly improve
+performance. If the optional *account-name* is supplied, it will be passed along
+to the `op item get` call, which will help it look in the right account, in case
+you have multiple accounts (e.g., personal and work accounts).
+
+If there is no valid session in the environment, by default you will be
+interactively prompted to sign in.
!!! example
```
- {{ (onepassword "$UUID").details.password }}
- {{ (onepassword "$UUID" "$VAULT_UUID").details.password }}
- {{ (onepassword "$UUID" "$VAULT_UUID" "$ACCOUNT_NAME").details.password }}
+ {{ (onepassword "$UUID").fields[1].value }}
+ {{ (onepassword "$UUID" "$VAULT_UUID").fields[1].value }}
+ {{ (onepassword "$UUID" "$VAULT_UUID" "$ACCOUNT_NAME").fields[1].value }}
+ {{ (onepassword "$UUID" "" "$ACCOUNT_NAME").fields[1].value }}
```
- If using 1Password 1.0, then *vault-uuid* is optional.
+ A more robust way to get a password field would be something like:
```
- {{ (onepassword "$UUID" "" "$ACCOUNT_NAME").details.password }}
+ {{ range (onepassword "$UUID").fields -}}
+ {{- if and (eq .label "password") (eq .purpose "PASSWORD") }}{{ .value }}{{ end -}}
+ {{- end }}
```
-!!! info
+ ??? info
+
+ For 1Password CLI 1.x.
+
+ ```
+ {{ (onepassword "$UUID").details.password }}
+ {{ (onepassword "$UUID" "$VAULT_UUID").details.password }}
+ {{ (onepassword "$UUID" "$VAULT_UUID" "$ACCOUNT_NAME").details.password }}
+ {{ (onepassword "$UUID" "" "$ACCOUNT_NAME").details.password }}
+ ```
- If you're using [1Password CLI 2.0](https://developer.1password.com/), there
- are changes to be aware of.
+!!! danger
- !!! warning
+ When using [1Password CLI 2.0](https://developer.1password.com/), note that
+ the structure of the data returned by the `onepassword` template function
+ is different and your templates will need updating.
- The structure of the data returned by the `onepassword` template function
- will be different and you will need to update your templates. The structure
- has not yet been finalized.
+ You may wish to use `onepasswordDetailsFields` or `onepasswordItemFields`
+ instead of this function, as `onepassword` returns fields as a list of
+ objects. However, this function may return values that are inaccessible from
+ the other functions. Testing the output of this function is recommended:
- !!! warning
+ ```console
+ chezmoi execute-template "{{- onepassword \"$UUID\" | toJson -}}" | jq .
+ ```
+
+!!! warning
- Neither *vault-uuid* nor *account-name* may be empty strings if specified.
- Older versions of 1Password CLI would ignore empty strings for arguments.
+ When using 1Password CLI 2.0, there may be an issue with pre-authenticating
+ `op` because the environment variable used to store the session key has
+ changed from `OP_SESSION_account` to `OP_SESSION_accountUUID`. Instead of
+ using *account-name*, it is recommended that you use the *account-uuid*.
+ This can be found using `op account list`.
- !!! warning
+ This issue does not exist when using biometric authentication and 1Password
+ 8, or if you allow chezmoi to prompt you for 1Password authentication
+ (`1password.prompt = true`).
+
+!!! info
- Unless using biometric authentication, or when using without prompting, it
- is recommended that instead of *account-name*, the UUID of the account is
- used. This can be shown with `op account list`.
+ In earlier versions of chezmoi, if *vault-uuid* or *account-name* were
+ empty strings, they would be added to the resulting `op` command-line
+ (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments
+ will no longer be added.
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md
index 632114443d7..339cbbf2fd8 100644
--- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md
+++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDetailsFields.md
@@ -2,19 +2,19 @@
`onepasswordDetailsFields` returns structured data from
[1Password](https://1password.com/) using the [1Password
-CLI](https://support.1password.com/command-line-getting-started/) (`op`).
-*uuid* is passed to `op get item $UUID`, the output from `op` is parsed as
-JSON, and elements of `details.fields` are returned as a map indexed by each
-field's `designation`. If there is no valid session in the environment, by
-default you will be interactively prompted to sign in.
+CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid*
+is passed to `op get item $UUID`, the output from `op` is parsed as JSON, and
+elements of `details.fields` are returned as a map indexed by each field's
+`designation`. If there is no valid session in the environment, by default you
+will be interactively prompted to sign in.
The output from `op` is cached so calling `onepasswordDetailsFields` multiple
-times with the same *uuid* will only invoke `op` once. If the optional
+times with the same *uuid* will only invoke `op` once. If the optional
*vault-uuid* is supplied, it will be passed along to the `op get` call, which
can significantly improve performance. If the optional *account-name* is
supplied, it will be passed along to the `op get` call, which will help it look
-in the right account, in case you have multiple accounts (eg. personal and work
-accounts).
+in the right account, in case you have multiple accounts (e.g., personal and
+work accounts).
!!! example
@@ -22,11 +22,6 @@ accounts).
{{ (onepasswordDetailsFields "$UUID").password.value }}
{{ (onepasswordDetailsFields "$UUID" "$VAULT_UUID").password.value }}
{{ (onepasswordDetailsFields "$UUID" "$VAULT_UUID" "$ACCOUNT_NAME").password.value }}
- ```
-
- If using 1Password 1.0, then *vault-uuid* is optional.
-
- ```
{{ (onepasswordDetailsFields "$UUID" "" "$ACCOUNT_NAME").password.value }}
```
@@ -75,24 +70,35 @@ accounts).
}
```
-!!! info
+!!! danger
+
+ When using [1Password CLI 2.0](https://developer.1password.com/), note that
+ the structure of the data returned by the `onepasswordDetailsFields`
+ template function is different and your templates will need updating.
- If you're using [1Password CLI 2.0](https://developer.1password.com/), there
- are changes to be aware of.
+ You may wish to use `onepassword` or `onepasswordItemFields` instead of this
+ function, as it may not return expected values. Testing the output of this
+ function is recommended:
- !!! warning
+ ```console
+ chezmoi execute-template "{{- onepasswordDetailsFields \"$UUID\" | toJson -}}" | jq .
+ ```
- The structure of the data returned by the `onepasswordDetailsFields`
- template function will be different and you will need to update your
- templates. The structure has not yet been finalized.
+!!! warning
- !!! warning
+ When using 1Password CLI 2.0, there may be an issue with pre-authenticating
+ `op` because the environment variable used to store the session key has
+ changed from `OP_SESSION_account` to `OP_SESSION_accountUUID`. Instead of
+ using *account-name*, it is recommended that you use the *account-uuid*.
+ This can be found using `op account list`.
- Neither *vault-uuid* nor *account-name* may be empty strings if specified.
- Older versions of 1Password CLI would ignore empty strings for arguments.
+ This issue does not exist when using biometric authentication and 1Password
+ 8, or if you allow chezmoi to prompt you for 1Password authentication
+ (`1password.prompt = true`).
- !!! warning
+!!! info
- Unless using biometric authentication, or when using without prompting, it
- is recommended that instead of *account-name*, the UUID of the account is
- used. This can be shown with `op account list`.
+ In earlier versions of chezmoi, if *vault-uuid* or *account-name* were
+ empty strings, they would be added to the resulting `op` command-line
+ (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments
+ will no longer be added.
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md
index 31726f2ec16..9fbed7f6f65 100644
--- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md
+++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordDocument.md
@@ -1,17 +1,17 @@
# `onepasswordDocument` *uuid* [*vault-uuid* [*account-name*]]
-`onepassword` returns a document from [1Password](https://1password.com/) using
-the [1Password
-CLI](https://support.1password.com/command-line-getting-started/) (`op`).
-*uuid* is passed to `op get document $UUID` and the output from `op` is
-returned. The output from `op` is cached so calling `onepasswordDocument`
-multiple times with the same *uuid* will only invoke `op` once. If the
-optional *vault-uuid* is supplied, it will be passed along to the `op get`
-call, which can significantly improve performance. If the optional
-*account-name* is supplied, it will be passed along to the `op get` call, which
-will help it look in the right account, in case you have multiple accounts (eg.
-personal and work accounts). If there is no valid session in the environment,
-by default you will be interactively prompted to sign in.
+`onepasswordDocument` returns a document from
+[1Password](https://1password.com/) using the [1Password
+CLI](https://support.1password.com/command-line-getting-started/) (`op`). *uuid*
+is passed to `op get document $UUID` and the output from `op` is returned. The
+output from `op` is cached so calling `onepasswordDocument` multiple times with
+the same *uuid* will only invoke `op` once. If the optional *vault-uuid* is
+supplied, it will be passed along to the `op get` call, which can significantly
+improve performance. If the optional *account-name* is supplied, it will be
+passed along to the `op get` call, which will help it look in the right account,
+in case you have multiple accounts (e.g., personal and work accounts). If there
+is no valid session in the environment, by default you will be interactively
+prompted to sign in.
!!! example
@@ -19,26 +19,25 @@ by default you will be interactively prompted to sign in.
{{- onepasswordDocument "$UUID" -}}
{{- onepasswordDocument "$UUID" "$VAULT_UUID" -}}
{{- onepasswordDocument "$UUID" "$VAULT_UUID" "$ACCOUNT_NAME" -}}
- ```
-
- If using 1Password 1.0, then *vault-uuid* is optional.
-
- ```
{{- onepasswordDocument "$UUID" "" "$ACCOUNT_NAME" -}}
```
-!!! info
-
- If you're using [1Password CLI 2.0](https://developer.1password.com/), there
- are changes to be aware of.
+!!! warning
- !!! warning
+ When you're using [1Password CLI 2.0](https://developer.1password.com/),
+ there may be an issue with pre-authenticated usage of `op`. The environment
+ variable used to store the session key has changed from `OP_SESSION_account`
+ to `OP_SESSION_accountUUID`. Instead of using *account-name*, it is
+ recommended that you use the *account-uuid*. This can be found using `op
+ account list`.
- Neither *vault-uuid* nor *account-name* may be empty strings if specified.
- Older versions of 1Password CLI would ignore empty strings for arguments.
+ This issue does not exist when using biometric authentication and 1Password
+ 8, or if you allow chezmoi to prompt you for 1Password authentication
+ (`1password.prompt = true`).
- !!! warning
+!!! info
- Unless using biometric authentication, or when using without prompting, it
- is recommended that instead of *account-name*, the UUID of the account is
- used. This can be shown with `op account list`.
+ In earlier versions of chezmoi, if *vault-uuid* or *account-name* were
+ empty strings, they would be added to the resulting `op` command-line
+ (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments
+ will no longer be added.
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md
index d868077329d..2da73414462 100644
--- a/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md
+++ b/assets/chezmoi.io/docs/reference/templates/functions/onepasswordItemFields.md
@@ -1,54 +1,74 @@
-# `onepasswordItemFields` *uuid* [*vault-uuid* [*account-name*]]
+# `onepasswordItemFields` _uuid_ [_vault-uuid_ [*account-name*]]
`onepasswordItemFields` returns structured data from
[1Password](https://1password.com/) using the [1Password
-CLI](https://support.1password.com/command-line-getting-started/) (`op`).
-*uuid* is passed to `op get item $UUID`, the output from `op` is parsed as
-JSON, and each element of `details.sections` are iterated over and any `fields`
-are returned as a map indexed by each field's `n`. If there is no valid session
-in the environment, by default you will be interactively prompted to sign in.
+CLI](https://support.1password.com/command-line-getting-started/) (`op`). _uuid_
+is passed to `op item get $UUID --format json`, the output from `op` is parsed
+as JSON, and each element of `details.sections` are iterated over and any
+`fields` are returned as a map indexed by each field's `n`.
+
+If there is no valid session in the environment, by default you will be
+interactively prompted to sign in.
!!! example
The result of
```
- {{ (onepasswordItemFields "abcdefghijklmnopqrstuvwxyz").exampleLabel.v }}
+ {{ (onepasswordItemFields "abcdefghijklmnopqrstuvwxyz").exampleLabel.value }}
```
is equivalent to calling
```console
- $ op get item abcdefghijklmnopqrstuvwxyz --fields exampleLabel
+ $ op item get abcdefghijklmnopqrstuvwxyz --fields label=exampleLabel
+ # or
+ $ op item get abcdefghijklmnopqrstuvwxyz --fields exampleLabel
```
+ ??? info
+
+ For 1Password CLI 1.x.
+
+ ```
+ {{ (onepasswordItemFields "abcdefghijklmnopqrstuvwxyz").exampleLabel.v }}
+ ```
+
+ is equivalent to calling
+
+ ```console
+ $ op get item abcdefghijklmnopqrstuvwxyz --fields exampleLabel
+ ```
!!! example
Given the output from `op`:
```json
{
- "uuid": "$UUID",
- "details": {
- "sections": [
- {
- "name": "linked items",
- "title": "Related Items"
- },
- {
- "fields": [
- {
- "k": "string",
- "n": "D4328E0846D2461E8E455D7A07B93397",
- "t": "exampleLabel",
- "v": "exampleValue"
- }
- ],
- "name": "Section_20E0BD380789477D8904F830BFE8A121",
- "title": ""
- }
- ]
+ "id": "$UUID",
+ "title": "$TITLE",
+ "version": 1,
+ "vault": {
+ "id": "$vaultUUID"
},
+ "category": "LOGIN",
+ "last_edited_by": "userUUID",
+ "created_at": "2022-01-12T16:29:26Z",
+ "updated_at": "2022-01-12T16:29:26Z",
+ "sections": [
+ {
+ "id": "$sectionID",
+ "label": "Related Items"
+ }
+ ],
+ "fields": [
+ {
+ "id": "nerlnqbfzdm5q5g6ydsgdqgdw4",
+ "type": "STRING",
+ "label": "exampleLabel",
+ "value": "exampleValue"
+ }
+ ],
}
```
@@ -57,32 +77,86 @@ in the environment, by default you will be interactively prompted to sign in.
```json
{
"exampleLabel": {
- "k": "string",
- "n": "D4328E0846D2461E8E455D7A07B93397",
- "t": "exampleLabel",
- "v": "exampleValue"
+ "id": "string",
+ "type": "D4328E0846D2461E8E455D7A07B93397",
+ "label": "exampleLabel",
+ "value": "exampleValue"
}
}
```
+ ??? info
+
+ For 1Password CLI 1.x, the output is this:
+
+ ```json
+ {
+ "uuid": "$UUID",
+ "details": {
+ "sections": [
+ {
+ "name": "linked items",
+ "title": "Related Items"
+ },
+ {
+ "fields": [
+ {
+ "k": "string",
+ "n": "D4328E0846D2461E8E455D7A07B93397",
+ "t": "exampleLabel",
+ "v": "exampleValue"
+ }
+ ],
+ "name": "Section_20E0BD380789477D8904F830BFE8A121",
+ "title": ""
+ }
+ ]
+ },
+ }
+ ```
+
+ the return value of `onepasswordItemFields` will be the map:
+
+ ```json
+ {
+ "exampleLabel": {
+ "k": "string",
+ "n": "D4328E0846D2461E8E455D7A07B93397",
+ "t": "exampleLabel",
+ "v": "exampleValue"
+ }
+ }
+ ```
+
!!! info
- If you're using [1Password CLI 2.0](https://developer.1password.com/), there
- are changes to be aware of.
+ When using [1Password CLI 2.0](https://developer.1password.com/), note that
+ the structure of the data returned by the `onepasswordItemFields` template
+ function is different and your templates will need updating.
- !!! warning
+ You may wish to use `onepassword` or `onepasswordDetailsFields` instead of
+ this function, as it may not return expected values. Testing the output of
+ this function is recommended:
- The structure of the data returned by the `onepasswordItemFields` template
- function will be different and you will need to update your templates. The
- structure has not yet been finalized.
+ ```console
+ chezmoi execute-template "{{- onepasswordItemFields \"$UUID\" | toJson -}}" | jq .
+ ```
- !!! warning
+!!! warning
- Neither *vault-uuid* nor *account-name* may be empty strings if specified.
- Older versions of 1Password CLI would ignore empty strings for arguments.
+ When using 1Password CLI 2.0, there may be an issue with pre-authenticating
+ `op` because the environment variable used to store the session key has
+ changed from `OP_SESSION_account` to `OP_SESSION_accountUUID`. Instead of
+ using *account-name*, it is recommended that you use the *account-uuid*.
+ This can be found using `op account list`.
- !!! warning
+ This issue does not exist when using biometric authentication and 1Password
+ 8, or if you allow chezmoi to prompt you for 1Password authentication
+ (`1password.prompt = true`).
+
+!!! info
- Unless using biometric authentication, or when using without prompting, it
- is recommended that instead of *account-name*, the UUID of the account is
- used. This can be shown with `op account list`.
+ In earlier versions of chezmoi, if *vault-uuid* or *account-name* were
+ empty strings, they would be added to the resulting `op` command-line
+ (`--vault ''`). This causes errors in 1Password CLI 2.0, so those arguments
+ will no longer be added.
diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/1password.md b/assets/chezmoi.io/docs/user-guide/password-managers/1password.md
index 1bd6cb8fed4..f6b7807adfe 100644
--- a/assets/chezmoi.io/docs/user-guide/password-managers/1password.md
+++ b/assets/chezmoi.io/docs/user-guide/password-managers/1password.md
@@ -4,38 +4,142 @@ chezmoi includes support for [1Password](https://1password.com/) using the
[1Password CLI](https://support.1password.com/command-line-getting-started/) to
expose data as a template function.
+!!! note
+
+ [1Password CLI 2.0](https://developer.1password.com/) has been released.
+ Examples will be shown using the changed details for this version and
+ examples for 1Password CLI 1.x will follow.
+
Log in and get a session using:
```console
-$ eval $(op signin $SUBDOMAIN.1password.com $EMAIL)
+# For 1Password 2.x. Neither step is necessary with biometric authentication.
+$ op account add --address $SUBDOMAIN.1password.com --email $EMAIL
+$ eval $(op signin --account $SUBDOMAIN)
```
-The output of `op get item $UUID` is available as the `onepassword` template
-function. chezmoi parses the JSON output and returns it as structured data. For
-example, if the output of `op get item $UUID` is:
+??? info
+
+ ```console
+ # For 1Password 1.x
+ $ eval $(op signin $SUBDOMAIN.1password.com $EMAIL)
+ ```
+
+The output of `op item get $UUID--format json` (`op get item $UUID`) is
+available as the `onepassword` template function. chezmoi parses the JSON output
+and returns it as structured data. For example, if the output is:
```json
{
- "uuid": "$UUID",
- "details": {
- "password": "$PASSWORD"
+ "id": "$UUID",
+ "title": "$TITLE",
+ "version": 2,
+ "vault": {
+ "id": "$vaultUUID"
+ },
+ "category": "LOGIN",
+ "last_edited_by": "$userUUID",
+ "created_at": "2010-08-23T13:18:43Z",
+ "updated_at": "2014-07-20T04:40:11Z",
+ "fields": [
+ {
+ "id": "username",
+ "type": "STRING",
+ "purpose": "USERNAME",
+ "label": "username",
+ "value": "$USERNAME"
+ },
+ {
+ "id": "password",
+ "type": "CONCEALED",
+ "purpose": "PASSWORD",
+ "label": "password",
+ "value": "$PASSWORD",
+ "password_details": {
+ "strength": "FANTASTIC",
+ "history": []
+ }
+ }
+ ],
+ "urls": [
+ {
+ "primary": true,
+ "href": "$URL"
}
+ ]
}
```
-Then you can access `details.password` with the syntax:
+Then you can access the password field with the syntax
```
-{{ (onepassword "$UUID").details.password }}
+{{ (onepassword "$UUID").fields[1].value }}
```
-Login details fields can be retrieved with the `onepasswordDetailsFields`
-function, for example:
+or:
+
+```
+{{ range (onepassword "$UUID").fields -}}
+{{- if and (eq .label "password") (eq .purpose "PASSWORD") }}{{ .value }}{{ end -}}
+{{- end }}
+```
+
+??? info
+
+ 1Password CLI 1.x returns a simpler structure:
+
+ ```json
+ {
+ "uuid": "$UUID",
+ "details": {
+ "password": "$PASSWORD"
+ }
+ }
+ ```
+
+ This allows for the syntax:
+
+ ```
+ {{ (onepassword "$UUID").details.password }}
+ ```
+
+`onepasswordDetailsFields` returns a reworked version of the structure that
+allows the fields to be queried by key:
+
+```json
+{
+ "password": {
+ "id": "password",
+ "label": "password",
+ "password_details": {
+ "history": [],
+ "strength": "FANTASTIC"
+ },
+ "purpose": "PASSWORD",
+ "type": "CONCEALED",
+ "value": "$PASSWORD"
+ },
+ "username": {
+ "id": "username",
+ "label": "username",
+ "purpose": "USERNAME",
+ "type": "STRING",
+ "value": "$USERNAME"
+ }
+}
+```
```
{{- (onepasswordDetailsFields "$UUID").password.value }}
```
+Additional fields may be obtained with `onePasswordItemFields`; not all objects
+in 1Password have item fields, so it is worth testing before using:
+
+```console
+chezmoi execute-template "{{- onepasswordItemFields \"$UUID\" | toJson -}}" | jq .
+```
+
Documents can be retrieved with:
```
@@ -64,16 +168,16 @@ your configuration file:
prompt = false
```
-!!! warning
+!!! danger
Do not use the prompt on shared machines. A session token verified or
- acquired interactively will be passed to the 1Password CLI through a
- command line parameter, which is visible to other users of the same system.
+ acquired interactively will be passed to the 1Password CLI through a command
+ line parameter, which is visible to other users of the same system.
!!! info
If you're using [1Password CLI
2.0](https://developer.1password.com/docs/cli/), then the structure of the
data returned by the `onepassword`, `onepasswordDetailsFields`, and
- `onePasswordItemFiles` template functions will be different and you will
- need to update your templates.
+ `onePasswordItemFiles` template functions is different and templates will
+ need to be updated.
diff --git a/pkg/cmd/onepasswordtemplatefuncs.go b/pkg/cmd/onepasswordtemplatefuncs.go
index feea0bd13d7..d65156d3515 100644
--- a/pkg/cmd/onepasswordtemplatefuncs.go
+++ b/pkg/cmd/onepasswordtemplatefuncs.go
@@ -398,11 +398,11 @@ func newOnepasswordArgs(baseArgs, userArgs []string) (*onepasswordArgs, error) {
}
a.item = userArgs[0]
a.args = append(a.args, a.item)
- if len(userArgs) > 1 {
+ if len(userArgs) > 1 && userArgs[1] != "" {
a.vault = userArgs[1]
a.args = append(a.args, "--vault", a.vault)
}
- if len(userArgs) > 2 {
+ if len(userArgs) > 2 && userArgs[2] != "" {
a.account = userArgs[2]
a.args = append(a.args, "--account", a.account)
}
diff --git a/pkg/cmd/testdata/scripts/onepassword.txt b/pkg/cmd/testdata/scripts/onepassword.txt
index c170f1ced50..1062b307f71 100644
--- a/pkg/cmd/testdata/scripts/onepassword.txt
+++ b/pkg/cmd/testdata/scripts/onepassword.txt
@@ -28,7 +28,7 @@ case "$*" in
"--version")
echo 1.3.0
;;
-"get item ExampleLogin" | "get item ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken get item ExampleLogin" | "--session thisIsAFakeSessionToken get item ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken get item ExampleLogin --vault --account account")
+"get item ExampleLogin" | "get item ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken get item ExampleLogin" | "--session thisIsAFakeSessionToken get item ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken get item ExampleLogin --account account")
echo '{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}'
;;
"signin --raw" | "signin account --raw")
@@ -46,13 +46,13 @@ IF "%*" == "--version" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
) ELSE IF "%*" == "get item ExampleLogin --vault vault --account account" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
-) ELSE IF "%*" == "get item ExampleLogin --vault '''' --account account" (
+) ELSE IF "%*" == "get item ExampleLogin --account account" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
) ELSE IF "%*" == "--session thisIsAFakeSessionToken get item ExampleLogin" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
) ELSE IF "%*" == "--session thisIsAFakeSessionToken get item ExampleLogin --vault vault --account account" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken get item ExampleLogin --vault '''' --account account" (
+) ELSE IF "%*" == "--session thisIsAFakeSessionToken get item ExampleLogin --account account" (
echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[{"name":"linked items","title":"Related Items"},{"fields":[{"k":"string","n":"D4328E0846D2461E8E455D7A07B93397","t":"exampleLabel","v":"exampleValue"}],"name":"Section_20E0BD380789477D8904F830BFE8A121","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
) ELSE IF "%*" == "signin --raw" (
echo thisIsAFakeSessionToken
diff --git a/pkg/cmd/testdata/scripts/onepassword2.txt b/pkg/cmd/testdata/scripts/onepassword2.txt
index 68dc6fa259d..f561563f407 100644
--- a/pkg/cmd/testdata/scripts/onepassword2.txt
+++ b/pkg/cmd/testdata/scripts/onepassword2.txt
@@ -9,9 +9,9 @@ stdout '^wxcplh5udshnonkzg2n4qx262y$'
chezmoi execute-template '{{ (onepassword "ExampleLogin" "vault" "account").id }}'
stdout '^wxcplh5udshnonkzg2n4qx262y$'
-# test onepassword template function with empty vault and account
-! chezmoi execute-template '{{ (onepassword "ExampleLogin" "" "account").id }}'
-stderr 'error calling onepassword'
+# test onepassword template function with empty vault
+chezmoi execute-template '{{ (onepassword "ExampleLogin" "" "account").id }}'
+stdout '^wxcplh5udshnonkzg2n4qx262y$'
# test onepasswordDetailsFields template function
chezmoi execute-template '{{ (onepasswordDetailsFields "ExampleLogin").password.value }}'
@@ -28,13 +28,9 @@ case "$*" in
"--version")
echo 2.0.0
;;
-"item get --format json ExampleLogin" | "item get --format json ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account")
+"item get --format json ExampleLogin" | "item get --format json ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account")
echo '{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}'
;;
-"item get --format json ExampleLogin --vault --account account" | "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault --account account")
- echo "[ERROR] 2020/01/01 00:00:00 invalid argument \"\" for \"--vault\" flag: it\'s empty." 1>&2
- exit 1
- ;;
"signin --raw" | "signin --account account --raw")
echo 'thisIsAFakeSessionToken'
;;
@@ -50,16 +46,14 @@ IF "%*" == "--version" (
echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
) ELSE IF "%*" == "item get --format json ExampleLogin --vault vault --account account" (
echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "item get --format json ExampleLogin --vault '''' --account account" (
- echo.[ERROR] 2020/01/01 00:00:00 invalid argument "" for "--vault" flag: it\'s empty. 1>&2
- exit /b 1
+) ELSE IF "%*" == "item get --format json ExampleLogin --account account" (
+ echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin" (
echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault vault --account account" (
echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
-) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --vault '''' --account account" (
- echo.[ERROR] 2020/01/01 00:00:00 invalid argument "" for "--vault" flag: it\'s empty. 1>&2
- exit /b 1
+) ELSE IF "%*" == "--session thisIsAFakeSessionToken item get --format json ExampleLogin --account account" (
+ echo.{"id":"wxcplh5udshnonkzg2n4qx262y","title":"ExampleLogin","version":1,"vault":{"id":"tscpxgi6s7c662jtqn3vmw4n5a"},"category":"LOGIN","last_edited_by":"YO4UTYPAD3ZFBNZG5DVAZFBNZM","created_at":"2022-01-17T01:53:50Z","updated_at":"2022-01-17T01:55:35Z","sections":[{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"}],"fields":[{"id":"username","type":"STRING","purpose":"USERNAME","label":"username","value":"exampleuser "},{"id":"password","type":"CONCEALED","purpose":"PASSWORD","label":"password","value":"L8rm1JXJIE1b8YUDWq7h","password_details":{"strength":"EXCELLENT"}},{"id":"notesPlain","type":"STRING","purpose":"NOTES","label":"notesPlain"},{"id":"cqn7oda7wkcsar7rzcr52i2m3u","section":{"id":"Section_cdzjhg2jo7jylpyin2f5mbfnhm","label":"Related Items"},"type":"STRING","label":"exampleLabel","value":"exampleValue"}],"urls":[{"primary":true,"href":"https://www.example.com/"}]}
) ELSE IF "%*" == "signin --raw" (
echo thisIsAFakeSessionToken
) ELSE IF "%*" == "signin --account account --raw" (
|
chore
|
Improve 1Password CLI 2.0.0 support
|
9fd2934d60f9d3f9d4b952c1fc52b8e0d61b45e5
|
2021-12-27 02:23:00
|
Tim Byrne
|
docs: Update yadm comparison (scripts)
| false
|
diff --git a/docs/COMPARISON.md b/docs/COMPARISON.md
index 434d9a8fe03..b07b8446142 100644
--- a/docs/COMPARISON.md
+++ b/docs/COMPARISON.md
@@ -43,8 +43,8 @@
| Manage partial files | ✅ | ❌ | ❌ | ❌ | ⁉️ | ✅ | ⁉️ |
| File removal | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
| Directory creation | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
-| Run scripts | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
-| Run once scripts | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
+| Run scripts | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ |
+| Run once scripts | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
| Machine-to-machine symlink differences | ✅ | ❌ | ❌ | ❌ | ⁉️ | ✅ | ⁉️ |
| Shell completion | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Archive import | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ✅ |
|
docs
|
Update yadm comparison (scripts)
|
a73febb407b16ab44adfa51e82308e6f39535006
|
2023-11-09 07:49:59
|
Tom Payne
|
chore: Remove unused version infrastructure
| false
|
diff --git a/internal/cmd/errors.go b/internal/cmd/errors.go
index b11c3bad27b..ac957bb0375 100644
--- a/internal/cmd/errors.go
+++ b/internal/cmd/errors.go
@@ -3,8 +3,6 @@ package cmd
import (
"fmt"
"os/exec"
-
- "github.com/coreos/go-semver/semver"
)
type cmdOutputError struct {
@@ -34,14 +32,6 @@ func (e *cmdOutputError) Unwrap() error {
return e.err
}
-type extractVersionError struct {
- output []byte
-}
-
-func (e *extractVersionError) Error() string {
- return fmt.Sprintf("%s: cannot extract version", e.output)
-}
-
type parseCmdOutputError struct {
command string
args []string
@@ -83,20 +73,3 @@ func (e *parseVersionError) Error() string {
func (e *parseVersionError) Unwrap() error {
return e.err
}
-
-type unsupportedVersionError struct {
- version *semver.Version
-}
-
-func (e *unsupportedVersionError) Error() string {
- return fmt.Sprintf("%s: unsupported version", e.version)
-}
-
-type versionTooOldError struct {
- have *semver.Version
- need *semver.Version
-}
-
-func (e *versionTooOldError) Error() string {
- return fmt.Sprintf("found version %s, need version %s or later", e.have, e.need)
-}
|
chore
|
Remove unused version infrastructure
|
21e2666e25b23a91f96357330d7cd9a6375efca7
|
2022-05-23 02:52:59
|
Tom Payne
|
fix: Parse $EDITOR and $VISUAL environment variables as shell commands
| false
|
diff --git a/go.mod b/go.mod
index 814341ec4b3..db156303ebd 100644
--- a/go.mod
+++ b/go.mod
@@ -38,6 +38,7 @@ require (
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99
howett.net/plist v1.0.0
+ mvdan.cc/sh/v3 v3.5.0
)
require (
diff --git a/go.sum b/go.sum
index 6f2b49a0459..e64eb12ceea 100644
--- a/go.sum
+++ b/go.sum
@@ -154,6 +154,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKY
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
@@ -305,6 +306,7 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -1147,6 +1149,8 @@ honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
+mvdan.cc/sh/v3 v3.5.0 h1:/wJEun8808ezNyNyaORnK80JAu4nimLbfibn9xOccFE=
+mvdan.cc/sh/v3 v3.5.0/go.mod h1:1JcoyAKm1lZw/2bZje/iYKWicU/KMd0rsyJeKHnsK4E=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/goversion v1.2.0 h1:SPn+NLTiAG7w30IRK/DKp1BjvpWabYgxlLp/+kx5J8w=
diff --git a/pkg/cmd/cdcmd.go b/pkg/cmd/cdcmd.go
index a4348e6e108..6784e57263f 100644
--- a/pkg/cmd/cdcmd.go
+++ b/pkg/cmd/cdcmd.go
@@ -30,16 +30,19 @@ func (c *Config) newCDCmd() *cobra.Command {
}
func (c *Config) runCDCmd(cmd *cobra.Command, args []string) error {
- cdCommand, cdArgs := c.cdCommand()
+ cdCommand, cdArgs, err := c.cdCommand()
+ if err != nil {
+ return err
+ }
return c.run(c.WorkingTreeAbsPath, cdCommand, cdArgs)
}
-func (c *Config) cdCommand() (string, []string) {
+func (c *Config) cdCommand() (string, []string, error) {
cdCommand := c.CD.Command
cdArgs := c.CD.Args
if cdCommand != "" {
- return cdCommand, cdArgs
+ return cdCommand, cdArgs, nil
}
cdCommand, _ = shell.CurrentUserShell()
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index 8ca733d4e0e..92f5753c1f3 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -43,6 +43,8 @@ import (
"github.com/twpayne/go-xdg/v6"
"go.uber.org/multierr"
"golang.org/x/term"
+ "mvdan.cc/sh/v3/expand"
+ "mvdan.cc/sh/v3/syntax"
"github.com/twpayne/chezmoi/v2/assets/templates"
"github.com/twpayne/chezmoi/v2/pkg/chezmoi"
@@ -1081,13 +1083,13 @@ func (c *Config) diffFile(
}
// editor returns the path to the user's editor and any extra arguments.
-func (c *Config) editor(args []string) (string, []string) {
+func (c *Config) editor(args []string) (string, []string, error) {
editCommand := c.Edit.Command
editArgs := c.Edit.Args
// If the user has set an edit command then use it.
if editCommand != "" {
- return editCommand, append(editArgs, args...)
+ return editCommand, append(editArgs, args...), nil
}
// Prefer $VISUAL over $EDITOR and fallback to the OS's default editor.
@@ -1524,7 +1526,10 @@ func (c *Config) pageOutputString(output, cmdPager string) error {
var pagerCmd *exec.Cmd
if strings.IndexFunc(pager, unicode.IsSpace) != -1 {
shellCommand, _ := shell.CurrentUserShell()
- shellCommand, shellArgs := parseCommand(shellCommand, []string{"-c", pager})
+ shellCommand, shellArgs, err := parseCommand(shellCommand, []string{"-c", pager})
+ if err != nil {
+ return err
+ }
pagerCmd = exec.Command(shellCommand, shellArgs...)
} else {
pagerCmd = exec.Command(pager)
@@ -1847,9 +1852,12 @@ func (c *Config) runEditor(args []string) error {
if err := c.persistentState.Close(); err != nil {
return err
}
- editor, editorArgs := c.editor(args)
+ editor, editorArgs, err := c.editor(args)
+ if err != nil {
+ return err
+ }
start := time.Now()
- err := c.run(chezmoi.EmptyAbsPath, editor, editorArgs)
+ err = c.run(chezmoi.EmptyAbsPath, editor, editorArgs)
if runtime.GOOS != "windows" && c.Edit.MinDuration != 0 {
if duration := time.Since(start); duration < c.Edit.MinDuration {
c.errorf("warning: %s: returned in less than %s\n", shellQuoteCommand(editor, editorArgs), c.Edit.MinDuration)
@@ -2123,23 +2131,32 @@ func (c *Config) writeOutputString(data string) error {
return c.writeOutput([]byte(data))
}
-func parseCommand(command string, args []string) (string, []string) {
+func parseCommand(command string, args []string) (string, []string, error) {
// If command is found, then return it.
if path, err := chezmoi.LookPath(command); err == nil {
- return path, args
+ return path, args, nil
}
- // Otherwise, if the command contains spaces, then assume that the first word
- // is the editor and the rest are arguments.
- components := whitespaceRx.Split(command, -1)
- if len(components) > 1 {
- if path, err := chezmoi.LookPath(components[0]); err == nil {
- return path, append(components[1:], args...)
+ // Otherwise, if the command contains spaces, parse it as a shell command.
+ if whitespaceRx.MatchString(command) {
+ var words []*syntax.Word
+ if err := syntax.NewParser().Words(strings.NewReader(command), func(word *syntax.Word) bool {
+ words = append(words, word)
+ return true
+ }); err != nil {
+ return "", nil, err
+ }
+ fields, err := expand.Fields(&expand.Config{
+ Env: expand.FuncEnviron(os.Getenv),
+ }, words...)
+ if err != nil {
+ return "", nil, err
}
+ return fields[0], append(fields[1:], args...), nil
}
// Fallback to the command only.
- return command, args
+ return command, args, nil
}
// withVersionInfo sets the version information.
diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go
index fc495134dde..621d3b6c5cf 100644
--- a/pkg/cmd/config_test.go
+++ b/pkg/cmd/config_test.go
@@ -5,6 +5,7 @@ import (
"io/fs"
"path/filepath"
"runtime"
+ "strconv"
"testing"
"github.com/stretchr/testify/assert"
@@ -28,6 +29,48 @@ func TestAddTemplateFuncPanic(t *testing.T) {
})
}
+func TestParseCommand(t *testing.T) {
+ for i, tc := range []struct {
+ command string
+ args []string
+ expectedCommand string
+ expectedArgs []string
+ expectedErr bool
+ }{
+ {
+ command: "chezmoi-editor",
+ expectedCommand: "chezmoi-editor",
+ },
+ {
+ command: `chezmoi-editor -f --nomru -c "au VimLeave * !open -a Terminal"`,
+ expectedCommand: "chezmoi-editor",
+ expectedArgs: []string{"-f", "--nomru", "-c", "au VimLeave * !open -a Terminal"},
+ },
+ {
+ command: `"chezmoi editor" $CHEZMOI_TEST_VAR`,
+ args: []string{"extra-arg"},
+ expectedCommand: "chezmoi editor",
+ expectedArgs: []string{"chezmoi-test-value", "extra-arg"},
+ },
+ {
+ command: `"chezmoi editor`,
+ expectedErr: true,
+ },
+ } {
+ t.Run(strconv.Itoa(i), func(t *testing.T) {
+ t.Setenv("CHEZMOI_TEST_VAR", "chezmoi-test-value")
+ actualCommand, actualArgs, err := parseCommand(tc.command, tc.args)
+ if tc.expectedErr {
+ assert.Error(t, err)
+ } else {
+ assert.NoError(t, err)
+ assert.Equal(t, tc.expectedCommand, actualCommand)
+ assert.Equal(t, tc.expectedArgs, actualArgs)
+ }
+ })
+ }
+}
+
func TestParseConfig(t *testing.T) {
for _, tc := range []struct {
name string
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go
index 1fb76cb91b4..6e71fa6d839 100644
--- a/pkg/cmd/doctorcmd.go
+++ b/pkg/cmd/doctorcmd.go
@@ -156,9 +156,9 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
}
httpClient, httpClientErr := c.getHTTPClient()
shellCommand, _ := shell.CurrentUserShell()
- shellCommand, shellArgs := parseCommand(shellCommand, nil)
- cdCommand, cdArgs := c.cdCommand()
- editCommand, editArgs := c.editor(nil)
+ shellCommand, shellArgs, _ := parseCommand(shellCommand, nil)
+ cdCommand, cdArgs, _ := c.cdCommand()
+ editCommand, editArgs, _ := c.editor(nil)
checks := []check{
&versionCheck{
versionInfo: c.versionInfo,
|
fix
|
Parse $EDITOR and $VISUAL environment variables as shell commands
|
1743224bb34c46633ddcf77ddab7f82e3d38bfab
|
2024-02-06 02:32:37
|
Tom Payne
|
chore: Update dependencies
| false
|
diff --git a/go.mod b/go.mod
index 118db19c7a5..6c9c7187275 100644
--- a/go.mod
+++ b/go.mod
@@ -15,7 +15,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.26.2
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/bradenhilton/mozillainstallhash v1.0.1
- github.com/charmbracelet/bubbles v0.17.1
+ github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/glamour v0.6.0
github.com/coreos/go-semver v0.3.1
@@ -25,14 +25,14 @@ require (
github.com/google/renameio/v2 v2.0.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
github.com/itchyny/gojq v0.12.14
- github.com/klauspost/compress v1.17.4
+ github.com/klauspost/compress v1.17.6
github.com/mitchellh/copystructure v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/muesli/combinator v0.3.0
github.com/muesli/termenv v0.15.2
github.com/pelletier/go-toml/v2 v2.1.1
github.com/rogpeppe/go-internal v1.12.0
- github.com/rs/zerolog v1.31.0
+ github.com/rs/zerolog v1.32.0
github.com/sergi/go-diff v1.1.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
@@ -44,7 +44,7 @@ require (
github.com/ulikunitz/xz v0.5.11
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
github.com/zalando/go-keyring v0.2.3
- github.com/zricethezav/gitleaks/v8 v8.18.2-0.20240110190900-a59289ca9bd3
+ github.com/zricethezav/gitleaks/v8 v8.18.2
go.etcd.io/bbolt v1.3.8
golang.org/x/crypto v0.18.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
@@ -90,7 +90,7 @@ require (
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/lipgloss v0.9.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
- github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
+ github.com/containerd/console v1.0.4 // indirect
github.com/creack/pty/v2 v2.0.0-20231209135443-03db72c7b76c // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
@@ -135,7 +135,7 @@ require (
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
- github.com/rivo/uniseg v0.4.4 // indirect
+ github.com/rivo/uniseg v0.4.6 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
@@ -146,7 +146,7 @@ require (
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
- github.com/yuin/goldmark v1.6.0 // indirect
+ github.com/yuin/goldmark v1.7.0 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.14.0 // indirect
diff --git a/go.sum b/go.sum
index 8935f24e12b..f387b013c60 100644
--- a/go.sum
+++ b/go.sum
@@ -104,8 +104,8 @@ github.com/bradenhilton/mozillainstallhash v1.0.1 h1:JVAVsItiWlLoudJX4L+tIuml+ho
github.com/bradenhilton/mozillainstallhash v1.0.1/go.mod h1:J6cA36kUZrgaTkDl2bHRqI+4i2UKO1ImDB1P1x1PyOA=
github.com/bwesterb/go-ristretto v1.2.3 h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/JMzngw=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
-github.com/charmbracelet/bubbles v0.17.1 h1:0SIyjOnkrsfDo88YvPgAWvZMwXe26TP6drRvmkjyUu4=
-github.com/charmbracelet/bubbles v0.17.1/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o=
+github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
+github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
@@ -117,8 +117,8 @@ github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
-github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
-github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
+github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro=
+github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
@@ -259,8 +259,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
-github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
-github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
+github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI=
+github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -338,8 +338,6 @@ github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5d
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
-github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 h1:lL+y4Xv20pVlCGyLzNHRC0I0rIHhIL1lTvHizoS/dU8=
-github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9/go.mod h1:EHPiTAKtiFmrMldLUNswFwfZ2eJIYBHktdaUTZxYWRw=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
@@ -357,14 +355,14 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
-github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
+github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
-github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
-github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
+github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
+github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/crypt v0.17.0 h1:ZA/7pXyjkHoK4bW4mIdnCLvL8hd+Nrbiw7Dqk7D4qUk=
@@ -447,15 +445,15 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
-github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
-github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA=
+github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s=
github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms=
github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
-github.com/zricethezav/gitleaks/v8 v8.18.2-0.20240110190900-a59289ca9bd3 h1:zwKxkR8hOXD5iQ3k2q7n6Ul2xAN6820CoXYmPekZkF8=
-github.com/zricethezav/gitleaks/v8 v8.18.2-0.20240110190900-a59289ca9bd3/go.mod h1:8Dn6XSzCXjbkxc2e/o1M+dwIHPAoyY7HsYjLWzgg+Zs=
+github.com/zricethezav/gitleaks/v8 v8.18.2 h1:slo/sMmgs3qA+6Vv6iqVhsCv+gsl3RekQXqDN0M4g5M=
+github.com/zricethezav/gitleaks/v8 v8.18.2/go.mod h1:8F5GrdCpEtyN5R+0MKPubbOPqIHptNckH3F7bYrhT+Y=
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/etcd/api/v3 v3.5.10 h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k=
|
chore
|
Update dependencies
|
3dea74aa715ad3103e89d20fcfe6d1f4f2a3a508
|
2024-07-15 04:03:24
|
Tom Payne
|
chore: Use user-defined encrypted suffixes in doctor check
| false
|
diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go
index a8cd746277d..ced281aaa6a 100644
--- a/internal/cmd/doctorcmd.go
+++ b/internal/cmd/doctorcmd.go
@@ -134,7 +134,8 @@ type omittedCheck struct{}
// A suspiciousEntriesCheck checks that a source directory does not contain any
// suspicious files.
type suspiciousEntriesCheck struct {
- dirname chezmoi.AbsPath
+ dirname chezmoi.AbsPath
+ encryptedSuffixes []string
}
// A upgradeMethodCheck checks the upgrade method.
@@ -207,6 +208,10 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
},
&suspiciousEntriesCheck{
dirname: c.SourceDirAbsPath,
+ encryptedSuffixes: []string{
+ c.Age.Suffix,
+ c.GPG.Suffix,
+ },
},
&dirCheck{
name: "working-tree",
@@ -730,18 +735,13 @@ func (c *suspiciousEntriesCheck) Name() string {
}
func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) {
- // FIXME include user-defined suffixes from age and gpg configs
- encryptedSuffixes := []string{
- defaultAgeEncryptionConfig.Suffix,
- defaultGPGEncryptionConfig.Suffix,
- }
// FIXME check that config file templates are in root
var suspiciousEntries []string
walkFunc := func(absPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
if err != nil {
return err
}
- if chezmoi.SuspiciousSourceDirEntry(absPath.Base(), fileInfo, encryptedSuffixes) {
+ if chezmoi.SuspiciousSourceDirEntry(absPath.Base(), fileInfo, c.encryptedSuffixes) {
suspiciousEntries = append(suspiciousEntries, absPath.String())
}
return nil
diff --git a/internal/cmd/testdata/scripts/doctor_unix.txtar b/internal/cmd/testdata/scripts/doctor_unix.txtar
index bec4325c8ba..5c611c00765 100644
--- a/internal/cmd/testdata/scripts/doctor_unix.txtar
+++ b/internal/cmd/testdata/scripts/doctor_unix.txtar
@@ -85,6 +85,12 @@ chhome home4/user
stdout '^warning\s+config-file\s+.*multiple config files'
! stderr .
+chhome home5/user
+
+# test that chezmoi doctor warns about encrypted files
+exec chezmoi doctor
+stdout '^warning\s+suspicious-entries\s+'
+
-- bin/age --
#!/bin/sh
@@ -203,3 +209,7 @@ echo "0.2.1, git sha (8d9af42c8b98c9527741a239b23a3e384812f514), go1.20.4 arm64"
-- home3/user/.local/share/chezmoi/.chezmoisuspicious --
-- home4/user/.config/chezmoi/chezmoi.json --
-- home4/user/.config/chezmoi/chezmoi.yaml --
+-- home5/user/.config/chezmoi/chezmoi.toml --
+[age]
+ suffix = ".age-encrypted"
+-- home5/user/.local/share/chezmoi/dot_config/chezmoi/encrypted_chezmoi.toml.age-encrypted --
|
chore
|
Use user-defined encrypted suffixes in doctor check
|
8162df63e9da9d798b820855729420a6857f17e8
|
2023-06-01 13:45:31
|
dependabot[bot]
|
chore(deps): bump actions/setup-go from 4.0.0 to 4.0.1
| false
|
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index d3e52a5802d..f0b554717b1 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -11,7 +11,7 @@ jobs:
id: go-version
run: |
echo go-version="$(awk '/GO_VERSION:/ { print $2 }' .github/workflows/main.yml | tr -d \')" >> ${GITHUB_OUTPUT}
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ steps.go-version.outputs.go-version }}
- name: install
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 64a4833f575..0de996d365c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -127,7 +127,7 @@ jobs:
runs-on: macos-11
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: build
@@ -157,7 +157,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: oldstable
- name: build
@@ -184,7 +184,7 @@ jobs:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
fetch-depth: 0
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-release-dependencies
@@ -242,7 +242,7 @@ jobs:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
fetch-depth: 0
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-age
@@ -280,7 +280,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-website-dependencies
@@ -295,7 +295,7 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
@@ -334,7 +334,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: generate
@@ -360,7 +360,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5
@@ -400,7 +400,7 @@ jobs:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
fetch-depth: 0
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: sigstore/cosign-installer@204a51a57a74d190b284a0ce69b44bc37201f343
@@ -424,7 +424,7 @@ jobs:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
fetch-depth: 0
- - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
+ - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: prepare-chezmoi.io
|
chore
|
bump actions/setup-go from 4.0.0 to 4.0.1
|
42f021741bcc4d915f48ddff568f58825da41383
|
2023-07-14 06:06:33
|
Tom Payne
|
chore: Use golang/govulncheck-action
| false
|
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index 14f5fa7060d..e5b7cfa490b 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -11,12 +11,6 @@ jobs:
id: go-version
run: |
echo go-version="$(awk '/GO_VERSION:/ { print $2 }' .github/workflows/main.yml | tr -d \')" >> "${GITHUB_OUTPUT}"
- - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
+ - uses: golang/govulncheck-action@dd3ead030e4f2cf713062f7a3395191802364e13
with:
- go-version: ${{ steps.go-version.outputs.go-version }}
- - name: install
- run: |
- go install golang.org/x/vuln/cmd/govulncheck@latest
- - name: run
- run: |
- govulncheck ./...
+ go-version-input: ${{ steps.go-version.outputs.go-version }}
|
chore
|
Use golang/govulncheck-action
|
e4f5d7092d75860e8731b8b9f8ec7b720e2b9c06
|
2021-10-07 23:50:44
|
Tom Payne
|
chore: Miscellaneous code tidy-ups
| false
|
diff --git a/internal/chezmoi/ageencryption.go b/internal/chezmoi/ageencryption.go
index e9aae07d793..bb607ffabe6 100644
--- a/internal/chezmoi/ageencryption.go
+++ b/internal/chezmoi/ageencryption.go
@@ -108,11 +108,11 @@ func (e *AgeEncryption) builtinDecrypt(ciphertext []byte) ([]byte, error) {
if err != nil {
return nil, err
}
- w := &bytes.Buffer{}
- if _, err = io.Copy(w, r); err != nil {
+ buffer := &bytes.Buffer{}
+ if _, err = io.Copy(buffer, r); err != nil {
return nil, err
}
- return w.Bytes(), err
+ return buffer.Bytes(), err
}
// builtinEncrypt encrypts ciphertext using the builtin age.
diff --git a/internal/chezmoi/archivereadersystem_test.go b/internal/chezmoi/archivereadersystem_test.go
index 7eaf54a4041..c5c73a87606 100644
--- a/internal/chezmoi/archivereadersystem_test.go
+++ b/internal/chezmoi/archivereadersystem_test.go
@@ -12,31 +12,31 @@ import (
)
func TestArchiveReaderSystemTAR(t *testing.T) {
- b := &bytes.Buffer{}
- w := tar.NewWriter(b)
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ buffer := &bytes.Buffer{}
+ tarWriter := tar.NewWriter(buffer)
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeDir,
Name: "dir/",
Mode: 0o777,
}))
data := []byte("# contents of dir/file\n")
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeReg,
Name: "dir/file",
Size: int64(len(data)),
Mode: 0o666,
}))
- _, err := w.Write(data)
+ _, err := tarWriter.Write(data)
assert.NoError(t, err)
linkname := "file"
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeSymlink,
Name: "dir/symlink",
Linkname: linkname,
}))
- require.NoError(t, w.Close())
+ require.NoError(t, tarWriter.Close())
- archiveReaderSystem, err := NewArchiveReaderSystem("archive.tar", b.Bytes(), ArchiveFormatTar, ArchiveReaderSystemOptions{
+ archiveReaderSystem, err := NewArchiveReaderSystem("archive.tar", buffer.Bytes(), ArchiveFormatTar, ArchiveReaderSystemOptions{
RootAbsPath: NewAbsPath("/home/user"),
StripComponents: 1,
})
diff --git a/internal/chezmoi/attr_test.go b/internal/chezmoi/attr_test.go
index dc212e53a71..c75a6435672 100644
--- a/internal/chezmoi/attr_test.go
+++ b/internal/chezmoi/attr_test.go
@@ -33,13 +33,13 @@ func TestDirAttr(t *testing.T) {
Private: []bool{false, true},
ReadOnly: []bool{false, true},
}
- var das []DirAttr
- require.NoError(t, combinator.Generate(&das, testData))
- for _, da := range das {
- actualSourceName := da.SourceName()
- actualDA := parseDirAttr(actualSourceName)
- assert.Equal(t, da, actualDA)
- assert.Equal(t, actualSourceName, actualDA.SourceName())
+ var dirAttrs []DirAttr
+ require.NoError(t, combinator.Generate(&dirAttrs, testData))
+ for _, dirAttr := range dirAttrs {
+ actualSourceName := dirAttr.SourceName()
+ actualDirAttr := parseDirAttr(actualSourceName)
+ assert.Equal(t, dirAttr, actualDirAttr)
+ assert.Equal(t, actualSourceName, actualDirAttr.SourceName())
}
}
@@ -76,7 +76,7 @@ func TestDirAttrLiteral(t *testing.T) {
}
func TestFileAttr(t *testing.T) {
- var fas []FileAttr
+ var fileAttrs []FileAttr
targetNames := []string{
".name",
"create_name",
@@ -91,7 +91,7 @@ func TestFileAttr(t *testing.T) {
"symlink_name",
"template.tmpl",
}
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
Encrypted []bool
@@ -108,7 +108,7 @@ func TestFileAttr(t *testing.T) {
ReadOnly: []bool{false, true},
Template: []bool{false, true},
}))
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
Empty []bool
@@ -127,7 +127,7 @@ func TestFileAttr(t *testing.T) {
ReadOnly: []bool{false, true},
Template: []bool{false, true},
}))
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
Executable []bool
@@ -142,14 +142,14 @@ func TestFileAttr(t *testing.T) {
ReadOnly: []bool{false, true},
Template: []bool{false, true},
}))
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
}{
Type: SourceFileTypeRemove,
TargetName: targetNames,
}))
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
Once []bool
@@ -160,18 +160,18 @@ func TestFileAttr(t *testing.T) {
Once: []bool{false, true},
Order: []int{-1, 0, 1},
}))
- require.NoError(t, combinator.Generate(&fas, struct {
+ require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
TargetName []string
}{
Type: SourceFileTypeSymlink,
TargetName: targetNames,
}))
- for _, fa := range fas {
- actualSourceName := fa.SourceName("")
- actualFA := parseFileAttr(actualSourceName, "")
- assert.Equal(t, fa, actualFA)
- assert.Equal(t, actualSourceName, actualFA.SourceName(""))
+ for _, fileAttr := range fileAttrs {
+ actualSourceName := fileAttr.SourceName("")
+ actualFileAttr := parseFileAttr(actualSourceName, "")
+ assert.Equal(t, fileAttr, actualFileAttr)
+ assert.Equal(t, actualSourceName, actualFileAttr.SourceName(""))
}
}
diff --git a/internal/chezmoi/data.go b/internal/chezmoi/data.go
index fd03b00ff20..9b21c177012 100644
--- a/internal/chezmoi/data.go
+++ b/internal/chezmoi/data.go
@@ -19,8 +19,7 @@ import (
func Kernel(fileSystem vfs.FS) (map[string]interface{}, error) {
const procSysKernel = "/proc/sys/kernel"
- info, err := fileSystem.Stat(procSysKernel)
- switch {
+ switch info, err := fileSystem.Stat(procSysKernel); {
case errors.Is(err, fs.ErrNotExist):
return nil, nil
case errors.Is(err, fs.ErrPermission):
@@ -37,16 +36,16 @@ func Kernel(fileSystem vfs.FS) (map[string]interface{}, error) {
"ostype",
"version",
} {
- data, err := fileSystem.ReadFile(filepath.Join(procSysKernel, filename))
- switch {
+ switch data, err := fileSystem.ReadFile(filepath.Join(procSysKernel, filename)); {
+ case err == nil:
+ kernel[filename] = string(bytes.TrimSpace(data))
case errors.Is(err, fs.ErrNotExist):
continue
case errors.Is(err, fs.ErrPermission):
continue
- case err != nil:
+ default:
return nil, err
}
- kernel[filename] = string(bytes.TrimSpace(data))
}
return kernel, nil
}
diff --git a/internal/chezmoi/externaldiffsystem.go b/internal/chezmoi/externaldiffsystem.go
index 5db70b163e8..4c479321fdf 100644
--- a/internal/chezmoi/externaldiffsystem.go
+++ b/internal/chezmoi/externaldiffsystem.go
@@ -203,14 +203,14 @@ func (s *ExternalDiffSystem) runDiffCommand(destAbsPath, targetAbsPath AbsPath)
return err
}
- var sb strings.Builder
- if err := tmpl.Execute(&sb, templateData); err != nil {
+ builder := strings.Builder{}
+ if err := tmpl.Execute(&builder, templateData); err != nil {
return err
}
- args = append(args, sb.String())
+ args = append(args, builder.String())
// Detect template arguments.
- if arg != sb.String() {
+ if arg != builder.String() {
anyTemplateArgs = true
}
}
diff --git a/internal/chezmoi/format.go b/internal/chezmoi/format.go
index b4b19eff137..0cf6b4e7d43 100644
--- a/internal/chezmoi/format.go
+++ b/internal/chezmoi/format.go
@@ -50,16 +50,16 @@ func (formatGzippedJSON) Marshal(value interface{}) ([]byte, error) {
if err != nil {
return nil, err
}
- sb := &strings.Builder{}
- sb.Grow(len(jsonData))
- w := gzip.NewWriter(sb)
- if _, err := w.Write(jsonData); err != nil {
+ builder := &strings.Builder{}
+ builder.Grow(len(jsonData))
+ gzipWriter := gzip.NewWriter(builder)
+ if _, err := gzipWriter.Write(jsonData); err != nil {
return nil, err
}
- if err := w.Close(); err != nil {
+ if err := gzipWriter.Close(); err != nil {
return nil, err
}
- return []byte(sb.String()), nil
+ return []byte(builder.String()), nil
}
// Name implements Format.Name.
diff --git a/internal/chezmoi/hexbytes_test.go b/internal/chezmoi/hexbytes_test.go
index 18865aa7b9a..abe748f4e52 100644
--- a/internal/chezmoi/hexbytes_test.go
+++ b/internal/chezmoi/hexbytes_test.go
@@ -35,9 +35,9 @@ func TestHexBytes(t *testing.T) {
actual, err := format.Marshal(tc.b)
require.NoError(t, err)
assert.Equal(t, []byte(tc.expectedStr), actual)
- var actualB HexBytes
- require.NoError(t, format.Unmarshal(actual, &actualB))
- assert.Equal(t, tc.b, actualB)
+ var actualHexBytes HexBytes
+ require.NoError(t, format.Unmarshal(actual, &actualHexBytes))
+ assert.Equal(t, tc.b, actualHexBytes)
})
}
})
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index f670cdf507d..459137cb32c 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -624,11 +624,11 @@ func (s *SourceState) ExecuteTemplateData(name string, data []byte) ([]byte, err
defer delete(chezmoiTemplateData, "sourceFile")
}
- var sb strings.Builder
- if err = tmpl.ExecuteTemplate(&sb, name, templateData); err != nil {
+ builder := strings.Builder{}
+ if err = tmpl.ExecuteTemplate(&builder, name, templateData); err != nil {
return nil, err
}
- return []byte(sb.String()), nil
+ return []byte(builder.String()), nil
}
// Ignored returns if targetRelPath is ignored.
@@ -963,7 +963,7 @@ func (s *SourceState) addPatterns(patternSet *patternSet, sourceAbsPath AbsPath,
}
dir := sourceRelPath.Dir().TargetRelPath("")
scanner := bufio.NewScanner(bytes.NewReader(data))
- var lineNumber int
+ lineNumber := 0
for scanner.Scan() {
lineNumber++
text := scanner.Text()
@@ -1013,10 +1013,9 @@ func (s *SourceState) addTemplateData(sourceAbsPath AbsPath) error {
// addTemplatesDir adds all templates in templateDir to s.
func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error {
return WalkDir(s.system, templatesDirAbsPath, func(templateAbsPath AbsPath, info fs.FileInfo, err error) error {
- if err != nil {
- return err
- }
switch {
+ case err != nil:
+ return err
case info.Mode().IsRegular():
contents, err := s.system.ReadFile(templateAbsPath)
if err != nil {
diff --git a/internal/chezmoi/tarwritersystem.go b/internal/chezmoi/tarwritersystem.go
index fdf05c173d1..5577b9ac4b8 100644
--- a/internal/chezmoi/tarwritersystem.go
+++ b/internal/chezmoi/tarwritersystem.go
@@ -10,21 +10,21 @@ import (
type TARWriterSystem struct {
emptySystemMixin
noUpdateSystemMixin
- w *tar.Writer
+ tarWriter *tar.Writer
headerTemplate tar.Header
}
// NewTARWriterSystem returns a new TARWriterSystem that writes a TAR file to w.
func NewTARWriterSystem(w io.Writer, headerTemplate tar.Header) *TARWriterSystem {
return &TARWriterSystem{
- w: tar.NewWriter(w),
+ tarWriter: tar.NewWriter(w),
headerTemplate: headerTemplate,
}
}
// Close closes m.
func (s *TARWriterSystem) Close() error {
- return s.w.Close()
+ return s.tarWriter.Close()
}
// Mkdir implements System.Mkdir.
@@ -33,7 +33,7 @@ func (s *TARWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error {
header.Typeflag = tar.TypeDir
header.Name = name.String() + "/"
header.Mode = int64(perm)
- return s.w.WriteHeader(&header)
+ return s.tarWriter.WriteHeader(&header)
}
// RunScript implements System.RunScript.
@@ -48,10 +48,10 @@ func (s *TARWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileM
header.Name = filename.String()
header.Size = int64(len(data))
header.Mode = int64(perm)
- if err := s.w.WriteHeader(&header); err != nil {
+ if err := s.tarWriter.WriteHeader(&header); err != nil {
return err
}
- _, err := s.w.Write(data)
+ _, err := s.tarWriter.Write(data)
return err
}
@@ -61,5 +61,5 @@ func (s *TARWriterSystem) WriteSymlink(oldname string, newname AbsPath) error {
header.Typeflag = tar.TypeSymlink
header.Name = newname.String()
header.Linkname = oldname
- return s.w.WriteHeader(&header)
+ return s.tarWriter.WriteHeader(&header)
}
diff --git a/internal/chezmoi/zipwritersystem.go b/internal/chezmoi/zipwritersystem.go
index 7b45c3b1b95..1674f3faba2 100644
--- a/internal/chezmoi/zipwritersystem.go
+++ b/internal/chezmoi/zipwritersystem.go
@@ -11,32 +11,32 @@ import (
type ZIPWriterSystem struct {
emptySystemMixin
noUpdateSystemMixin
- w *zip.Writer
- modified time.Time
+ zipWriter *zip.Writer
+ modified time.Time
}
// NewZIPWriterSystem returns a new ZIPWriterSystem that writes a ZIP archive to
// w.
func NewZIPWriterSystem(w io.Writer, modified time.Time) *ZIPWriterSystem {
return &ZIPWriterSystem{
- w: zip.NewWriter(w),
- modified: modified,
+ zipWriter: zip.NewWriter(w),
+ modified: modified,
}
}
// Close closes m.
func (s *ZIPWriterSystem) Close() error {
- return s.w.Close()
+ return s.zipWriter.Close()
}
// Mkdir implements System.Mkdir.
func (s *ZIPWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error {
- fh := zip.FileHeader{
+ fileHeader := zip.FileHeader{
Name: name.String(),
Modified: s.modified,
}
- fh.SetMode(fs.ModeDir | perm)
- _, err := s.w.CreateHeader(&fh)
+ fileHeader.SetMode(fs.ModeDir | perm)
+ _, err := s.zipWriter.CreateHeader(&fileHeader)
return err
}
@@ -54,7 +54,7 @@ func (s *ZIPWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileM
UncompressedSize64: uint64(len(data)),
}
fh.SetMode(perm)
- fw, err := s.w.CreateHeader(&fh)
+ fw, err := s.zipWriter.CreateHeader(&fh)
if err != nil {
return err
}
@@ -71,7 +71,7 @@ func (s *ZIPWriterSystem) WriteSymlink(oldname string, newname AbsPath) error {
UncompressedSize64: uint64(len(data)),
}
fh.SetMode(fs.ModeSymlink)
- fw, err := s.w.CreateHeader(&fh)
+ fw, err := s.zipWriter.CreateHeader(&fh)
if err != nil {
return err
}
diff --git a/internal/cmd/archivecmd.go b/internal/cmd/archivecmd.go
index b8795ed45da..6715b86b3ad 100644
--- a/internal/cmd/archivecmd.go
+++ b/internal/cmd/archivecmd.go
@@ -88,11 +88,11 @@ func (c *Config) runArchiveCmd(cmd *cobra.Command, args []string) error {
}
gzippedArchive := strings.Builder{}
- w := gzip.NewWriter(&gzippedArchive)
- if _, err := w.Write([]byte(output.String())); err != nil {
+ gzipWriter := gzip.NewWriter(&gzippedArchive)
+ if _, err := gzipWriter.Write([]byte(output.String())); err != nil {
return err
}
- if err := w.Close(); err != nil {
+ if err := gzipWriter.Close(); err != nil {
return err
}
return c.writeOutputString(gzippedArchive.String())
diff --git a/internal/cmd/catcmd.go b/internal/cmd/catcmd.go
index 075777fb56e..f5a03db2824 100644
--- a/internal/cmd/catcmd.go
+++ b/internal/cmd/catcmd.go
@@ -30,7 +30,7 @@ func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezm
return err
}
- sb := strings.Builder{}
+ builder := strings.Builder{}
for _, targetRelPath := range targetRelPaths {
targetStateEntry, err := sourceState.MustEntry(targetRelPath).TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath))
if err != nil {
@@ -42,22 +42,22 @@ func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezm
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
- sb.Write(contents)
+ builder.Write(contents)
case *chezmoi.TargetStateScript:
contents, err := targetStateEntry.Contents()
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
- sb.Write(contents)
+ builder.Write(contents)
case *chezmoi.TargetStateSymlink:
linkname, err := targetStateEntry.Linkname()
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
- sb.WriteString(linkname + "\n")
+ builder.WriteString(linkname + "\n")
default:
return fmt.Errorf("%s: not a file, script, or symlink", targetRelPath)
}
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go
index e6c576ca44b..106f4d8b4ea 100644
--- a/internal/cmd/cmd.go
+++ b/internal/cmd/cmd.go
@@ -165,22 +165,22 @@ func extractHelps(r io.Reader) (map[string]*help, error) {
)
var (
- state = stateFindCommands
- sb = &strings.Builder{}
- h *help
+ state = stateFindCommands
+ builder = &strings.Builder{}
+ h *help
)
saveAndReset := func() error {
- var tr *glamour.TermRenderer
+ var termRenderer *glamour.TermRenderer
switch state {
case stateInCommand, stateFindExample:
- tr = longTermRenderer
+ termRenderer = longTermRenderer
case stateInExample:
- tr = examplesTermRenderer
+ termRenderer = examplesTermRenderer
default:
panic(fmt.Sprintf("%d: invalid state", state))
}
- s, err := tr.Render(sb.String())
+ s, err := termRenderer.Render(builder.String())
if err != nil {
return err
}
@@ -194,7 +194,7 @@ func extractHelps(r io.Reader) (map[string]*help, error) {
default:
panic(fmt.Sprintf("%d: invalid state", state))
}
- sb.Reset()
+ builder.Reset()
return nil
}
@@ -214,8 +214,7 @@ FOR:
state = stateInCommand
}
case stateInCommand, stateFindExample, stateInExample:
- m := commandRx.FindStringSubmatch(s.Text())
- switch {
+ switch m := commandRx.FindStringSubmatch(s.Text()); {
case m != nil:
if err := saveAndReset(); err != nil {
return nil, err
@@ -241,10 +240,10 @@ FOR:
}
state = stateFindFirstCommand
case state != stateFindExample:
- if _, err := sb.WriteString(s.Text()); err != nil {
+ if _, err := builder.WriteString(s.Text()); err != nil {
return nil, err
}
- if err := sb.WriteByte('\n'); err != nil {
+ if err := builder.WriteByte('\n'); err != nil {
return nil, err
}
}
diff --git a/internal/cmd/completioncmd.go b/internal/cmd/completioncmd.go
index 1a4f013c1bb..bf54ced21d7 100644
--- a/internal/cmd/completioncmd.go
+++ b/internal/cmd/completioncmd.go
@@ -25,29 +25,29 @@ func (c *Config) newCompletionCmd() *cobra.Command {
}
func (c *Config) runCompletionCmd(cmd *cobra.Command, args []string) error {
- var sb strings.Builder
- sb.Grow(16384)
+ builder := strings.Builder{}
+ builder.Grow(16384)
switch args[0] {
case "bash":
includeDesc := true
- if err := cmd.Root().GenBashCompletionV2(&sb, includeDesc); err != nil {
+ if err := cmd.Root().GenBashCompletionV2(&builder, includeDesc); err != nil {
return err
}
case "fish":
includeDesc := true
- if err := cmd.Root().GenFishCompletion(&sb, includeDesc); err != nil {
+ if err := cmd.Root().GenFishCompletion(&builder, includeDesc); err != nil {
return err
}
case "powershell":
- if err := cmd.Root().GenPowerShellCompletion(&sb); err != nil {
+ if err := cmd.Root().GenPowerShellCompletion(&builder); err != nil {
return err
}
case "zsh":
- if err := cmd.Root().GenZshCompletion(&sb); err != nil {
+ if err := cmd.Root().GenZshCompletion(&builder); err != nil {
return err
}
default:
return fmt.Errorf("%s: unsupported shell", args[0])
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index ccf4a942862..6df496b533a 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -671,15 +671,15 @@ func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte
return nil, err
}
- sb := strings.Builder{}
+ builder := strings.Builder{}
templateData := c.defaultTemplateData()
if c.init.data {
chezmoi.RecursiveMerge(templateData, c.Data)
}
- if err = t.Execute(&sb, templateData); err != nil {
+ if err = t.Execute(&builder, templateData); err != nil {
return nil, err
}
- return []byte(sb.String()), nil
+ return []byte(builder.String()), nil
}
// defaultConfigFile returns the default config file according to the XDG Base
@@ -948,8 +948,8 @@ func (c *Config) destAbsPathInfos(sourceState *chezmoi.SourceState, args []strin
// diffFile outputs the diff between fromData and fromMode and toData and toMode
// at path.
func (c *Config) diffFile(path chezmoi.RelPath, fromData []byte, fromMode fs.FileMode, toData []byte, toMode fs.FileMode) error {
- var sb strings.Builder
- unifiedEncoder := diff.NewUnifiedEncoder(&sb, diff.DefaultContextLines)
+ builder := strings.Builder{}
+ unifiedEncoder := diff.NewUnifiedEncoder(&builder, diff.DefaultContextLines)
color := c.Color.Value(c.colorAutoFunc)
if color {
unifiedEncoder.SetColor(diff.NewColorConfig())
@@ -961,7 +961,7 @@ func (c *Config) diffFile(path chezmoi.RelPath, fromData []byte, fromMode fs.Fil
if err := unifiedEncoder.Encode(diffPatch); err != nil {
return err
}
- return c.pageOutputString(sb.String(), c.Diff.Pager)
+ return c.pageOutputString(builder.String(), c.Diff.Pager)
}
// doPurge is the core purge functionality. It removes all files and directories
diff --git a/internal/cmd/config_test.go b/internal/cmd/config_test.go
index d52702e9f28..91fe1837e92 100644
--- a/internal/cmd/config_test.go
+++ b/internal/cmd/config_test.go
@@ -18,12 +18,12 @@ import (
func TestAddTemplateFuncPanic(t *testing.T) {
chezmoitest.WithTestFS(t, nil, func(fileSystem vfs.FS) {
- c := newTestConfig(t, fileSystem)
+ config := newTestConfig(t, fileSystem)
assert.NotPanics(t, func() {
- c.addTemplateFunc("func", nil)
+ config.addTemplateFunc("func", nil)
})
assert.Panics(t, func() {
- c.addTemplateFunc("func", nil)
+ config.addTemplateFunc("func", nil)
})
})
}
@@ -168,7 +168,7 @@ func TestValidateKeys(t *testing.T) {
func newTestConfig(t *testing.T, fileSystem vfs.FS, options ...configOption) *Config {
t.Helper()
system := chezmoi.NewRealSystem(fileSystem)
- c, err := newConfig(
+ config, err := newConfig(
append([]configOption{
withBaseSystem(system),
withDestSystem(system),
@@ -179,7 +179,7 @@ func newTestConfig(t *testing.T, fileSystem vfs.FS, options ...configOption) *Co
}, options...)...,
)
require.NoError(t, err)
- return c
+ return config
}
func withBaseSystem(baseSystem chezmoi.System) configOption {
@@ -226,38 +226,38 @@ func withTestFS(fileSystem vfs.FS) configOption {
func withTestUser(t *testing.T, username string) configOption {
t.Helper()
- return func(c *Config) error {
+ return func(config *Config) error {
var env string
switch runtime.GOOS {
case "plan9":
- c.homeDir = filepath.Join("/", "home", username)
+ config.homeDir = filepath.Join("/", "home", username)
env = "home"
case "windows":
- c.homeDir = filepath.Join("C:\\", "home", username)
+ config.homeDir = filepath.Join("C:\\", "home", username)
env = "USERPROFILE"
default:
- c.homeDir = filepath.Join("/", "home", username)
+ config.homeDir = filepath.Join("/", "home", username)
env = "HOME"
}
- testSetenv(t, env, c.homeDir)
+ testSetenv(t, env, config.homeDir)
var err error
- c.homeDirAbsPath, err = chezmoi.NormalizePath(c.homeDir)
+ config.homeDirAbsPath, err = chezmoi.NormalizePath(config.homeDir)
if err != nil {
panic(err)
}
- c.CacheDirAbsPath = c.homeDirAbsPath.Join(".cache", "chezmoi")
- c.SourceDirAbsPath = c.homeDirAbsPath.Join(".local", "share", "chezmoi")
- c.DestDirAbsPath = c.homeDirAbsPath
- c.Umask = 0o22
- configHome := filepath.Join(c.homeDir, ".config")
- dataHome := filepath.Join(c.homeDir, ".local", "share")
- c.bds = &xdg.BaseDirectorySpecification{
+ config.CacheDirAbsPath = config.homeDirAbsPath.Join(".cache", "chezmoi")
+ config.SourceDirAbsPath = config.homeDirAbsPath.Join(".local", "share", "chezmoi")
+ config.DestDirAbsPath = config.homeDirAbsPath
+ config.Umask = 0o22
+ configHome := filepath.Join(config.homeDir, ".config")
+ dataHome := filepath.Join(config.homeDir, ".local", "share")
+ config.bds = &xdg.BaseDirectorySpecification{
ConfigHome: configHome,
ConfigDirs: []string{configHome},
DataHome: dataHome,
DataDirs: []string{dataHome},
- CacheHome: filepath.Join(c.homeDir, ".cache"),
- RuntimeDir: filepath.Join(c.homeDir, ".run"),
+ CacheHome: filepath.Join(config.homeDir, ".cache"),
+ RuntimeDir: filepath.Join(config.homeDir, ".run"),
}
return nil
}
diff --git a/internal/cmd/datacmd_test.go b/internal/cmd/datacmd_test.go
index be092a0e866..8f7f0e76147 100644
--- a/internal/cmd/datacmd_test.go
+++ b/internal/cmd/datacmd_test.go
@@ -47,10 +47,10 @@ func TestDataCmd(t *testing.T) {
"data",
"--format", tc.format.Name(),
}
- c := newTestConfig(t, fileSystem)
- var sb strings.Builder
- c.stdout = &sb
- require.NoError(t, c.execute(args))
+ config := newTestConfig(t, fileSystem)
+ builder := strings.Builder{}
+ config.stdout = &builder
+ require.NoError(t, config.execute(args))
var data struct {
Chezmoi struct {
@@ -58,7 +58,7 @@ func TestDataCmd(t *testing.T) {
} `json:"chezmoi" yaml:"chezmoi"`
Test bool `json:"test" yaml:"test"`
}
- assert.NoError(t, tc.format.Unmarshal([]byte(sb.String()), &data))
+ assert.NoError(t, tc.format.Unmarshal([]byte(builder.String()), &data))
normalizedSourceDir, err := chezmoi.NormalizePath("/tmp/source")
require.NoError(t, err)
assert.Equal(t, normalizedSourceDir.String(), data.Chezmoi.SourceDir)
diff --git a/internal/cmd/diffcmd.go b/internal/cmd/diffcmd.go
index 77d91b060a2..082820250e1 100644
--- a/internal/cmd/diffcmd.go
+++ b/internal/cmd/diffcmd.go
@@ -43,11 +43,11 @@ func (c *Config) newDiffCmd() *cobra.Command {
}
func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) error {
- sb := strings.Builder{}
+ builder := strings.Builder{}
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
if c.Diff.useBuiltinDiff || c.Diff.Command == "" {
color := c.Color.Value(c.colorAutoFunc)
- gitDiffSystem := chezmoi.NewGitDiffSystem(dryRunSystem, &sb, c.DestDirAbsPath, color)
+ gitDiffSystem := chezmoi.NewGitDiffSystem(dryRunSystem, &builder, c.DestDirAbsPath, color)
if err := c.applyArgs(cmd.Context(), gitDiffSystem, c.DestDirAbsPath, args, applyArgsOptions{
include: c.Diff.include.Sub(c.Diff.Exclude),
init: c.Diff.init,
@@ -56,7 +56,7 @@ func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) error {
}); err != nil {
return err
}
- return c.pageOutputString(sb.String(), c.Diff.Pager)
+ return c.pageOutputString(builder.String(), c.Diff.Pager)
}
diffSystem := chezmoi.NewExternalDiffSystem(dryRunSystem, c.Diff.Command, c.Diff.Args, c.DestDirAbsPath)
defer diffSystem.Close()
diff --git a/internal/cmd/diffcmd_test.go b/internal/cmd/diffcmd_test.go
index 447517131fe..233833608e1 100644
--- a/internal/cmd/diffcmd_test.go
+++ b/internal/cmd/diffcmd_test.go
@@ -95,7 +95,7 @@ func TestDiffCmd(t *testing.T) {
if tc.extraRoot != nil {
require.NoError(t, vfst.NewBuilder().Build(fileSystem, tc.extraRoot))
}
- var stdout strings.Builder
+ stdout := strings.Builder{}
require.NoError(t, newTestConfig(t, fileSystem, withStdout(&stdout)).execute(append([]string{"diff"}, tc.args...)))
assert.Equal(t, tc.stdoutStr, stdout.String())
})
diff --git a/internal/cmd/docscmd.go b/internal/cmd/docscmd.go
index 4e68f3e109d..2e32bd016bc 100644
--- a/internal/cmd/docscmd.go
+++ b/internal/cmd/docscmd.go
@@ -95,7 +95,7 @@ func (c *Config) runDocsCmd(cmd *cobra.Command, args []string) error {
width = c.Docs.MaxWidth
}
- tr, err := glamour.NewTermRenderer(
+ termRenderer, err := glamour.NewTermRenderer(
glamour.WithStyles(glamour.ASCIIStyleConfig),
glamour.WithWordWrap(width),
)
@@ -103,7 +103,7 @@ func (c *Config) runDocsCmd(cmd *cobra.Command, args []string) error {
return err
}
- renderedData, err := tr.RenderBytes(documentData)
+ renderedData, err := termRenderer.RenderBytes(documentData)
if err != nil {
return err
}
diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go
index 1bfeaf83567..54cf0858b1e 100644
--- a/internal/cmd/doctorcmd.go
+++ b/internal/cmd/doctorcmd.go
@@ -409,8 +409,7 @@ func (c *fileCheck) Run(system chezmoi.System) (checkResult, string) {
return c.ifNotSet, "not set"
}
- _, err := system.ReadFile(c.filename)
- switch {
+ switch _, err := system.ReadFile(c.filename); {
case errors.Is(err, fs.ErrNotExist):
return c.ifNotExist, fmt.Sprintf("%s does not exist", c.filename)
case err != nil:
diff --git a/internal/cmd/importcmd_test.go b/internal/cmd/importcmd_test.go
index d45d10f8184..5a03f75574e 100644
--- a/internal/cmd/importcmd_test.go
+++ b/internal/cmd/importcmd_test.go
@@ -15,34 +15,34 @@ import (
)
func TestImportCmd(t *testing.T) {
- b := &bytes.Buffer{}
- w := tar.NewWriter(b)
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ buffer := &bytes.Buffer{}
+ tarWriter := tar.NewWriter(buffer)
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeDir,
Name: "archive/",
Mode: 0o777,
}))
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeDir,
Name: "archive/.dir/",
Mode: 0o777,
}))
data := []byte("# contents of archive/.dir/.file\n")
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeReg,
Name: "archive/.dir/.file",
Size: int64(len(data)),
Mode: 0o666,
}))
- _, err := w.Write(data)
+ _, err := tarWriter.Write(data)
assert.NoError(t, err)
linkname := ".file"
- assert.NoError(t, w.WriteHeader(&tar.Header{
+ assert.NoError(t, tarWriter.WriteHeader(&tar.Header{
Typeflag: tar.TypeSymlink,
Name: "archive/.dir/.symlink",
Linkname: linkname,
}))
- require.NoError(t, w.Close())
+ require.NoError(t, tarWriter.Close())
for _, tc := range []struct {
args []string
@@ -158,8 +158,8 @@ func TestImportCmd(t *testing.T) {
if tc.extraRoot != nil {
require.NoError(t, vfst.NewBuilder().Build(fileSystem, tc.extraRoot))
}
- c := newTestConfig(t, fileSystem, withStdin(bytes.NewReader(b.Bytes())))
- require.NoError(t, c.execute(append([]string{"import"}, tc.args...)))
+ config := newTestConfig(t, fileSystem, withStdin(bytes.NewReader(buffer.Bytes())))
+ require.NoError(t, config.execute(append([]string{"import"}, tc.args...)))
vfst.RunTests(t, fileSystem, "", tc.tests...)
})
})
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go
index 09e6751f9a2..1da50ac985a 100644
--- a/internal/cmd/main_test.go
+++ b/internal/cmd/main_test.go
@@ -217,8 +217,7 @@ func cmdMkFile(ts *testscript.TestScript, neg bool, args []string) {
}
for _, arg := range args {
filename := ts.MkAbs(arg)
- _, err := os.Lstat(filename)
- switch {
+ switch _, err := os.Lstat(filename); {
case err == nil:
ts.Fatalf("%s: already exists", arg)
case !errors.Is(err, fs.ErrNotExist):
@@ -613,18 +612,18 @@ func setup(env *testscript.Env) error {
// unix2DOS returns data with UNIX line endings converted to DOS line endings.
func unix2DOS(data []byte) ([]byte, error) {
- sb := strings.Builder{}
- s := bufio.NewScanner(bytes.NewReader(data))
- for s.Scan() {
- if _, err := sb.Write(s.Bytes()); err != nil {
+ builder := strings.Builder{}
+ scanner := bufio.NewScanner(bytes.NewReader(data))
+ for scanner.Scan() {
+ if _, err := builder.Write(scanner.Bytes()); err != nil {
return nil, err
}
- if _, err := sb.WriteString("\r\n"); err != nil {
+ if _, err := builder.WriteString("\r\n"); err != nil {
return nil, err
}
}
- if err := s.Err(); err != nil {
+ if err := scanner.Err(); err != nil {
return nil, err
}
- return []byte(sb.String()), nil
+ return []byte(builder.String()), nil
}
diff --git a/internal/cmd/managedcmd.go b/internal/cmd/managedcmd.go
index 1b201eb96fd..f1169426f89 100644
--- a/internal/cmd/managedcmd.go
+++ b/internal/cmd/managedcmd.go
@@ -50,9 +50,9 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c
sort.Slice(targetRelPaths, func(i, j int) bool {
return targetRelPaths[i] < targetRelPaths[j]
})
- sb := strings.Builder{}
+ builder := strings.Builder{}
for _, targetRelPath := range targetRelPaths {
- fmt.Fprintln(&sb, targetRelPath)
+ fmt.Fprintln(&builder, targetRelPath)
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
diff --git a/internal/cmd/mergecmd.go b/internal/cmd/mergecmd.go
index fa11488ee5a..3c32973ee65 100644
--- a/internal/cmd/mergecmd.go
+++ b/internal/cmd/mergecmd.go
@@ -140,14 +140,14 @@ func (c *Config) runMergeCmd(cmd *cobra.Command, args []string, sourceState *che
return err
}
- var sb strings.Builder
- if err := tmpl.Execute(&sb, templateData); err != nil {
+ builder := strings.Builder{}
+ if err := tmpl.Execute(&builder, templateData); err != nil {
return err
}
- args = append(args, sb.String())
+ args = append(args, builder.String())
// Detect template arguments.
- if arg != sb.String() {
+ if arg != builder.String() {
anyTemplateArgs = true
}
}
diff --git a/internal/cmd/sourcepathcmd.go b/internal/cmd/sourcepathcmd.go
index bc72752b135..0d82f475ed5 100644
--- a/internal/cmd/sourcepathcmd.go
+++ b/internal/cmd/sourcepathcmd.go
@@ -31,9 +31,9 @@ func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string, sourceState
return err
}
- sb := strings.Builder{}
+ builder := strings.Builder{}
for _, sourceAbsPath := range sourceAbsPaths {
- fmt.Fprintln(&sb, sourceAbsPath)
+ fmt.Fprintln(&builder, sourceAbsPath)
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go
index c85d60bce22..b6dcbaf6b95 100644
--- a/internal/cmd/statuscmd.go
+++ b/internal/cmd/statuscmd.go
@@ -40,7 +40,7 @@ func (c *Config) newStatusCmd() *cobra.Command {
}
func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
- sb := strings.Builder{}
+ builder := strings.Builder{}
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
statusCmdPreApplyFunc := func(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error {
log.Info().
@@ -62,7 +62,7 @@ func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *ch
y = statusRune(actualEntryState, targetEntryState)
}
if x != ' ' || y != ' ' {
- fmt.Fprintf(&sb, "%c%c %s\n", x, y, targetRelPath)
+ fmt.Fprintf(&builder, "%c%c %s\n", x, y, targetRelPath)
}
return chezmoi.Skip
}
@@ -75,7 +75,7 @@ func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *ch
}); err != nil {
return err
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
func statusRune(fromState, toState *chezmoi.EntryState) rune {
diff --git a/internal/cmd/statuscmd_test.go b/internal/cmd/statuscmd_test.go
index a56a28c1b86..92fa53ea9a6 100644
--- a/internal/cmd/statuscmd_test.go
+++ b/internal/cmd/statuscmd_test.go
@@ -56,7 +56,7 @@ func TestStatusCmd(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- var stdout strings.Builder
+ stdout := strings.Builder{}
require.NoError(t, newTestConfig(t, fileSystem, withStdout(&stdout)).execute(append([]string{"status"}, tc.args...)))
assert.Equal(t, tc.stdoutStr, stdout.String())
diff --git a/internal/cmd/templatefuncs.go b/internal/cmd/templatefuncs.go
index 737b4baad4d..5cffbc04d30 100644
--- a/internal/cmd/templatefuncs.go
+++ b/internal/cmd/templatefuncs.go
@@ -68,8 +68,7 @@ func (c *Config) joinPathTemplateFunc(elem ...string) string {
}
func (c *Config) lookPathTemplateFunc(file string) string {
- path, err := exec.LookPath(file)
- switch {
+ switch path, err := exec.LookPath(file); {
case err == nil:
return path
case errors.Is(err, exec.ErrNotFound):
@@ -101,8 +100,7 @@ func (c *Config) outputTemplateFunc(name string, args ...string) string {
}
func (c *Config) statTemplateFunc(name string) interface{} {
- info, err := c.fileSystem.Stat(name)
- switch {
+ switch info, err := c.fileSystem.Stat(name); {
case err == nil:
return map[string]interface{}{
"name": info.Name(),
diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go
index 18834b37785..3103dce9ed3 100644
--- a/internal/cmd/unmanagedcmd.go
+++ b/internal/cmd/unmanagedcmd.go
@@ -24,7 +24,7 @@ func (c *Config) newUnmanagedCmd() *cobra.Command {
}
func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
- sb := strings.Builder{}
+ builder := strings.Builder{}
if err := chezmoi.WalkDir(c.destSystem, c.DestDirAbsPath, func(destAbsPath chezmoi.AbsPath, info fs.FileInfo, err error) error {
if err != nil {
return err
@@ -36,7 +36,7 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState
_, managed := sourceState.Entry(targeRelPath)
ignored := sourceState.Ignored(targeRelPath)
if !managed && !ignored {
- sb.WriteString(string(targeRelPath) + "\n")
+ builder.WriteString(string(targeRelPath) + "\n")
}
if info.IsDir() && (!managed || ignored) {
return vfs.SkipDir
@@ -45,5 +45,5 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState
}); err != nil {
return err
}
- return c.writeOutputString(sb.String())
+ return c.writeOutputString(builder.String())
}
diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go
index 046641338a6..02c110f7701 100644
--- a/internal/cmd/upgradecmd.go
+++ b/internal/cmd/upgradecmd.go
@@ -259,13 +259,11 @@ func (c *Config) getLibc() (string, error) {
// writes to stdout and exits with code 0. On musl libc systems it writes to
// stderr and exits with code 1.
lddCmd := exec.Command("ldd", "--version")
- if output, _ := c.baseSystem.IdempotentCmdCombinedOutput(lddCmd); len(output) != 0 {
- switch {
- case libcTypeGlibcRx.Match(output):
- return libcTypeGlibc, nil
- case libcTypeMuslRx.Match(output):
- return libcTypeMusl, nil
- }
+ switch output, _ := c.baseSystem.IdempotentCmdCombinedOutput(lddCmd); {
+ case libcTypeGlibcRx.Match(output):
+ return libcTypeGlibc, nil
+ case libcTypeMuslRx.Match(output):
+ return libcTypeMusl, nil
}
// Second, try getconf GNU_LIBC_VERSION.
@@ -303,19 +301,18 @@ func (c *Config) replaceExecutable(ctx context.Context, executableFilenameAbsPat
}
// Extract the executable from the archive.
- gzipr, err := gzip.NewReader(bytes.NewReader(data))
+ gzipReader, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return err
}
- defer gzipr.Close()
- tr := tar.NewReader(gzipr)
+ defer gzipReader.Close()
+ tarReader := tar.NewReader(gzipReader)
var executableData []byte
FOR:
for {
- h, err := tr.Next()
- switch {
- case err == nil && h.Name == c.upgrade.repo:
- executableData, err = io.ReadAll(tr)
+ switch header, err := tarReader.Next(); {
+ case err == nil && header.Name == c.upgrade.repo:
+ executableData, err = io.ReadAll(tarReader)
if err != nil {
return err
}
diff --git a/internal/cmd/util_windows.go b/internal/cmd/util_windows.go
index b1f4249bf76..4db388573d8 100644
--- a/internal/cmd/util_windows.go
+++ b/internal/cmd/util_windows.go
@@ -34,13 +34,13 @@ var defaultInterpreters = map[string]*chezmoi.Interpreter{
// enableVirtualTerminalProcessing enables virtual terminal processing. See
// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences.
func enableVirtualTerminalProcessing(w io.Writer) error {
- f, ok := w.(*os.File)
+ file, ok := w.(*os.File)
if !ok {
return nil
}
var dwMode uint32
- if err := windows.GetConsoleMode(windows.Handle(f.Fd()), &dwMode); err != nil {
+ if err := windows.GetConsoleMode(windows.Handle(file.Fd()), &dwMode); err != nil {
return nil // Ignore error in the case that fd is not a terminal.
}
- return windows.SetConsoleMode(windows.Handle(f.Fd()), dwMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+ return windows.SetConsoleMode(windows.Handle(file.Fd()), dwMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}
|
chore
|
Miscellaneous code tidy-ups
|
e102de5d9df613f2da115f803552076368944d3b
|
2024-06-12 12:17:03
|
Donald Guy
|
chore: add test to ensure config struct tags match across marshal formats
| false
|
diff --git a/internal/chezmoi/interpreter.go b/internal/chezmoi/interpreter.go
index c82ea0efbc0..15036d2fdc7 100644
--- a/internal/chezmoi/interpreter.go
+++ b/internal/chezmoi/interpreter.go
@@ -7,8 +7,8 @@ import (
// An Interpreter interprets scripts.
type Interpreter struct {
- Command string `mapstructure:"command"`
- Args []string `mapstructure:"args"`
+ Command string `json:"command" mapstructure:"command" yaml:"command"`
+ Args []string `json:"args" mapstructure:"args" yaml:"args"`
}
// ExecCommand returns the *exec.Cmd to interpret name.
diff --git a/internal/cmd/config_tags_test.go b/internal/cmd/config_tags_test.go
new file mode 100644
index 00000000000..4497e6df49e
--- /dev/null
+++ b/internal/cmd/config_tags_test.go
@@ -0,0 +1,96 @@
+package cmd
+
+import (
+ "fmt"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+var expectedTags = []string{"json", "yaml", "mapstructure"}
+
+func TestExportedFieldsHaveMatchingMarshalTags(t *testing.T) {
+ failed, errmsg := verifyTagsArePresentAndMatch(reflect.TypeFor[ConfigFile]())
+ if failed {
+ t.Error(errmsg)
+ }
+}
+
+func fieldTypesNeedsVerification(ft reflect.Type) []reflect.Type {
+ kind := ft.Kind()
+ if kind < reflect.Array || kind == reflect.String { // its a ~scalar type
+ return []reflect.Type{}
+ } else if kind == reflect.Struct {
+ return []reflect.Type{ft}
+ }
+ switch kind {
+ case reflect.Pointer:
+ fallthrough
+ case reflect.Array:
+ fallthrough
+ case reflect.Slice:
+ return fieldTypesNeedsVerification(ft.Elem())
+ case reflect.Map:
+ return append(fieldTypesNeedsVerification(ft.Key()), fieldTypesNeedsVerification(ft.Elem())...)
+ default:
+ return []reflect.Type{} // ... we'll assume interface types, funcs, chans are okay.
+ }
+}
+
+func verifyTagsArePresentAndMatch(structType reflect.Type) (failed bool, errmsg string) {
+ name := structType.Name()
+ fields := reflect.VisibleFields(structType)
+ failed = false
+
+ var errs strings.Builder
+
+ for _, f := range fields {
+ if !f.IsExported() {
+ continue
+ }
+
+ ts := f.Tag
+ tagValueGroups := make(map[string][]string)
+
+ for _, tagName := range expectedTags {
+ tagValue, tagPresent := ts.Lookup(tagName)
+
+ if !tagPresent {
+ errs.WriteString(fmt.Sprintf("\n%s field %s is missing a `%s:` tag", name, f.Name, tagName))
+ failed = true
+ }
+
+ matchingTags, notFirstOccurrence := tagValueGroups[tagValue]
+ if notFirstOccurrence {
+ tagValueGroups[tagValue] = append(matchingTags, tagName)
+ } else {
+ tagValueGroups[tagValue] = []string{tagName}
+ }
+ }
+
+ if len(tagValueGroups) > 1 {
+ errs.WriteString(fmt.Sprintf("\n%s field %s has non-matching tag names:", name, f.Name))
+
+ for value, tagsMatching := range tagValueGroups {
+ if len(tagsMatching) == 1 {
+ errs.WriteString(fmt.Sprintf("\n %s says \"%s\"", tagsMatching[0], value))
+ } else {
+ errs.WriteString(fmt.Sprintf("\n (%s) each say \"%s\"", strings.Join(tagsMatching, ", "), value))
+ }
+ }
+ failed = true
+ }
+
+ verifyTypes := fieldTypesNeedsVerification(f.Type)
+ for _, ft := range verifyTypes {
+ subFailed, suberrs := verifyTagsArePresentAndMatch(ft)
+ if subFailed {
+ errs.WriteString(fmt.Sprintf("\n In %s.%s:", name, f.Name))
+ errs.WriteString(strings.ReplaceAll(suberrs, "\n", "\n "))
+ failed = true
+ }
+ }
+ }
+
+ return failed, errs.String()
+}
diff --git a/internal/cmd/config_test.go b/internal/cmd/config_test.go
index b7f09fb08fe..e2b7350b0eb 100644
--- a/internal/cmd/config_test.go
+++ b/internal/cmd/config_test.go
@@ -1,11 +1,14 @@
package cmd
import (
+ "fmt"
"io"
"io/fs"
"path/filepath"
+ "reflect"
"runtime"
"strconv"
+ "strings"
"testing"
"github.com/alecthomas/assert/v2"
@@ -16,6 +19,43 @@ import (
"github.com/twpayne/chezmoi/v2/internal/chezmoitest"
)
+func TestTagFieldNamesMatch(t *testing.T) {
+ fields := reflect.VisibleFields(reflect.TypeFor[ConfigFile]())
+ expectedTags := []string{"json", "yaml", "mapstructure"}
+
+ for _, f := range fields {
+ ts := f.Tag
+ tagValueGroups := make(map[string][]string)
+
+ for _, tagName := range expectedTags {
+ tagValue, tagPresent := ts.Lookup(tagName)
+
+ if !tagPresent {
+ t.Errorf("ConfigFile field %s is missing a %s tag", f.Name, tagName)
+ }
+
+ matchingTags, notFirstOccurrence := tagValueGroups[tagValue]
+ if notFirstOccurrence {
+ tagValueGroups[tagValue] = append(matchingTags, tagName)
+ } else {
+ tagValueGroups[tagValue] = []string{tagName}
+ }
+ }
+
+ if len(tagValueGroups) > 1 {
+ valueMsgs := []string{}
+ for value, tagsMatching := range tagValueGroups {
+ if len(tagsMatching) == 1 {
+ valueMsgs = append(valueMsgs, fmt.Sprintf("%s says \"%s\"", tagsMatching[0], value))
+ } else {
+ valueMsgs = append(valueMsgs, fmt.Sprintf("(%s) each say \"%s\"", strings.Join(tagsMatching, ", "), value))
+ }
+ }
+ t.Errorf("ConfigFile field %s has non-matching tag names:\n %s", f.Name, strings.Join(valueMsgs, "\n "))
+ }
+ }
+}
+
func TestAddTemplateFuncPanic(t *testing.T) {
chezmoitest.WithTestFS(t, nil, func(fileSystem vfs.FS) {
config := newTestConfig(t, fileSystem)
|
chore
|
add test to ensure config struct tags match across marshal formats
|
345a55e5133091ac37699eb1b4770ad8d416d024
|
2025-02-14 05:15:23
|
Tom Payne
|
chore: Build with Go 1.24
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b6b4e1e82ae..f9dbc51a29e 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -21,7 +21,7 @@ env:
FIND_TYPOS_VERSION: 0.0.3 # https://github.com/twpayne/find-typos/tags
GO_VERSION: 1.24.0 # https://go.dev/doc/devel/release
GOFUMPT_VERSION: 0.7.0 # https://github.com/mvdan/gofumpt/releases
- GOLANGCI_LINT_VERSION: 1.64.2 # https://github.com/golangci/golangci-lint/releases
+ GOLANGCI_LINT_VERSION: 1.64.4 # https://github.com/golangci/golangci-lint/releases
GOLINES_VERSION: 0.12.2 # https://github.com/segmentio/golines/releases
GORELEASER_VERSION: 2.7.0 # https://github.com/goreleaser/goreleaser/releases
GOVERSIONINFO_VERSION: 1.4.1 # https://github.com/josephspurrier/goversioninfo/releases
@@ -456,7 +456,7 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
upload-cache: false
- - uses: golangci/golangci-lint-action@051d91933864810ecd5e2ea2cfd98f6a5bca5347
+ - uses: golangci/golangci-lint-action@e0ebdd245eea59746bb0b28ea6a9871d3e35fbc9
with:
version: v${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
diff --git a/.golangci.yml b/.golangci.yml
index 3b94a8f1e85..ced4d027fb9 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,5 +1,5 @@
run:
- go: '1.23'
+ go: '1.24'
linters:
enable:
diff --git a/assets/chezmoi.io/docs/developer-guide/index.md b/assets/chezmoi.io/docs/developer-guide/index.md
index 6ea1de2eee3..507c92c03ce 100644
--- a/assets/chezmoi.io/docs/developer-guide/index.md
+++ b/assets/chezmoi.io/docs/developer-guide/index.md
@@ -10,7 +10,7 @@
chezmoi is written in [Go](https://golang.org) and development happens on
[GitHub](https://github.com). chezmoi is a standard Go project, using standard
-Go tooling. chezmoi requires Go 1.23 or later.
+Go tooling. chezmoi requires Go 1.24 or later.
Checkout chezmoi:
diff --git a/assets/chezmoi.io/docs/developer-guide/website.md b/assets/chezmoi.io/docs/developer-guide/website.md
index 67769ce8458..2d50135e40c 100644
--- a/assets/chezmoi.io/docs/developer-guide/website.md
+++ b/assets/chezmoi.io/docs/developer-guide/website.md
@@ -6,7 +6,7 @@ contents of the `assets/chezmoi.io/docs/` directory. It is hosted by
[GitHub pages](https://pages.github.com/) from the
[`gh-pages` branch](https://github.com/twpayne/chezmoi/tree/gh-pages).
-To build the website locally, Go 1.23 (or later) and
+To build the website locally, Go 1.24 (or later) and
[uv](https://docs.astral.sh/uv/getting-started/installation/) 0.4.15 (or later)
must be installed. Python 3.10 (or later) is required, but may be installed with
`uv`:
diff --git a/assets/chezmoi.io/docs/install.md.tmpl b/assets/chezmoi.io/docs/install.md.tmpl
index 71abcbc784d..a669d033cf2 100644
--- a/assets/chezmoi.io/docs/install.md.tmpl
+++ b/assets/chezmoi.io/docs/install.md.tmpl
@@ -247,7 +247,7 @@ pre-built binary and shell completions.
## Install from source
-Download, build, and install chezmoi for your system with Go 1.23 or later:
+Download, build, and install chezmoi for your system with Go 1.24 or later:
```sh
git clone https://github.com/twpayne/chezmoi.git
diff --git a/assets/docker/entrypoint.sh b/assets/docker/entrypoint.sh
index e3d227c7955..7008ca0cce9 100755
--- a/assets/docker/entrypoint.sh
+++ b/assets/docker/entrypoint.sh
@@ -4,7 +4,8 @@ set -euf
git config --global --add safe.directory /chezmoi
-GO=${GO:-go}
+export GO="${GO:-go}"
+export GOTOOLCHAIN=auto
if [ -d "/go-cache" ]; then
export GOCACHE="/go-cache/cache"
diff --git a/go.mod b/go.mod
index 433d94f8f19..9cc8a2d2fb7 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/twpayne/chezmoi/v2
-go 1.23.6
+go 1.24.0
require (
filippo.io/age v1.2.1
diff --git a/internal/chezmoi/dumpsystem_test.go b/internal/chezmoi/dumpsystem_test.go
index 735f6e8bd3a..80a3d01cae8 100644
--- a/internal/chezmoi/dumpsystem_test.go
+++ b/internal/chezmoi/dumpsystem_test.go
@@ -1,7 +1,6 @@
package chezmoi
import (
- "context"
"io/fs"
"testing"
@@ -31,7 +30,7 @@ func TestDumpSystem(t *testing.T) {
"symlink_symlink": ".dir/subdir/file\n",
},
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
diff --git a/internal/chezmoi/sourcestate_test.go b/internal/chezmoi/sourcestate_test.go
index 4e8b7ce3f2e..d7c9516054d 100644
--- a/internal/chezmoi/sourcestate_test.go
+++ b/internal/chezmoi/sourcestate_test.go
@@ -3,7 +3,6 @@ package chezmoi
import (
"archive/tar"
"bytes"
- "context"
"crypto/sha256"
"errors"
"fmt"
@@ -516,7 +515,7 @@ func TestSourceStateAdd(t *testing.T) {
".template": "key = value\n",
},
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
persistentState := NewMockPersistentState()
if tc.extraRoot != nil {
@@ -577,7 +576,7 @@ func TestSourceStateAddInExternal(t *testing.T) {
}
chezmoitest.WithTestFS(t, root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
persistentState := NewMockPersistentState()
s := NewSourceState(
@@ -808,7 +807,7 @@ func TestSourceStateApplyAll(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
persistentState := NewMockPersistentState()
sourceStateOptions := []SourceStateOption{
@@ -1516,7 +1515,7 @@ func TestSourceStateRead(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
@@ -1628,7 +1627,7 @@ func TestSourceStateReadExternal(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
@@ -1664,7 +1663,7 @@ func TestSourceStateReadScriptsConcurrent(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
@@ -1707,7 +1706,7 @@ func TestSourceStateReadExternalCache(t *testing.T) {
),
},
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
readSourceState := func(refreshExternals RefreshExternals) {
@@ -1798,7 +1797,7 @@ func TestSourceStateTargetRelPaths(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
@@ -2098,7 +2097,7 @@ func TestSourceStateExternalErrors(t *testing.T) {
chezmoitest.WithTestFS(t, map[string]any{
"/home/user/.local/share/chezmoi": tc.shareDir,
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
diff --git a/internal/chezmoi/system_test.go b/internal/chezmoi/system_test.go
index 6ecfa6dd0e3..cbc026a8eb7 100644
--- a/internal/chezmoi/system_test.go
+++ b/internal/chezmoi/system_test.go
@@ -30,7 +30,7 @@ func TestConcurrentWalkSourceDir(t *testing.T) {
var actualSourceAbsPaths []AbsPath
chezmoitest.WithTestFS(t, root, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
var mutex sync.Mutex
walkFunc := func(ctx context.Context, sourceAbsPath AbsPath, fileInfo fs.FileInfo, err error) error {
diff --git a/internal/chezmoi/tarwritersystem_test.go b/internal/chezmoi/tarwritersystem_test.go
index ab42159e469..a9f31e074ac 100644
--- a/internal/chezmoi/tarwritersystem_test.go
+++ b/internal/chezmoi/tarwritersystem_test.go
@@ -3,7 +3,6 @@ package chezmoi
import (
"archive/tar"
"bytes"
- "context"
"io"
"io/fs"
"testing"
@@ -34,7 +33,7 @@ func TestTarWriterSystem(t *testing.T) {
"symlink_symlink": ".dir/subdir/file\n",
},
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
diff --git a/internal/chezmoi/zipwritersystem_test.go b/internal/chezmoi/zipwritersystem_test.go
index d58b432cb1d..24a3c81f08f 100644
--- a/internal/chezmoi/zipwritersystem_test.go
+++ b/internal/chezmoi/zipwritersystem_test.go
@@ -2,7 +2,6 @@ package chezmoi
import (
"bytes"
- "context"
"io"
"io/fs"
"testing"
@@ -35,7 +34,7 @@ func TestZIPWriterSystem(t *testing.T) {
"symlink_symlink": ".dir/subdir/file\n",
},
}, func(fileSystem vfs.FS) {
- ctx := context.Background()
+ ctx := t.Context()
system := NewRealSystem(fileSystem)
s := NewSourceState(
WithBaseSystem(system),
|
chore
|
Build with Go 1.24
|
7022068510b9bc7d85b77880585c79fce2d29b7b
|
2025-03-04 22:37:25
|
Tom Payne
|
chore: Improve comments and variable names
| false
|
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index e25017800b8..67f2fdbedd3 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -1813,8 +1813,8 @@ func (s *SourceState) newSourceStateDir(absPath AbsPath, sourceRelPath SourceRel
}
// newCreateTargetStateEntryFunc returns a targetStateEntryFunc that returns a
-// file with sourceLazyContents if the file does not already exist, or returns
-// the actual file's contents unchanged if the file already exists.
+// file with the value of sourceContentsFunc if the file does not already exist,
+// or returns the actual file's contents unchanged if the file already exists.
func (s *SourceState) newCreateTargetStateEntryFunc(
sourceRelPath SourceRelPath,
fileAttr FileAttr,
@@ -1860,15 +1860,15 @@ func (s *SourceState) newCreateTargetStateEntryFunc(
}
// newFileTargetStateEntryFunc returns a targetStateEntryFunc that returns a
-// file with sourceLazyContents.
+// file with the contents of the value of sourceContentsFunc.
func (s *SourceState) newFileTargetStateEntryFunc(
sourceRelPath SourceRelPath,
fileAttr FileAttr,
- contentsFunc func() ([]byte, error),
+ sourceContentsFunc func() ([]byte, error),
) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
if s.mode == ModeSymlink && !fileAttr.Encrypted && !fileAttr.Executable && !fileAttr.Private && !fileAttr.Template {
- switch contents, err := contentsFunc(); {
+ switch contents, err := sourceContentsFunc(); {
case err != nil:
return nil, err
case isEmpty(contents) && !fileAttr.Empty:
@@ -1884,7 +1884,7 @@ func (s *SourceState) newFileTargetStateEntryFunc(
}
}
executedContentsFunc := sync.OnceValues(func() ([]byte, error) {
- contents, err := contentsFunc()
+ contents, err := sourceContentsFunc()
if err != nil {
return nil, err
}
|
chore
|
Improve comments and variable names
|
45cd5f39ff2eaac415df99828eb74116f27ff044
|
2022-01-26 08:10:10
|
Tom Payne
|
chore: Improve implementation of .chezmoiremove
| false
|
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index ad67b13226d..7f8ce7a2f84 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -79,6 +79,7 @@ type SourceState struct {
umask fs.FileMode
encryption Encryption
ignore *patternSet
+ remove *patternSet
interpreters map[string]*Interpreter
httpClient *http.Client
logger *zerolog.Logger
@@ -229,6 +230,7 @@ func NewSourceState(options ...SourceStateOption) *SourceState {
umask: Umask,
encryption: NoEncryption{},
ignore: newPatternSet(),
+ remove: newPatternSet(),
httpClient: http.DefaultClient,
logger: &log.Logger,
readTemplateData: true,
@@ -835,32 +837,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
case fileInfo.Name() == ignoreName:
return s.addPatterns(s.ignore, sourceAbsPath, parentSourceRelPath)
case fileInfo.Name() == removeName:
- removePatterns := newPatternSet()
- if err := s.addPatterns(removePatterns, sourceAbsPath, sourceRelPath); err != nil {
- return err
- }
- matches, err := removePatterns.glob(s.system.UnderlyingFS(), ensureSuffix(s.destDirAbsPath.String(), "/"))
- if err != nil {
- return err
- }
- n := 0
- for _, match := range matches {
- if !s.Ignore(NewRelPath(match)) {
- matches[n] = match
- n++
- }
- }
- targetParentRelPath := parentSourceRelPath.TargetRelPath(s.encryption.EncryptedSuffix())
- matches = matches[:n]
- for _, match := range matches {
- targetRelPath := targetParentRelPath.JoinString(match)
- sourceStateEntry := &SourceStateRemove{
- sourceRelPath: sourceRelPath,
- targetRelPath: targetRelPath,
- }
- allSourceStateEntries[targetRelPath] = append(allSourceStateEntries[targetRelPath], sourceStateEntry)
- }
- return nil
+ return s.addPatterns(s.remove, sourceAbsPath, parentSourceRelPath)
case fileInfo.Name() == scriptsDirName:
scriptsDirSourceStateEntries, err := s.readScriptsDir(sourceAbsPath)
if err != nil {
@@ -954,6 +931,23 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
}
}
+ // Generate SourceStateRemoves for existing targets.
+ matches, err := s.remove.glob(s.system.UnderlyingFS(), ensureSuffix(s.destDirAbsPath.String(), "/"))
+ if err != nil {
+ return err
+ }
+ for _, match := range matches {
+ if s.Ignore(NewRelPath(match)) {
+ continue
+ }
+ targetRelPath := NewRelPath(match)
+ sourceStateEntry := &SourceStateRemove{
+ sourceRelPath: NewSourceRelPath(".chezmoiremove"),
+ targetRelPath: targetRelPath,
+ }
+ allSourceStateEntries[targetRelPath] = append(allSourceStateEntries[targetRelPath], sourceStateEntry)
+ }
+
// Generate SourceStateRemoves for exact directories.
for targetRelPath, sourceStateEntries := range allSourceStateEntries {
if len(sourceStateEntries) != 1 {
@@ -1001,7 +995,6 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
targetRelPaths = append(targetRelPaths, targetRelPath)
}
sort.Sort(targetRelPaths)
- var err error
for _, targetRelPath := range targetRelPaths {
sourceStateEntries := allSourceStateEntries[targetRelPath]
if len(sourceStateEntries) == 1 {
diff --git a/internal/chezmoi/sourcestate_test.go b/internal/chezmoi/sourcestate_test.go
index c6bdce3920e..7248a682366 100644
--- a/internal/chezmoi/sourcestate_test.go
+++ b/internal/chezmoi/sourcestate_test.go
@@ -1167,6 +1167,11 @@ func TestSourceStateRead(t *testing.T) {
targetRelPath: NewRelPath("file"),
},
}),
+ withRemove(
+ mustNewPatternSet(t, map[string]bool{
+ "file": true,
+ }),
+ ),
),
},
{
@@ -1193,6 +1198,54 @@ func TestSourceStateRead(t *testing.T) {
"file2": true,
}),
),
+ withRemove(
+ mustNewPatternSet(t, map[string]bool{
+ "file*": true,
+ }),
+ ),
+ ),
+ },
+ {
+ name: "chezmoiremove_and_ignore_in_subdir",
+ root: map[string]interface{}{
+ "/home/user": map[string]interface{}{
+ "dir": map[string]interface{}{
+ "file1": "",
+ "file2": "",
+ },
+ },
+ "/home/user/.local/share/chezmoi": map[string]interface{}{
+ "dir/.chezmoiignore": "file2\n",
+ "dir/.chezmoiremove": "file*\n",
+ },
+ },
+ expectedSourceState: NewSourceState(
+ withEntries(map[RelPath]SourceStateEntry{
+ NewRelPath("dir"): &SourceStateDir{
+ origin: "dir",
+ sourceRelPath: NewSourceRelDirPath("dir"),
+ Attr: DirAttr{
+ TargetName: "dir",
+ },
+ targetStateEntry: &TargetStateDir{
+ perm: 0o777 &^ chezmoitest.Umask,
+ },
+ },
+ NewRelPath("dir/file1"): &SourceStateRemove{
+ sourceRelPath: NewSourceRelPath(".chezmoiremove"),
+ targetRelPath: NewRelPath("dir/file1"),
+ },
+ }),
+ withIgnore(
+ mustNewPatternSet(t, map[string]bool{
+ "dir/file2": true,
+ }),
+ ),
+ withRemove(
+ mustNewPatternSet(t, map[string]bool{
+ "dir/file*": true,
+ }),
+ ),
),
},
{
@@ -1587,6 +1640,12 @@ func withIgnore(ignore *patternSet) SourceStateOption {
}
}
+func withRemove(remove *patternSet) SourceStateOption {
+ return func(s *SourceState) {
+ s.remove = remove
+ }
+}
+
// withUserTemplateData adds template data.
func withUserTemplateData(templateData map[string]interface{}) SourceStateOption {
return func(s *SourceState) {
|
chore
|
Improve implementation of .chezmoiremove
|
7b59cd98b8fe62c13f08524e7c44e2dc8db00a5a
|
2024-01-08 03:20:46
|
Tom Payne
|
chore: Update copyright year
| false
|
diff --git a/LICENSE b/LICENSE
index 9ec788a3976..ea8e16df597 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2018-2023 Tom Payne
+Copyright (c) 2018-2024 Tom Payne
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/assets/chezmoi.io/docs/license.md b/assets/chezmoi.io/docs/license.md
index e8de2c71ada..712852afa3e 100644
--- a/assets/chezmoi.io/docs/license.md
+++ b/assets/chezmoi.io/docs/license.md
@@ -2,7 +2,7 @@
The MIT License (MIT)
-Copyright (c) 2018-2023 Tom Payne
+Copyright (c) 2018-2024 Tom Payne
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml
index 7a72b60e40a..3bb3ac0f51d 100644
--- a/assets/chezmoi.io/mkdocs.yml
+++ b/assets/chezmoi.io/mkdocs.yml
@@ -2,7 +2,7 @@ site_name: chezmoi
site_url: https://chezmoi.io
site_description: Manage your dotfiles across multiple machines, securely.
site_author: Tom Payne
-copyright: Copyright © Tom Payne 2018-2023
+copyright: Copyright © Tom Payne 2018-2024
repo_name: twpayne/chezmoi
repo_url: https://github.com/twpayne/chezmoi
edit_uri: edit/master/assets/chezmoi.io/docs/
|
chore
|
Update copyright year
|
10dbbcd2be5049cc4a5bfe97820188d17455c057
|
2021-11-21 01:22:48
|
Tom Payne
|
chore: Break long lines
| false
|
diff --git a/.golangci.yml b/.golangci.yml
index 2b29beff956..f4ec3f82de8 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -31,6 +31,7 @@ linters:
- ifshort
- importas
- ineffassign
+ - lll
- makezero
- misspell
- nilerr
@@ -68,7 +69,6 @@ linters:
- godox
- goheader
- gomnd
- - lll
- maligned
- nakedret
- nestif
@@ -102,7 +102,9 @@ issues:
- linters:
- forbidigo
- gosec
+ - lll
path: ^internal/cmds/
- linters:
- gosec
+ - lll
path: "_test\\.go$"
diff --git a/internal/chezmoi/archivereadersystem.go b/internal/chezmoi/archivereadersystem.go
index 11abd01dc92..2e618014c8d 100644
--- a/internal/chezmoi/archivereadersystem.go
+++ b/internal/chezmoi/archivereadersystem.go
@@ -58,7 +58,9 @@ type ArchiveReaderSystemOptions struct {
// NewArchiveReaderSystem returns a new ArchiveReaderSystem reading from data
// and using archivePath as a hint for the archive format.
-func NewArchiveReaderSystem(archivePath string, data []byte, format ArchiveFormat, options ArchiveReaderSystemOptions) (*ArchiveReaderSystem, error) {
+func NewArchiveReaderSystem(
+ archivePath string, data []byte, format ArchiveFormat, options ArchiveReaderSystemOptions,
+) (*ArchiveReaderSystem, error) {
s := &ArchiveReaderSystem{
fileInfos: make(map[AbsPath]fs.FileInfo),
contents: make(map[AbsPath][]byte),
diff --git a/internal/chezmoi/autotemplate.go b/internal/chezmoi/autotemplate.go
index 01470865bf1..5f43730bcb3 100644
--- a/internal/chezmoi/autotemplate.go
+++ b/internal/chezmoi/autotemplate.go
@@ -78,7 +78,9 @@ func extractVariables(data map[string]interface{}) []templateVariable {
// extractVariablesHelper appends all template variables in data to variables
// and returns variables. data is assumed to be rooted at parent.
-func extractVariablesHelper(variables []templateVariable, parent []string, data map[string]interface{}) []templateVariable {
+func extractVariablesHelper(
+ variables []templateVariable, parent []string, data map[string]interface{},
+) []templateVariable {
for name, value := range data {
switch value := value.(type) {
case string:
diff --git a/internal/chezmoi/chezmoi.go b/internal/chezmoi/chezmoi.go
index ccad7110126..24f19145191 100644
--- a/internal/chezmoi/chezmoi.go
+++ b/internal/chezmoi/chezmoi.go
@@ -61,7 +61,9 @@ const (
var (
dirPrefixRegexp = regexp.MustCompile(`\A(dot|exact|literal|readonly|private)_`)
- filePrefixRegexp = regexp.MustCompile(`\A(after|before|create|dot|empty|encrypted|executable|literal|modify|once|private|readonly|remove|run|symlink)_`)
+ filePrefixRegexp = regexp.MustCompile(
+ `\A(after|before|create|dot|empty|encrypted|executable|literal|modify|once|private|readonly|remove|run|symlink)_`,
+ )
fileSuffixRegexp = regexp.MustCompile(`\.(literal|tmpl)\z`)
)
diff --git a/internal/chezmoi/diff.go b/internal/chezmoi/diff.go
index 346a29b699d..7e82492cc9c 100644
--- a/internal/chezmoi/diff.go
+++ b/internal/chezmoi/diff.go
@@ -64,7 +64,11 @@ func (p *gitDiffPatch) Message() string { return p.message }
// DiffPatch returns a github.com/go-git/go-git/plumbing/format/diff.Patch for
// path from the given data and mode to the given data and mode.
-func DiffPatch(path RelPath, fromData []byte, fromMode fs.FileMode, toData []byte, toMode fs.FileMode) (diff.Patch, error) {
+func DiffPatch(
+ path RelPath,
+ fromData []byte, fromMode fs.FileMode,
+ toData []byte, toMode fs.FileMode,
+) (diff.Patch, error) {
isBinary := isBinary(fromData) || isBinary(toData)
var from diff.File
diff --git a/internal/chezmoi/entrystate.go b/internal/chezmoi/entrystate.go
index 2aeade14725..84d2358fc57 100644
--- a/internal/chezmoi/entrystate.go
+++ b/internal/chezmoi/entrystate.go
@@ -27,7 +27,7 @@ const (
type EntryState struct {
Type EntryStateType `json:"type" toml:"type" yaml:"type"`
Mode fs.FileMode `json:"mode,omitempty" toml:"mode,omitempty" yaml:"mode,omitempty"`
- ContentsSHA256 HexBytes `json:"contentsSHA256,omitempty" toml:"contentsSHA256,omitempty" yaml:"contentsSHA256,omitempty"` //nolint:tagliatelle
+ ContentsSHA256 HexBytes `json:"contentsSHA256,omitempty" toml:"contentsSHA256,omitempty" yaml:"contentsSHA256,omitempty"` //nolint:lll,tagliatelle
contents []byte
overwrite bool
}
diff --git a/internal/chezmoi/entrytypeset.go b/internal/chezmoi/entrytypeset.go
index ff64a92c122..4156cbe59b7 100644
--- a/internal/chezmoi/entrytypeset.go
+++ b/internal/chezmoi/entrytypeset.go
@@ -29,7 +29,12 @@ const (
EntryTypeEncrypted
// EntryTypesAll is all entry types.
- EntryTypesAll EntryTypeBits = EntryTypeDirs | EntryTypeFiles | EntryTypeRemove | EntryTypeScripts | EntryTypeSymlinks | EntryTypeEncrypted
+ EntryTypesAll EntryTypeBits = EntryTypeDirs |
+ EntryTypeFiles |
+ EntryTypeRemove |
+ EntryTypeScripts |
+ EntryTypeSymlinks |
+ EntryTypeEncrypted
// EntryTypesNone is no entry types.
EntryTypesNone EntryTypeBits = 0
diff --git a/internal/chezmoi/externaldiffsystem.go b/internal/chezmoi/externaldiffsystem.go
index 8d6de4c3454..f3d62c2d81d 100644
--- a/internal/chezmoi/externaldiffsystem.go
+++ b/internal/chezmoi/externaldiffsystem.go
@@ -28,7 +28,9 @@ type ExternalDiffSystemOptions struct {
}
// NewExternalDiffSystem creates a new ExternalDiffSystem.
-func NewExternalDiffSystem(system System, command string, args []string, destDirAbsPath AbsPath, options *ExternalDiffSystemOptions) *ExternalDiffSystem {
+func NewExternalDiffSystem(
+ system System, command string, args []string, destDirAbsPath AbsPath, options *ExternalDiffSystemOptions,
+) *ExternalDiffSystem {
return &ExternalDiffSystem{
system: system,
command: command,
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index 93d962ca1a9..2ae1d04e771 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -243,7 +243,10 @@ type AddOptions struct {
}
// Add adds destAbsPathInfos to s.
-func (s *SourceState) Add(sourceSystem System, persistentState PersistentState, destSystem System, destAbsPathInfos map[AbsPath]fs.FileInfo, options *AddOptions) error {
+func (s *SourceState) Add(
+ sourceSystem System, persistentState PersistentState, destSystem System, destAbsPathInfos map[AbsPath]fs.FileInfo,
+ options *AddOptions,
+) error {
type sourceUpdate struct {
destAbsPath AbsPath
entryState *EntryState
@@ -289,7 +292,9 @@ DESTABSPATH:
if err != nil {
return err
}
- newSourceStateEntry, err := s.sourceStateEntry(actualStateEntry, destAbsPath, destAbsPathInfo, parentSourceRelPath, options)
+ newSourceStateEntry, err := s.sourceStateEntry(
+ actualStateEntry, destAbsPath, destAbsPathInfo, parentSourceRelPath, options,
+ )
if err != nil {
return err
}
@@ -408,15 +413,21 @@ DESTABSPATH:
for _, sourceUpdate := range sourceUpdates {
for _, sourceRelPath := range sourceUpdate.sourceRelPaths {
- if err := targetSourceState.Apply(sourceSystem, sourceSystem, NullPersistentState{}, s.sourceDirAbsPath, sourceRelPath.RelPath(), ApplyOptions{
- Include: options.Include,
- Umask: s.umask,
- }); err != nil {
+ err := targetSourceState.Apply(
+ sourceSystem, sourceSystem, NullPersistentState{}, s.sourceDirAbsPath, sourceRelPath.RelPath(),
+ ApplyOptions{
+ Include: options.Include,
+ Umask: s.umask,
+ },
+ )
+ if err != nil {
return err
}
}
if !sourceUpdate.destAbsPath.Empty() {
- if err := persistentStateSet(persistentState, EntryStateBucket, sourceUpdate.destAbsPath.Bytes(), sourceUpdate.entryState); err != nil {
+ if err := persistentStateSet(
+ persistentState, EntryStateBucket, sourceUpdate.destAbsPath.Bytes(), sourceUpdate.entryState,
+ ); err != nil {
return err
}
}
@@ -427,7 +438,9 @@ DESTABSPATH:
// AddDestAbsPathInfos adds an fs.FileInfo to destAbsPathInfos for destAbsPath
// and any of its parents which are not already known.
-func (s *SourceState) AddDestAbsPathInfos(destAbsPathInfos map[AbsPath]fs.FileInfo, system System, destAbsPath AbsPath, fileInfo fs.FileInfo) error {
+func (s *SourceState) AddDestAbsPathInfos(
+ destAbsPathInfos map[AbsPath]fs.FileInfo, system System, destAbsPath AbsPath, fileInfo fs.FileInfo,
+) error {
for {
if _, err := destAbsPath.TrimDirPrefix(s.destDirAbsPath); err != nil {
return err
@@ -461,7 +474,9 @@ func (s *SourceState) AddDestAbsPathInfos(destAbsPathInfos map[AbsPath]fs.FileIn
}
// A PreApplyFunc is called before a target is applied.
-type PreApplyFunc func(targetRelPath RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *EntryState) error
+type PreApplyFunc func(
+ targetRelPath RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *EntryState,
+) error
// ApplyOptions are options to SourceState.ApplyAll and SourceState.ApplyOne.
type ApplyOptions struct {
@@ -471,7 +486,10 @@ type ApplyOptions struct {
}
// Apply updates targetRelPath in targetDir in destSystem to match s.
-func (s *SourceState) Apply(targetSystem, destSystem System, persistentState PersistentState, targetDir AbsPath, targetRelPath RelPath, options ApplyOptions) error {
+func (s *SourceState) Apply(
+ targetSystem, destSystem System, persistentState PersistentState, targetDir AbsPath, targetRelPath RelPath,
+ options ApplyOptions,
+) error {
sourceStateEntry := s.root.Get(targetRelPath)
if !options.Include.IncludeEncrypted() {
@@ -586,13 +604,15 @@ func (s *SourceState) Apply(targetSystem, destSystem System, persistentState Per
// respect to the last written state, we record the effect of the last
// apply as the last written state.
if targetEntryState.Equivalent(actualEntryState) && !lastWrittenEntryState.Equivalent(actualEntryState) {
- if err := persistentStateSet(persistentState, EntryStateBucket, targetAbsPath.Bytes(), targetEntryState); err != nil {
+ err := persistentStateSet(persistentState, EntryStateBucket, targetAbsPath.Bytes(), targetEntryState)
+ if err != nil {
return err
}
lastWrittenEntryState = targetEntryState
}
- if err := options.PreApplyFunc(targetRelPath, targetEntryState, lastWrittenEntryState, actualEntryState); err != nil {
+ err = options.PreApplyFunc(targetRelPath, targetEntryState, lastWrittenEntryState, actualEntryState)
+ if err != nil {
return err
}
}
@@ -693,7 +713,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
// Read all source entries.
allSourceStateEntries := make(map[RelPath][]SourceStateEntry)
- if err := WalkSourceDir(s.system, s.sourceDirAbsPath, func(sourceAbsPath AbsPath, fileInfo fs.FileInfo, err error) error {
+ walkFunc := func(sourceAbsPath AbsPath, fileInfo fs.FileInfo, err error) error {
if err != nil {
return err
}
@@ -794,7 +814,8 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
mode: fileInfo.Mode(),
}
}
- }); err != nil {
+ }
+ if err := WalkSourceDir(s.system, s.sourceDirAbsPath, walkFunc); err != nil {
return err
}
@@ -1040,7 +1061,7 @@ func (s *SourceState) addTemplateData(sourceAbsPath AbsPath) error {
// addTemplatesDir adds all templates in templateDir to s.
func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error {
- return WalkSourceDir(s.system, templatesDirAbsPath, func(templateAbsPath AbsPath, fileInfo fs.FileInfo, err error) error {
+ walkFunc := func(templateAbsPath AbsPath, fileInfo fs.FileInfo, err error) error {
switch {
case err != nil:
return err
@@ -1068,7 +1089,8 @@ func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error {
mode: fileInfo.Mode(),
}
}
- })
+ }
+ return WalkSourceDir(s.system, templatesDirAbsPath, walkFunc)
}
// addVersionFile reads a .chezmoiversion file from source path and updates s's
@@ -1100,7 +1122,9 @@ func (s *SourceState) executeTemplate(templateAbsPath AbsPath) ([]byte, error) {
// getExternalDataRaw returns the raw data for external at externalRelPath,
// possibly from the external cache.
-func (s *SourceState) getExternalDataRaw(ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions) ([]byte, error) {
+func (s *SourceState) getExternalDataRaw(
+ ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions,
+) ([]byte, error) {
var now time.Time
if options != nil && options.TimeNow != nil {
now = options.TimeNow()
@@ -1167,7 +1191,9 @@ func (s *SourceState) getExternalDataRaw(ctx context.Context, externalRelPath Re
// getExternalDataRaw reads the external data for externalRelPath from
// external.URL.
-func (s *SourceState) getExternalData(ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions) ([]byte, error) {
+func (s *SourceState) getExternalData(
+ ctx context.Context, externalRelPath RelPath, external External, options *ReadOptions,
+) ([]byte, error) {
data, err := s.getExternalDataRaw(ctx, externalRelPath, external, options)
if err != nil {
return nil, err
@@ -1209,7 +1235,9 @@ func (s *SourceState) newSourceStateDir(sourceRelPath SourceRelPath, dirAttr Dir
// newCreateTargetStateEntryFunc returns a targetStateEntryFunc that returns a
// file with sourceLazyContents if the file does not already exist, or returns
// the actual file's contents unchanged if the file already exists.
-func (s *SourceState) newCreateTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents) targetStateEntryFunc {
+func (s *SourceState) newCreateTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
var lazyContents *lazyContents
switch contents, err := destSystem.ReadFile(destAbsPath); {
@@ -1242,7 +1270,9 @@ func (s *SourceState) newCreateTargetStateEntryFunc(sourceRelPath SourceRelPath,
// newFileTargetStateEntryFunc returns a targetStateEntryFunc that returns a
// file with sourceLazyContents.
-func (s *SourceState) newFileTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents) targetStateEntryFunc {
+func (s *SourceState) newFileTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
if s.mode == ModeSymlink && !fileAttr.Encrypted && !fileAttr.Executable && !fileAttr.Private && !fileAttr.Template {
switch contents, err := sourceLazyContents.Contents(); {
@@ -1280,7 +1310,9 @@ func (s *SourceState) newFileTargetStateEntryFunc(sourceRelPath SourceRelPath, f
// newModifyTargetStateEntryFunc returns a targetStateEntryFunc that returns a
// file with the contents modified by running the sourceLazyContents script.
-func (s *SourceState) newModifyTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents, interpreter *Interpreter) targetStateEntryFunc {
+func (s *SourceState) newModifyTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents, interpreter *Interpreter,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
contentsFunc := func() (contents []byte, err error) {
// Read the current contents of the target.
@@ -1345,7 +1377,9 @@ func (s *SourceState) newModifyTargetStateEntryFunc(sourceRelPath SourceRelPath,
// newRemoveTargetStateEntryFunc returns a targetStateEntryFunc that removes a
// target.
-func (s *SourceState) newRemoveTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr) targetStateEntryFunc {
+func (s *SourceState) newRemoveTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
return &TargetStateRemove{}, nil
}
@@ -1353,7 +1387,10 @@ func (s *SourceState) newRemoveTargetStateEntryFunc(sourceRelPath SourceRelPath,
// newScriptTargetStateEntryFunc returns a targetStateEntryFunc that returns a
// script with sourceLazyContents.
-func (s *SourceState) newScriptTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath, sourceLazyContents *lazyContents, interpreter *Interpreter) targetStateEntryFunc {
+func (s *SourceState) newScriptTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath, sourceLazyContents *lazyContents,
+ interpreter *Interpreter,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
contentsFunc := func() ([]byte, error) {
contents, err := sourceLazyContents.Contents()
@@ -1379,7 +1416,9 @@ func (s *SourceState) newScriptTargetStateEntryFunc(sourceRelPath SourceRelPath,
// newSymlinkTargetStateEntryFunc returns a targetStateEntryFunc that returns a
// symlink with the linkname sourceLazyContents.
-func (s *SourceState) newSymlinkTargetStateEntryFunc(sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents) targetStateEntryFunc {
+func (s *SourceState) newSymlinkTargetStateEntryFunc(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, sourceLazyContents *lazyContents,
+) targetStateEntryFunc {
return func(destSystem System, destAbsPath AbsPath) (TargetStateEntry, error) {
linknameFunc := func() (string, error) {
linknameBytes, err := sourceLazyContents.Contents()
@@ -1403,7 +1442,9 @@ func (s *SourceState) newSymlinkTargetStateEntryFunc(sourceRelPath SourceRelPath
// newSourceStateFile returns a possibly new target RalPath and a new
// SourceStateFile.
-func (s *SourceState) newSourceStateFile(sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath) (RelPath, *SourceStateFile) {
+func (s *SourceState) newSourceStateFile(
+ sourceRelPath SourceRelPath, fileAttr FileAttr, targetRelPath RelPath,
+) (RelPath, *SourceStateFile) {
sourceLazyContents := newLazyContentsFunc(func() ([]byte, error) {
contents, err := s.system.ReadFile(s.sourceDirAbsPath.Join(sourceRelPath.RelPath()))
if err != nil {
@@ -1442,7 +1483,9 @@ func (s *SourceState) newSourceStateFile(sourceRelPath SourceRelPath, fileAttr F
// interpreter to use.
ext := strings.ToLower(strings.TrimPrefix(targetRelPath.Ext(), "."))
interpreter := s.interpreters[ext]
- targetStateEntryFunc = s.newScriptTargetStateEntryFunc(sourceRelPath, fileAttr, targetRelPath, sourceLazyContents, interpreter)
+ targetStateEntryFunc = s.newScriptTargetStateEntryFunc(
+ sourceRelPath, fileAttr, targetRelPath, sourceLazyContents, interpreter,
+ )
case SourceFileTypeSymlink:
targetStateEntryFunc = s.newSymlinkTargetStateEntryFunc(sourceRelPath, fileAttr, sourceLazyContents)
default:
@@ -1458,12 +1501,12 @@ func (s *SourceState) newSourceStateFile(sourceRelPath SourceRelPath, fileAttr F
}
}
-// newSourceStateDirEntry returns a SourceStateEntry constructed from a
-// directory in s.
+// newSourceStateDirEntry returns a SourceStateEntry constructed from a directory in s.
//
-// We return a SourceStateEntry rather than a *SourceStateDir to simplify nil
-// checks later.
-func (s *SourceState) newSourceStateDirEntry(fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions) (SourceStateEntry, error) {
+// We return a SourceStateEntry rather than a *SourceStateDir to simplify nil checks later.
+func (s *SourceState) newSourceStateDirEntry(
+ fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions,
+) (SourceStateEntry, error) {
dirAttr := DirAttr{
TargetName: fileInfo.Name(),
Exact: options.Exact,
@@ -1486,7 +1529,9 @@ func (s *SourceState) newSourceStateDirEntry(fileInfo fs.FileInfo, parentSourceR
//
// We return a SourceStateEntry rather than a *SourceStateFile to simplify nil
// checks later.
-func (s *SourceState) newSourceStateFileEntryFromFile(actualStateFile *ActualStateFile, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions) (SourceStateEntry, error) {
+func (s *SourceState) newSourceStateFileEntryFromFile(
+ actualStateFile *ActualStateFile, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions,
+) (SourceStateEntry, error) {
fileAttr := FileAttr{
TargetName: fileInfo.Name(),
Empty: options.Empty,
@@ -1541,7 +1586,10 @@ func (s *SourceState) newSourceStateFileEntryFromFile(actualStateFile *ActualSta
//
// We return a SourceStateEntry rather than a *SourceStateFile to simplify nil
// checks later.
-func (s *SourceState) newSourceStateFileEntryFromSymlink(actualStateSymlink *ActualStateSymlink, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions) (SourceStateEntry, error) {
+func (s *SourceState) newSourceStateFileEntryFromSymlink(
+ actualStateSymlink *ActualStateSymlink, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath,
+ options *AddOptions,
+) (SourceStateEntry, error) {
linkname, err := actualStateSymlink.Linkname()
if err != nil {
return nil, err
@@ -1583,7 +1631,10 @@ func (s *SourceState) newSourceStateFileEntryFromSymlink(actualStateSymlink *Act
}
// readExternal reads an external and returns its SourceStateEntries.
-func (s *SourceState) readExternal(ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, options *ReadOptions) (map[RelPath][]SourceStateEntry, error) {
+func (s *SourceState) readExternal(
+ ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External,
+ options *ReadOptions,
+) (map[RelPath][]SourceStateEntry, error) {
switch external.Type {
case ExternalTypeArchive:
return s.readExternalArchive(ctx, externalRelPath, parentSourceRelPath, external, options)
@@ -1596,7 +1647,10 @@ func (s *SourceState) readExternal(ctx context.Context, externalRelPath RelPath,
// readExternalArchive reads an external archive and returns its
// SourceStateEntries.
-func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, options *ReadOptions) (map[RelPath][]SourceStateEntry, error) {
+func (s *SourceState) readExternalArchive(
+ ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External,
+ options *ReadOptions,
+) (map[RelPath][]SourceStateEntry, error) {
data, err := s.getExternalData(ctx, externalRelPath, external, options)
if err != nil {
return nil, err
@@ -1684,6 +1738,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
Private: isPrivate(fileInfo),
ReadOnly: isReadOnly(fileInfo),
}
+ sourceRelPath := NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))
targetStateEntry := &TargetStateFile{
lazyContents: lazyContents,
empty: fileAttr.Empty,
@@ -1693,21 +1748,22 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
lazyContents: lazyContents,
Attr: fileAttr,
origin: external.URL,
- sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))),
+ sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, sourceRelPath),
targetStateEntry: targetStateEntry,
}
case fileInfo.Mode()&fs.ModeType == fs.ModeSymlink:
- targetStateEntry := &TargetStateSymlink{
- lazyLinkname: newLazyLinkname(linkname),
- }
fileAttr := FileAttr{
TargetName: fileInfo.Name(),
Type: SourceFileTypeSymlink,
}
+ sourceRelPath := NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))
+ targetStateEntry := &TargetStateSymlink{
+ lazyLinkname: newLazyLinkname(linkname),
+ }
sourceStateEntry = &SourceStateFile{
Attr: fileAttr,
origin: external.URL,
- sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix()))),
+ sourceRelPath: parentSourceRelPath.Join(dirSourceRelPath, sourceRelPath),
targetStateEntry: targetStateEntry,
}
default:
@@ -1723,7 +1779,10 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
}
// readExternalFile reads an external file and returns its SourceStateEntries.
-func (s *SourceState) readExternalFile(ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External, options *ReadOptions) (map[RelPath][]SourceStateEntry, error) {
+func (s *SourceState) readExternalFile(
+ ctx context.Context, externalRelPath RelPath, parentSourceRelPath SourceRelPath, external External,
+ options *ReadOptions,
+) (map[RelPath][]SourceStateEntry, error) {
lazyContents := newLazyContentsFunc(func() ([]byte, error) {
return s.getExternalData(ctx, externalRelPath, external, options)
})
@@ -1747,7 +1806,10 @@ func (s *SourceState) readExternalFile(ctx context.Context, externalRelPath RelP
}
// sourceStateEntry returns a new SourceStateEntry based on actualStateEntry.
-func (s *SourceState) sourceStateEntry(actualStateEntry ActualStateEntry, destAbsPath AbsPath, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath, options *AddOptions) (SourceStateEntry, error) {
+func (s *SourceState) sourceStateEntry(
+ actualStateEntry ActualStateEntry, destAbsPath AbsPath, fileInfo fs.FileInfo, parentSourceRelPath SourceRelPath,
+ options *AddOptions,
+) (SourceStateEntry, error) {
switch actualStateEntry := actualStateEntry.(type) {
case *ActualStateAbsent:
return nil, fmt.Errorf("%s: not found", destAbsPath)
diff --git a/internal/chezmoi/sourcestatetreenode.go b/internal/chezmoi/sourcestatetreenode.go
index a38444c9cce..8e340a4f5e4 100644
--- a/internal/chezmoi/sourcestatetreenode.go
+++ b/internal/chezmoi/sourcestatetreenode.go
@@ -54,7 +54,9 @@ func (n *sourceStateEntryTreeNode) ForEach(targetRelPath RelPath, f func(RelPath
}
// ForEachNode calls f for each node in the tree.
-func (n *sourceStateEntryTreeNode) ForEachNode(targetRelPath RelPath, f func(RelPath, *sourceStateEntryTreeNode) error) error {
+func (n *sourceStateEntryTreeNode) ForEachNode(
+ targetRelPath RelPath, f func(RelPath, *sourceStateEntryTreeNode) error,
+) error {
if err := f(targetRelPath, n); err != nil {
return err
}
@@ -87,7 +89,9 @@ func (n *sourceStateEntryTreeNode) Map() map[RelPath]SourceStateEntry {
// MkdirAll creates SourceStateDirs for all components of targetRelPath if they
// do not already exist and returns the SourceStateDir of relPath.
-func (n *sourceStateEntryTreeNode) MkdirAll(targetRelPath RelPath, origin string, umask fs.FileMode) (*SourceStateDir, error) {
+func (n *sourceStateEntryTreeNode) MkdirAll(
+ targetRelPath RelPath, origin string, umask fs.FileMode,
+) (*SourceStateDir, error) {
if targetRelPath == EmptyRelPath {
return nil, nil
}
diff --git a/internal/chezmoi/system.go b/internal/chezmoi/system.go
index 2ba966caac3..46b8365b4db 100644
--- a/internal/chezmoi/system.go
+++ b/internal/chezmoi/system.go
@@ -131,18 +131,23 @@ func MkdirAll(system System, absPath AbsPath, perm fs.FileMode) error {
}
}
+// A WalkFunc is called for every entry in a directory.
+type WalkFunc func(absPath AbsPath, fileInfo fs.FileInfo, err error) error
+
// Walk walks rootAbsPath in system, alling walkFunc for each file or directory in
// the tree, including rootAbsPath.
//
// Walk does not follow symlinks.
-func Walk(system System, rootAbsPath AbsPath, walkFunc func(absPath AbsPath, fileInfo fs.FileInfo, err error) error) error {
- return vfs.Walk(system.UnderlyingFS(), rootAbsPath.String(), func(absPath string, fileInfo fs.FileInfo, err error) error {
+func Walk(system System, rootAbsPath AbsPath, walkFunc WalkFunc) error {
+ outerWalkFunc := func(absPath string, fileInfo fs.FileInfo, err error) error {
return walkFunc(NewAbsPath(absPath).ToSlash(), fileInfo, err)
- })
+ }
+ return vfs.Walk(system.UnderlyingFS(), rootAbsPath.String(), outerWalkFunc)
}
-// A WalkSourceDirFunc is a function called for every in a source directory.
-type WalkSourceDirFunc func(AbsPath, fs.FileInfo, error) error
+// A WalkSourceDirFunc is a function called for every entry in a source
+// directory.
+type WalkSourceDirFunc func(absPath AbsPath, fileInfo fs.FileInfo, err error) error
// WalkSourceDir walks the source directory rooted at sourceDirAbsPath in
// system, calling walkFunc for each file or directory in the tree, including
diff --git a/internal/chezmoi/targetstateentry.go b/internal/chezmoi/targetstateentry.go
index f416d129f90..54330acebdb 100644
--- a/internal/chezmoi/targetstateentry.go
+++ b/internal/chezmoi/targetstateentry.go
@@ -59,7 +59,9 @@ type scriptState struct {
}
// Apply updates actualStateEntry to match t. It does not recurse.
-func (t *TargetStateDir) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *TargetStateDir) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
if actualStateDir, ok := actualStateEntry.(*ActualStateDir); ok {
if runtime.GOOS == "windows" || actualStateDir.perm == t.perm {
return false, nil
@@ -91,7 +93,9 @@ func (t *TargetStateDir) SkipApply(persistentState PersistentState, targetAbsPat
}
// Apply updates actualStateEntry to match t.
-func (t *TargetStateFile) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *TargetStateFile) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
contents, err := t.Contents()
if err != nil {
return false, err
@@ -167,7 +171,9 @@ func (t *TargetStateFile) SkipApply(persistentState PersistentState, targetAbsPa
}
// Apply updates actualStateEntry to match t.
-func (t *TargetStateRemove) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *TargetStateRemove) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
if _, ok := actualStateEntry.(*ActualStateAbsent); ok {
return false, nil
}
@@ -192,7 +198,9 @@ func (t *TargetStateRemove) SkipApply(persistentState PersistentState, targetAbs
}
// Apply runs t.
-func (t *TargetStateScript) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *TargetStateScript) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
skipApply, err := t.SkipApply(persistentState, actualStateEntry.Path())
if err != nil {
return false, err
@@ -294,7 +302,9 @@ func (t *TargetStateScript) SkipApply(persistentState PersistentState, targetAbs
}
// Apply updates actualStateEntry to match t.
-func (t *TargetStateSymlink) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *TargetStateSymlink) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
linkname, err := t.Linkname()
if err != nil {
return false, err
@@ -353,12 +363,16 @@ func (t *TargetStateSymlink) Evaluate() error {
}
// SkipApply implements TargetState.SkipApply.
-func (t *TargetStateSymlink) SkipApply(persistentState PersistentState, targetAbsPath AbsPath) (bool, error) {
+func (t *TargetStateSymlink) SkipApply(
+ persistentState PersistentState, targetAbsPath AbsPath,
+) (bool, error) {
return false, nil
}
// Apply renames actualStateEntry.
-func (t *targetStateRenameDir) Apply(system System, persistentState PersistentState, actualStateEntry ActualStateEntry) (bool, error) {
+func (t *targetStateRenameDir) Apply(
+ system System, persistentState PersistentState, actualStateEntry ActualStateEntry,
+) (bool, error) {
dir := actualStateEntry.Path().Dir()
return true, system.Rename(dir.Join(t.oldRelPath), dir.Join(t.newRelPath))
}
diff --git a/internal/cmd/addcmd.go b/internal/cmd/addcmd.go
index 6c039149e39..b4875b7d20e 100644
--- a/internal/cmd/addcmd.go
+++ b/internal/cmd/addcmd.go
@@ -40,7 +40,7 @@ func (c *Config) newAddCmd() *cobra.Command {
}
flags := addCmd.Flags()
- flags.BoolVarP(&c.Add.autoTemplate, "autotemplate", "a", c.Add.autoTemplate, "Generate the template when adding files as templates")
+ flags.BoolVarP(&c.Add.autoTemplate, "autotemplate", "a", c.Add.autoTemplate, "Generate the template when adding files as templates") //nolint:lll
flags.BoolVar(&c.Add.create, "create", c.Add.create, "Add files that should exist, irrespective of their contents")
flags.BoolVarP(&c.Add.empty, "empty", "e", c.Add.empty, "Add empty files")
flags.BoolVar(&c.Add.encrypt, "encrypt", c.Add.encrypt, "Encrypt files")
@@ -50,14 +50,16 @@ func (c *Config) newAddCmd() *cobra.Command {
flags.VarP(c.Add.include, "include", "i", "Include entry types")
flags.BoolVarP(&c.Add.recursive, "recursive", "r", c.Add.recursive, "Recurse into subdirectories")
flags.BoolVarP(&c.Add.template, "template", "T", c.Add.template, "Add files as templates")
- flags.BoolVar(&c.Add.TemplateSymlinks, "template-symlinks", c.Add.TemplateSymlinks, "Add symlinks with target in source or home dirs as templates")
+ flags.BoolVar(&c.Add.TemplateSymlinks, "template-symlinks", c.Add.TemplateSymlinks, "Add symlinks with target in source or home dirs as templates") //nolint:lll
return addCmd
}
// defaultPreAddFunc prompts the user for confirmation if the adding the entry
// would remove any of the encrypted, private, or template attributes.
-func (c *Config) defaultPreAddFunc(targetRelPath chezmoi.RelPath, newSourceStateEntry, oldSourceStateEntry chezmoi.SourceStateEntry) error {
+func (c *Config) defaultPreAddFunc(
+ targetRelPath chezmoi.RelPath, newSourceStateEntry, oldSourceStateEntry chezmoi.SourceStateEntry,
+) error {
if c.force {
return nil
}
@@ -82,9 +84,10 @@ func (c *Config) defaultPreAddFunc(targetRelPath chezmoi.RelPath, newSourceState
return nil
}
removedAttributesStr := englishListWithNoun(removedAttributes, "attribute", "")
+ prompt := fmt.Sprintf("adding %s would remove %s, continue", targetRelPath, removedAttributesStr)
for {
- switch choice, err := c.promptChoice(fmt.Sprintf("adding %s would remove %s, continue", targetRelPath, removedAttributesStr), yesNoAllQuit); {
+ switch choice, err := c.promptChoice(prompt, choicesYesNoAllQuit); {
case err != nil:
return err
case choice == "all":
diff --git a/internal/cmd/catcmd.go b/internal/cmd/catcmd.go
index 79582536930..f56079651a3 100644
--- a/internal/cmd/catcmd.go
+++ b/internal/cmd/catcmd.go
@@ -32,7 +32,8 @@ func (c *Config) runCatCmd(cmd *cobra.Command, args []string, sourceState *chezm
builder := strings.Builder{}
for _, targetRelPath := range targetRelPaths {
- targetStateEntry, err := sourceState.MustEntry(targetRelPath).TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath))
+ sourceStateEntry := sourceState.MustEntry(targetRelPath)
+ targetStateEntry, err := sourceStateEntry.TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath))
if err != nil {
return fmt.Errorf("%s: %w", targetRelPath, err)
}
diff --git a/internal/cmd/chattrcmd.go b/internal/cmd/chattrcmd.go
index fcff572f86d..45b6055e546 100644
--- a/internal/cmd/chattrcmd.go
+++ b/internal/cmd/chattrcmd.go
@@ -132,7 +132,8 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch
fileRelPath := fileSourceRelPath.RelPath()
switch sourceStateEntry := sourceStateEntry.(type) {
case *chezmoi.SourceStateDir:
- if newBaseNameRelPath := chezmoi.NewRelPath(m.modifyDirAttr(sourceStateEntry.Attr).SourceName()); newBaseNameRelPath != fileRelPath {
+ relPath := m.modifyDirAttr(sourceStateEntry.Attr).SourceName()
+ if newBaseNameRelPath := chezmoi.NewRelPath(relPath); newBaseNameRelPath != fileRelPath {
oldSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
if err := c.sourceSystem.Rename(oldSourceAbsPath, newSourceAbsPath); err != nil {
@@ -142,7 +143,8 @@ func (c *Config) runChattrCmd(cmd *cobra.Command, args []string, sourceState *ch
case *chezmoi.SourceStateFile:
// FIXME encrypted attribute changes
// FIXME when changing encrypted attribute add new file before removing old one
- if newBaseNameRelPath := chezmoi.NewRelPath(m.modifyFileAttr(sourceStateEntry.Attr).SourceName(encryptedSuffix)); newBaseNameRelPath != fileRelPath {
+ relPath := m.modifyFileAttr(sourceStateEntry.Attr).SourceName(encryptedSuffix)
+ if newBaseNameRelPath := chezmoi.NewRelPath(relPath); newBaseNameRelPath != fileRelPath {
oldSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, fileRelPath)
newSourceAbsPath := c.SourceDirAbsPath.Join(parentRelPath, newBaseNameRelPath)
if err := c.sourceSystem.Rename(oldSourceAbsPath, newSourceAbsPath); err != nil {
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 71a9a49780f..cec21621c2f 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -181,7 +181,7 @@ type Config struct {
type configOption func(*Config) error
type configState struct {
- ConfigTemplateContentsSHA256 chezmoi.HexBytes `json:"configTemplateContentsSHA256" yaml:"configTemplateContentsSHA256"` //nolint:tagliatelle
+ ConfigTemplateContentsSHA256 chezmoi.HexBytes `json:"configTemplateContentsSHA256" yaml:"configTemplateContentsSHA256"` //nolint:lll,tagliatelle
}
var (
@@ -306,7 +306,9 @@ func newConfig(options ...configOption) (*Config, error) {
Edit: editCmdConfig{
MinDuration: 1 * time.Second,
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted),
+ include: chezmoi.NewEntryTypeSet(
+ chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted,
+ ),
},
Git: gitCmdConfig{
Command: "git",
@@ -349,7 +351,9 @@ func newConfig(options ...configOption) (*Config, error) {
},
managed: managedCmdConfig{
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
- include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted),
+ include: chezmoi.NewEntryTypeSet(
+ chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted,
+ ),
},
mergeAll: mergeAllCmdConfig{
recursive: true,
@@ -485,7 +489,10 @@ type applyArgsOptions struct {
// It checks config file freshness, reads the source state, and then applies the
// source state for each target entry in args. If args is empty then the source
// state is applied to all target entries.
-func (c *Config) applyArgs(ctx context.Context, targetSystem chezmoi.System, targetDirAbsPath chezmoi.AbsPath, args []string, options applyArgsOptions) error {
+func (c *Config) applyArgs(
+ ctx context.Context, targetSystem chezmoi.System, targetDirAbsPath chezmoi.AbsPath, args []string,
+ options applyArgsOptions,
+) error {
if options.init {
if err := c.createAndReloadConfigFile(); err != nil {
return err
@@ -510,7 +517,8 @@ func (c *Config) applyArgs(ctx context.Context, targetSystem chezmoi.System, tar
}
previousConfigTemplateContentsSHA256 = []byte(configState.ConfigTemplateContentsSHA256)
}
- configTemplateContentsUnchanged := (currentConfigTemplateContentsSHA256 == nil && previousConfigTemplateContentsSHA256 == nil) ||
+ configTemplatesEmpty := currentConfigTemplateContentsSHA256 == nil && previousConfigTemplateContentsSHA256 == nil
+ configTemplateContentsUnchanged := configTemplatesEmpty ||
bytes.Equal(currentConfigTemplateContentsSHA256, previousConfigTemplateContentsSHA256)
if !configTemplateContentsUnchanged {
if c.force {
@@ -566,7 +574,9 @@ func (c *Config) applyArgs(ctx context.Context, targetSystem chezmoi.System, tar
keptGoingAfterErr := false
for _, targetRelPath := range targetRelPaths {
- switch err := sourceState.Apply(targetSystem, c.destSystem, c.persistentState, targetDirAbsPath, targetRelPath, applyOptions); {
+ switch err := sourceState.Apply(
+ targetSystem, c.destSystem, c.persistentState, targetDirAbsPath, targetRelPath, applyOptions,
+ ); {
case errors.Is(err, chezmoi.Skip):
continue
case err != nil && c.keepGoing:
@@ -719,7 +729,9 @@ func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte
// defaultConfigFile returns the default config file according to the XDG Base
// Directory Specification.
-func (c *Config) defaultConfigFile(fileSystem vfs.Stater, bds *xdg.BaseDirectorySpecification) (chezmoi.AbsPath, error) {
+func (c *Config) defaultConfigFile(
+ fileSystem vfs.Stater, bds *xdg.BaseDirectorySpecification,
+) (chezmoi.AbsPath, error) {
// Search XDG Base Directory Specification config directories first.
for _, configDir := range bds.ConfigDirs {
configDirAbsPath, err := chezmoi.NewAbsPathFromExtPath(configDir, c.homeDirAbsPath)
@@ -744,7 +756,9 @@ func (c *Config) defaultConfigFile(fileSystem vfs.Stater, bds *xdg.BaseDirectory
// defaultPreApplyFunc is the default pre-apply function. If the target entry
// has changed since chezmoi last wrote it then it prompts the user for the
// action to take.
-func (c *Config) defaultPreApplyFunc(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error {
+func (c *Config) defaultPreApplyFunc(
+ targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState,
+) error {
c.logger.Info().
Stringer("targetRelPath", targetRelPath).
Object("targetEntryState", targetEntryState).
@@ -765,6 +779,7 @@ func (c *Config) defaultPreApplyFunc(targetRelPath chezmoi.RelPath, targetEntryS
return nil
}
+ prompt := fmt.Sprintf("%s has changed since chezmoi last wrote it", targetRelPath)
var choices []string
actualContents := actualEntryState.Contents()
targetContents := targetEntryState.Contents()
@@ -773,11 +788,15 @@ func (c *Config) defaultPreApplyFunc(targetRelPath chezmoi.RelPath, targetEntryS
}
choices = append(choices, "overwrite", "all-overwrite", "skip", "quit")
for {
- switch choice, err := c.promptChoice(fmt.Sprintf("%s has changed since chezmoi last wrote it", targetRelPath), choices); {
+ switch choice, err := c.promptChoice(prompt, choices); {
case err != nil:
return err
case choice == "diff":
- if err := c.diffFile(targetRelPath, actualContents, actualEntryState.Mode, targetContents, targetEntryState.Mode); err != nil {
+ if err := c.diffFile(
+ targetRelPath,
+ actualContents, actualEntryState.Mode,
+ targetContents, targetEntryState.Mode,
+ ); err != nil {
return err
}
case choice == "overwrite":
@@ -933,7 +952,9 @@ type destAbsPathInfosOptions struct {
// destAbsPathInfos returns the os/fs.FileInfos for each destination entry in
// args, recursing into subdirectories and following symlinks if configured in
// options.
-func (c *Config) destAbsPathInfos(sourceState *chezmoi.SourceState, args []string, options destAbsPathInfosOptions) (map[chezmoi.AbsPath]fs.FileInfo, error) {
+func (c *Config) destAbsPathInfos(
+ sourceState *chezmoi.SourceState, args []string, options destAbsPathInfosOptions,
+) (map[chezmoi.AbsPath]fs.FileInfo, error) {
destAbsPathInfos := make(map[chezmoi.AbsPath]fs.FileInfo)
for _, arg := range args {
arg = filepath.Clean(arg)
@@ -945,7 +966,7 @@ func (c *Config) destAbsPathInfos(sourceState *chezmoi.SourceState, args []strin
return nil, err
}
if options.recursive {
- if err := chezmoi.Walk(c.destSystem, destAbsPath, func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
+ walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
switch {
case options.ignoreNotExist && errors.Is(err, fs.ErrNotExist):
return nil
@@ -959,7 +980,8 @@ func (c *Config) destAbsPathInfos(sourceState *chezmoi.SourceState, args []strin
}
}
return sourceState.AddDestAbsPathInfos(destAbsPathInfos, c.destSystem, destAbsPath, fileInfo)
- }); err != nil {
+ }
+ if err := chezmoi.Walk(c.destSystem, destAbsPath, walkFunc); err != nil {
return nil, err
}
} else {
@@ -985,7 +1007,11 @@ func (c *Config) destAbsPathInfos(sourceState *chezmoi.SourceState, args []strin
// diffFile outputs the diff between fromData and fromMode and toData and toMode
// at path.
-func (c *Config) diffFile(path chezmoi.RelPath, fromData []byte, fromMode fs.FileMode, toData []byte, toMode fs.FileMode) error {
+func (c *Config) diffFile(
+ path chezmoi.RelPath,
+ fromData []byte, fromMode fs.FileMode,
+ toData []byte, toMode fs.FileMode,
+) error {
builder := strings.Builder{}
unifiedEncoder := diff.NewUnifiedEncoder(&builder, diff.DefaultContextLines)
color := c.Color.Value(c.colorAutoFunc)
@@ -1145,7 +1171,9 @@ func (c *Config) gitAutoPush(status *git.Status) error {
// makeRunEWithSourceState returns a function for
// github.com/spf13/cobra.Command.RunE that includes reading the source state.
-func (c *Config) makeRunEWithSourceState(runE func(*cobra.Command, []string, *chezmoi.SourceState) error) func(*cobra.Command, []string) error {
+func (c *Config) makeRunEWithSourceState(
+ runE func(*cobra.Command, []string, *chezmoi.SourceState) error,
+) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
sourceState, err := c.newSourceState(cmd.Context())
if err != nil {
@@ -1216,7 +1244,9 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
persistentFlags.Var(&c.configFormat, "config-format", "Set config file format")
persistentFlags.Var(&c.cpuProfile, "cpu-profile", "Write a CPU profile to path")
persistentFlags.BoolVar(&c.debug, "debug", c.debug, "Include debug information in output")
- persistentFlags.BoolVarP(&c.dryRun, "dry-run", "n", c.dryRun, "Do not make any modifications to the destination directory")
+ persistentFlags.BoolVarP(
+ &c.dryRun, "dry-run", "n", c.dryRun, "Do not make any modifications to the destination directory",
+ )
persistentFlags.BoolVar(&c.force, "force", c.force, "Make all changes without prompting")
persistentFlags.BoolVar(&c.gops, "gops", c.gops, "Enable gops agent")
persistentFlags.BoolVarP(&c.keepGoing, "keep-going", "k", c.keepGoing, "Keep going as far as possible after an error")
@@ -1290,7 +1320,9 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
}
// newSourceState returns a new SourceState with options.
-func (c *Config) newSourceState(ctx context.Context, options ...chezmoi.SourceStateOption) (*chezmoi.SourceState, error) {
+func (c *Config) newSourceState(
+ ctx context.Context, options ...chezmoi.SourceStateOption,
+) (*chezmoi.SourceState, error) {
sourceStateLogger := c.logger.With().Str(logComponentKey, logComponentValueSourceState).Logger()
sourceDirAbsPath := c.SourceDirAbsPath
@@ -1474,7 +1506,9 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
if err != nil {
return err
}
- c.persistentState, err = chezmoi.NewBoltPersistentState(c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadOnly)
+ c.persistentState, err = chezmoi.NewBoltPersistentState(
+ c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadOnly,
+ )
if err != nil {
return err
}
@@ -1485,7 +1519,9 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
if err != nil {
return err
}
- persistentState, err := chezmoi.NewBoltPersistentState(c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadOnly)
+ persistentState, err := chezmoi.NewBoltPersistentState(
+ c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadOnly,
+ )
if err != nil {
return err
}
@@ -1502,7 +1538,9 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
if err != nil {
return err
}
- c.persistentState, err = chezmoi.NewBoltPersistentState(c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadWrite)
+ c.persistentState, err = chezmoi.NewBoltPersistentState(
+ c.baseSystem, persistentStateFileAbsPath, chezmoi.BoltPersistentStateReadWrite,
+ )
if err != nil {
return err
}
@@ -1601,7 +1639,8 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
workingTreeAbsPath := c.SourceDirAbsPath
FOR:
for {
- if fileInfo, err := c.baseSystem.Stat(workingTreeAbsPath.JoinString(gogit.GitDirName)); err == nil && fileInfo.IsDir() {
+ gitDirAbsPath := workingTreeAbsPath.JoinString(gogit.GitDirName)
+ if fileInfo, err := c.baseSystem.Stat(gitDirAbsPath); err == nil && fileInfo.IsDir() {
c.WorkingTreeAbsPath = workingTreeAbsPath
break FOR
}
@@ -1757,7 +1796,9 @@ type targetRelPathsOptions struct {
// targetRelPaths returns the target relative paths for each target path in
// args. The returned paths are sorted and de-duplicated.
-func (c *Config) targetRelPaths(sourceState *chezmoi.SourceState, args []string, options targetRelPathsOptions) (chezmoi.RelPaths, error) {
+func (c *Config) targetRelPaths(
+ sourceState *chezmoi.SourceState, args []string, options targetRelPathsOptions,
+) (chezmoi.RelPaths, error) {
targetRelPaths := make(chezmoi.RelPaths, 0, len(args))
for _, arg := range args {
argAbsPath, err := chezmoi.NewAbsPathFromExtPath(arg, c.homeDirAbsPath)
@@ -1807,7 +1848,9 @@ func (c *Config) targetRelPaths(sourceState *chezmoi.SourceState, args []string,
// targetRelPathsBySourcePath returns the target relative paths for each arg in
// args.
-func (c *Config) targetRelPathsBySourcePath(sourceState *chezmoi.SourceState, args []string) ([]chezmoi.RelPath, error) {
+func (c *Config) targetRelPathsBySourcePath(
+ sourceState *chezmoi.SourceState, args []string,
+) ([]chezmoi.RelPath, error) {
targetRelPaths := make([]chezmoi.RelPath, 0, len(args))
targetRelPathsBySourceRelPath := make(map[chezmoi.RelPath]chezmoi.RelPath)
_ = sourceState.ForEach(func(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi.SourceStateEntry) error {
diff --git a/internal/cmd/diffcmd.go b/internal/cmd/diffcmd.go
index cc2544dde5c..d9f3e86d095 100644
--- a/internal/cmd/diffcmd.go
+++ b/internal/cmd/diffcmd.go
@@ -65,9 +65,11 @@ func (c *Config) runDiffCmd(cmd *cobra.Command, args []string) (err error) {
err = c.pageOutputString(builder.String(), c.Diff.Pager)
return
}
- diffSystem := chezmoi.NewExternalDiffSystem(dryRunSystem, c.Diff.Command, c.Diff.Args, c.DestDirAbsPath, &chezmoi.ExternalDiffSystemOptions{
- Reverse: c.Diff.reverse,
- })
+ diffSystem := chezmoi.NewExternalDiffSystem(
+ dryRunSystem, c.Diff.Command, c.Diff.Args, c.DestDirAbsPath, &chezmoi.ExternalDiffSystemOptions{
+ Reverse: c.Diff.reverse,
+ },
+ )
defer func() {
err = multierr.Append(err, diffSystem.Close())
}()
diff --git a/internal/cmd/doctorcmd.go b/internal/cmd/doctorcmd.go
index 39733598a5c..c15393128f0 100644
--- a/internal/cmd/doctorcmd.go
+++ b/internal/cmd/doctorcmd.go
@@ -346,7 +346,8 @@ func (c *binaryCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath)
if c.versionRx != nil {
match := c.versionRx.FindSubmatch(versionBytes)
if len(match) != 2 {
- return checkResultWarning, fmt.Sprintf("found %s, cannot parse version from %s", pathAbsPath, bytes.TrimSpace(versionBytes))
+ s := fmt.Sprintf("found %s, cannot parse version from %s", pathAbsPath, bytes.TrimSpace(versionBytes))
+ return checkResultWarning, s
}
versionBytes = match[1]
}
@@ -475,7 +476,7 @@ func (c *suspiciousEntriesCheck) Name() string {
func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) {
// FIXME check that config file templates are in root
var suspiciousEntries []string
- switch err := chezmoi.WalkSourceDir(system, c.dirname, func(absPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
+ walkFunc := func(absPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
if err != nil {
return err
}
@@ -483,7 +484,8 @@ func (c *suspiciousEntriesCheck) Run(system chezmoi.System, homeDirAbsPath chezm
suspiciousEntries = append(suspiciousEntries, absPath.String())
}
return nil
- }); {
+ }
+ switch err := chezmoi.WalkSourceDir(system, c.dirname, walkFunc); {
case errors.Is(err, fs.ErrNotExist):
return checkResultOK, fmt.Sprintf("%s: no such file or directory", c.dirname)
case err != nil:
diff --git a/internal/cmd/executetemplatecmd.go b/internal/cmd/executetemplatecmd.go
index 6de4d82ed13..dc91fa9f1c9 100644
--- a/internal/cmd/executetemplatecmd.go
+++ b/internal/cmd/executetemplatecmd.go
@@ -30,9 +30,9 @@ func (c *Config) newExecuteTemplateCmd() *cobra.Command {
flags := executeTemplateCmd.Flags()
flags.BoolVarP(&c.executeTemplate.init, "init", "i", c.executeTemplate.init, "Simulate chezmoi init")
- flags.StringToStringVar(&c.executeTemplate.promptBool, "promptBool", c.executeTemplate.promptBool, "Simulate promptBool")
+ flags.StringToStringVar(&c.executeTemplate.promptBool, "promptBool", c.executeTemplate.promptBool, "Simulate promptBool") //nolint:lll
flags.StringToIntVar(&c.executeTemplate.promptInt, "promptInt", c.executeTemplate.promptInt, "Simulate promptInt")
- flags.StringToStringVarP(&c.executeTemplate.promptString, "promptString", "p", c.executeTemplate.promptString, "Simulate promptString")
+ flags.StringToStringVarP(&c.executeTemplate.promptString, "promptString", "p", c.executeTemplate.promptString, "Simulate promptString") //nolint:lll
flags.BoolVar(&c.executeTemplate.stdinIsATTY, "stdinisatty", c.executeTemplate.stdinIsATTY, "Simulate stdinIsATTY")
return executeTemplateCmd
diff --git a/internal/cmd/forgetcmd.go b/internal/cmd/forgetcmd.go
index 07a6c5046fe..b78a2d1e320 100644
--- a/internal/cmd/forgetcmd.go
+++ b/internal/cmd/forgetcmd.go
@@ -37,7 +37,7 @@ func (c *Config) runForgetCmd(cmd *cobra.Command, args []string, sourceState *ch
for _, targetRelPath := range targetRelPaths {
sourceAbsPath := c.SourceDirAbsPath.Join(sourceState.MustEntry(targetRelPath).SourceRelPath().RelPath())
if !c.force {
- choice, err := c.promptChoice(fmt.Sprintf("Remove %s", sourceAbsPath), yesNoAllQuit)
+ choice, err := c.promptChoice(fmt.Sprintf("Remove %s", sourceAbsPath), choicesYesNoAllQuit)
if err != nil {
return err
}
diff --git a/internal/cmd/importcmd.go b/internal/cmd/importcmd.go
index 07e7f26d2e2..ba249de4929 100644
--- a/internal/cmd/importcmd.go
+++ b/internal/cmd/importcmd.go
@@ -37,8 +37,8 @@ func (c *Config) newImportCmd() *cobra.Command {
flags.BoolVar(&c._import.exact, "exact", c._import.exact, "Set exact_ attribute on imported directories")
flags.VarP(c._import.exclude, "exclude", "x", "Exclude entry types")
flags.VarP(c._import.include, "include", "i", "Include entry types")
- flags.BoolVarP(&c._import.removeDestination, "remove-destination", "r", c._import.removeDestination, "Remove destination before import")
- flags.IntVar(&c._import.stripComponents, "strip-components", c._import.stripComponents, "Strip leading path components")
+ flags.BoolVarP(&c._import.removeDestination, "remove-destination", "r", c._import.removeDestination, "Remove destination before import") //nolint:lll
+ flags.IntVar(&c._import.stripComponents, "strip-components", c._import.stripComponents, "Strip leading path components") //nolint:lll
return importCmd
}
@@ -66,10 +66,12 @@ func (c *Config) runImportCmd(cmd *cobra.Command, args []string, sourceState *ch
return err
}
}
- archiveReaderSystem, err := chezmoi.NewArchiveReaderSystem(name, data, chezmoi.ArchiveFormatUnknown, chezmoi.ArchiveReaderSystemOptions{
- RootAbsPath: c._import.destination,
- StripComponents: c._import.stripComponents,
- })
+ archiveReaderSystem, err := chezmoi.NewArchiveReaderSystem(
+ name, data, chezmoi.ArchiveFormatUnknown, chezmoi.ArchiveReaderSystemOptions{
+ RootAbsPath: c._import.destination,
+ StripComponents: c._import.stripComponents,
+ },
+ )
if err != nil {
return err
}
@@ -80,9 +82,11 @@ func (c *Config) runImportCmd(cmd *cobra.Command, args []string, sourceState *ch
return err
}
}
- return sourceState.Add(c.sourceSystem, c.persistentState, archiveReaderSystem, archiveReaderSystem.FileInfos(), &chezmoi.AddOptions{
- Exact: c._import.exact,
- Include: c._import.include.Sub(c._import.exclude),
- RemoveDir: removeDir,
- })
+ return sourceState.Add(
+ c.sourceSystem, c.persistentState, archiveReaderSystem, archiveReaderSystem.FileInfos(), &chezmoi.AddOptions{
+ Exact: c._import.exact,
+ Include: c._import.include.Sub(c._import.exclude),
+ RemoveDir: removeDir,
+ },
+ )
}
diff --git a/internal/cmd/mergeallcmd.go b/internal/cmd/mergeallcmd.go
index e604e870dc8..c6faab34d85 100644
--- a/internal/cmd/mergeallcmd.go
+++ b/internal/cmd/mergeallcmd.go
@@ -34,7 +34,9 @@ func (c *Config) newMergeAllCmd() *cobra.Command {
func (c *Config) runMergeAllCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
var targetRelPaths []chezmoi.RelPath
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
- preApplyFunc := func(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error {
+ preApplyFunc := func(
+ targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState,
+ ) error {
if !targetEntryState.Equivalent(actualEntryState) {
targetRelPaths = append(targetRelPaths, targetRelPath)
}
diff --git a/internal/cmd/mergecmd.go b/internal/cmd/mergecmd.go
index e02e7c61604..7fe6340a48b 100644
--- a/internal/cmd/mergecmd.go
+++ b/internal/cmd/mergecmd.go
@@ -90,7 +90,9 @@ func (c *Config) doMerge(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi
// two-way merge if the source state's contents cannot be decrypted or
// are an invalid template
var targetStateEntry chezmoi.TargetStateEntry
- if targetStateEntry, err = sourceStateEntry.TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath)); err != nil {
+ if targetStateEntry, err = sourceStateEntry.TargetStateEntry(
+ c.destSystem, c.DestDirAbsPath.Join(targetRelPath),
+ ); err != nil {
err = fmt.Errorf("%s: %w", targetRelPath, err)
return
}
@@ -181,7 +183,9 @@ func (c *Config) doMerge(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi
if encryptedContents, err = c.encryption.EncryptFile(plaintextAbsPath); err != nil {
return
}
- if err = c.baseSystem.WriteFile(c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()), encryptedContents, 0o644); err != nil {
+ if err = c.baseSystem.WriteFile(
+ c.SourceDirAbsPath.Join(sourceStateEntry.SourceRelPath().RelPath()), encryptedContents, 0o644,
+ ); err != nil {
return
}
}
diff --git a/internal/cmd/purgecmd.go b/internal/cmd/purgecmd.go
index 503543fe1a2..fc1a99b94d3 100644
--- a/internal/cmd/purgecmd.go
+++ b/internal/cmd/purgecmd.go
@@ -82,7 +82,7 @@ func (c *Config) doPurge(purgeOptions *purgeOptions) error {
}
if !c.force {
- switch choice, err := c.promptChoice(fmt.Sprintf("Remove %s", absPath), yesNoAllQuit); {
+ switch choice, err := c.promptChoice(fmt.Sprintf("Remove %s", absPath), choicesYesNoAllQuit); {
case err != nil:
return err
case choice == "yes":
diff --git a/internal/cmd/removecmd.go b/internal/cmd/removecmd.go
index 14f38b4c366..e275ba8c8c6 100644
--- a/internal/cmd/removecmd.go
+++ b/internal/cmd/removecmd.go
@@ -49,7 +49,7 @@ func (c *Config) runRemoveCmd(cmd *cobra.Command, args []string, sourceState *ch
destAbsPath := c.DestDirAbsPath.Join(targetRelPath)
sourceAbsPath := c.SourceDirAbsPath.Join(sourceState.MustEntry(targetRelPath).SourceRelPath().RelPath())
if !c.force {
- choice, err := c.promptChoice(fmt.Sprintf("Remove %s and %s", destAbsPath, sourceAbsPath), yesNoAllQuit)
+ choice, err := c.promptChoice(fmt.Sprintf("Remove %s and %s", destAbsPath, sourceAbsPath), choicesYesNoAllQuit)
if err != nil {
return err
}
diff --git a/internal/cmd/statuscmd.go b/internal/cmd/statuscmd.go
index 8d8a6684431..7e9ffc4451c 100644
--- a/internal/cmd/statuscmd.go
+++ b/internal/cmd/statuscmd.go
@@ -41,7 +41,9 @@ func (c *Config) newStatusCmd() *cobra.Command {
func (c *Config) runStatusCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
builder := strings.Builder{}
dryRunSystem := chezmoi.NewDryRunSystem(c.destSystem)
- preApplyFunc := func(targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState) error {
+ preApplyFunc := func(
+ targetRelPath chezmoi.RelPath, targetEntryState, lastWrittenEntryState, actualEntryState *chezmoi.EntryState,
+ ) error {
c.logger.Info().
Stringer("targetRelPath", targetRelPath).
Object("targetEntryState", targetEntryState).
diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go
index a83baa6ec8d..9faac5844c1 100644
--- a/internal/cmd/unmanagedcmd.go
+++ b/internal/cmd/unmanagedcmd.go
@@ -25,7 +25,7 @@ func (c *Config) newUnmanagedCmd() *cobra.Command {
func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
builder := strings.Builder{}
- if err := chezmoi.WalkSourceDir(c.destSystem, c.DestDirAbsPath, func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
+ walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
if err != nil {
return err
}
@@ -43,7 +43,8 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState
return vfs.SkipDir
}
return nil
- }); err != nil {
+ }
+ if err := chezmoi.WalkSourceDir(c.destSystem, c.DestDirAbsPath, walkFunc); err != nil {
return err
}
return c.writeOutputString(builder.String())
diff --git a/internal/cmd/upgradecmd.go b/internal/cmd/upgradecmd.go
index 49900e15387..3be8db153a4 100644
--- a/internal/cmd/upgradecmd.go
+++ b/internal/cmd/upgradecmd.go
@@ -304,7 +304,10 @@ func (c *Config) getPackageFilename(packageType string, version *semver.Version,
}
}
-func (c *Config) replaceExecutable(ctx context.Context, executableFilenameAbsPath chezmoi.AbsPath, releaseVersion *semver.Version, rr *github.RepositoryRelease) (err error) {
+func (c *Config) replaceExecutable(
+ ctx context.Context, executableFilenameAbsPath chezmoi.AbsPath, releaseVersion *semver.Version,
+ rr *github.RepositoryRelease,
+) (err error) {
goos := runtime.GOOS
if goos == "linux" && runtime.GOARCH == "amd64" {
var libc string
@@ -361,7 +364,9 @@ func (c *Config) snapRefresh() error {
return c.run(chezmoi.EmptyAbsPath, "snap", []string{"refresh", c.upgrade.repo})
}
-func (c *Config) upgradePackage(ctx context.Context, version *semver.Version, rr *github.RepositoryRelease, useSudo bool) error {
+func (c *Config) upgradePackage(
+ ctx context.Context, version *semver.Version, rr *github.RepositoryRelease, useSudo bool,
+) error {
switch runtime.GOOS {
case "linux":
// Determine the package type and architecture.
@@ -440,7 +445,9 @@ func (c *Config) verifyChecksum(ctx context.Context, rr *github.RepositoryReleas
}
checksum := sha256.Sum256(data)
if !bytes.Equal(checksum[:], expectedChecksum) {
- return fmt.Errorf("%s: checksum failed (want %s, got %s)", name, hex.EncodeToString(expectedChecksum), hex.EncodeToString(checksum[:]))
+ return fmt.Errorf(
+ "%s: checksum failed (want %s, got %s)", name, hex.EncodeToString(expectedChecksum), hex.EncodeToString(checksum[:]),
+ )
}
return nil
}
@@ -531,7 +538,8 @@ func getPackageType(system chezmoi.System) (string, error) {
}
}
}
- return packageTypeNone, fmt.Errorf("could not determine package type (ID=%q, ID_LIKE=%q)", osRelease["ID"], osRelease["ID_LIKE"])
+ err = fmt.Errorf("could not determine package type (ID=%q, ID_LIKE=%q)", osRelease["ID"], osRelease["ID_LIKE"])
+ return packageTypeNone, err
}
// getReleaseAssetByName returns the release asset from rr with the given name.
diff --git a/internal/cmd/util.go b/internal/cmd/util.go
index 70243e2324e..5ab54b699d2 100644
--- a/internal/cmd/util.go
+++ b/internal/cmd/util.go
@@ -26,7 +26,7 @@ var (
"URL": {},
}
- yesNoAllQuit = []string{
+ choicesYesNoAllQuit = []string{
"yes",
"no",
"all",
diff --git a/internal/cmds/generate-chezmoi.io-content-docs/main.go b/internal/cmds/generate-chezmoi.io-content-docs/main.go
index 7153706127c..33cd2cde56d 100644
--- a/internal/cmds/generate-chezmoi.io-content-docs/main.go
+++ b/internal/cmds/generate-chezmoi.io-content-docs/main.go
@@ -16,7 +16,7 @@ var (
shortTitle = flag.String("shorttitle", "", "short title")
longTitle = flag.String("longtitle", "", "long title")
- replaceURLRegexp = regexp.MustCompile(`https://github\.com/twpayne/chezmoi/blob/master/docs/[A-Z]+\.md`) // lgtm[go/regex/missing-regexp-anchor]
+ replaceURLRegexp = regexp.MustCompile(`https://github\.com/twpayne/chezmoi/blob/master/docs/[A-Z]+\.md`)
nonStandardPageRenames = map[string]string{
"HOWTO": "how-to",
"QUICKSTART": "quick-start",
|
chore
|
Break long lines
|
2a64e42821988400257e1214e755bfa65a790f5a
|
2024-09-10 04:04:21
|
Tom Payne
|
docs: Make features and portability more prominent on home page
| false
|
diff --git a/assets/chezmoi.io/docs/index.md.tmpl b/assets/chezmoi.io/docs/index.md.tmpl
index b85fb9a573f..e3517e798ee 100644
--- a/assets/chezmoi.io/docs/index.md.tmpl
+++ b/assets/chezmoi.io/docs/index.md.tmpl
@@ -7,14 +7,19 @@ Manage your dotfiles across multiple diverse machines, securely.
The latest version of chezmoi is {{ $version }} ([release notes]({{
$latestRelease.HTMLURL }}), [release history](reference/release-history.md)).
+## What does chezmoi do?
+
chezmoi helps you manage your personal configuration files (dotfiles, like
`~/.gitconfig`) across multiple machines.
chezmoi provides many features beyond symlinking or using a bare git repo
-including: templates (to handle small differences between machines), password
-manager support (to store your secrets securely), importing files from archives
-(great for shell and editor plugins), full file encryption (using gpg or age),
-and running scripts (to handle everything else).
+including:
+
+* templates (to handle small differences between machines)
+* password manager support (to store your secrets securely)
+* importing files from archives (great for shell and editor plugins)
+* full file encryption (using gpg or age)
+* running scripts (to handle everything else)
With chezmoi, pronounced /ʃeɪ mwa/ (shay-moi), you can install chezmoi and your
dotfiles from your GitHub dotfiles repo on a new, empty machine with a single
@@ -33,6 +38,9 @@ Updating your dotfiles on any machine is a single command:
$ chezmoi update
```
+chezmoi runs on all popular operating systems, is distributed as a single
+statically-linked binary with no dependencies, and does not require root access.
+
## How do I start with chezmoi?
[Install chezmoi](install.md) then read the [quick start guide](quick-start.md).
|
docs
|
Make features and portability more prominent on home page
|
6a8d5129505eeacac751625d55348e40ae2b2857
|
2023-05-04 05:13:10
|
Tom Payne
|
chore: Use github.com/alecthomas/assert instead of github.com/stretchr/testify/assert
| false
|
diff --git a/.golangci.yml b/.golangci.yml
index f05cd2b4f90..57616240010 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -164,6 +164,7 @@ issues:
- lll
path: ^internal/cmds/
- linters:
+ - forcetypeassert
- gosec
- lll
path: _test\.go$
diff --git a/go.mod b/go.mod
index b79dc42ce21..0e1dc02c4a8 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
filippo.io/age v1.1.1
github.com/Masterminds/sprig/v3 v3.2.3
github.com/Shopify/ejson v1.3.3
+ github.com/alecthomas/assert/v2 v2.2.2
github.com/aws/aws-sdk-go-v2 v1.18.0
github.com/aws/aws-sdk-go-v2/config v1.18.22
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.19.6
@@ -60,6 +61,7 @@ require (
github.com/ProtonMail/go-crypto v0.0.0-20230426101702-58e86b294756 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
+ github.com/alecthomas/repr v0.2.0 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.21 // indirect
@@ -92,6 +94,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
+ github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
diff --git a/go.sum b/go.sum
index 132c49f90f2..da7beb567f3 100644
--- a/go.sum
+++ b/go.sum
@@ -19,8 +19,12 @@ github.com/Shopify/ejson v1.3.3 h1:dPzgmvFhUPTJIzwdF5DaqbwW1dWaoR8ADKRdSTy6Mss=
github.com/Shopify/ejson v1.3.3/go.mod h1:VZMUtDzvBW/PAXRUF5fzp1ffb1ucT8MztrZXXLYZurw=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
+github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
+github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
+github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
+github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
@@ -150,6 +154,8 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
+github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
+github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
diff --git a/internal/cmds/lint-whitespace/main_test.go b/internal/cmds/lint-whitespace/main_test.go
index 3a6a5e1f075..491eb965a12 100644
--- a/internal/cmds/lint-whitespace/main_test.go
+++ b/internal/cmds/lint-whitespace/main_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestLintData(t *testing.T) {
diff --git a/main_test.go b/main_test.go
index 0f1d1422e8b..56ac0142495 100644
--- a/main_test.go
+++ b/main_test.go
@@ -3,7 +3,7 @@ package main
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/chezmoi/v2/pkg/cmd"
)
diff --git a/pkg/archivetest/tar_test.go b/pkg/archivetest/tar_test.go
index 2bcf5427e21..67f8a4a9c0f 100644
--- a/pkg/archivetest/tar_test.go
+++ b/pkg/archivetest/tar_test.go
@@ -6,7 +6,7 @@ import (
"io/fs"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/archivetest/zip_test.go b/pkg/archivetest/zip_test.go
index 7dea31535a8..5842e531dc3 100644
--- a/pkg/archivetest/zip_test.go
+++ b/pkg/archivetest/zip_test.go
@@ -5,8 +5,8 @@ import (
"io/fs"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/klauspost/compress/zip"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -75,5 +75,5 @@ func TestNewZip(t *testing.T) {
assert.Equal(t, fs.ModeSymlink, zipFile.FileInfo().Mode().Type())
assert.Equal(t, uint64(len("file")), zipFile.UncompressedSize64)
- assert.Len(t, zipReader.File, fileIndex)
+ assert.Equal(t, fileIndex, len(zipReader.File))
}
diff --git a/pkg/chezmoi/abspath_test.go b/pkg/chezmoi/abspath_test.go
index b06a4584975..e12616a02c8 100644
--- a/pkg/chezmoi/abspath_test.go
+++ b/pkg/chezmoi/abspath_test.go
@@ -4,7 +4,7 @@ import (
"os"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/chezmoi/archive_test.go b/pkg/chezmoi/archive_test.go
index e24b67eec44..141e01a28a5 100644
--- a/pkg/chezmoi/archive_test.go
+++ b/pkg/chezmoi/archive_test.go
@@ -5,7 +5,7 @@ import (
"io/fs"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/chezmoi/v2/pkg/archivetest"
diff --git a/pkg/chezmoi/archivereadersystem_test.go b/pkg/chezmoi/archivereadersystem_test.go
index 23ea1164dd4..438146d889c 100644
--- a/pkg/chezmoi/archivereadersystem_test.go
+++ b/pkg/chezmoi/archivereadersystem_test.go
@@ -5,7 +5,7 @@ import (
"io/fs"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/chezmoi/v2/pkg/archivetest"
diff --git a/pkg/chezmoi/attr_test.go b/pkg/chezmoi/attr_test.go
index a85f05c5bdb..34d2c68cd97 100644
--- a/pkg/chezmoi/attr_test.go
+++ b/pkg/chezmoi/attr_test.go
@@ -4,8 +4,8 @@ import (
"io/fs"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/muesli/combinator"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/boltpersistentstate_test.go b/pkg/chezmoi/boltpersistentstate_test.go
index 72e9cc7bf05..ca69232604d 100644
--- a/pkg/chezmoi/boltpersistentstate_test.go
+++ b/pkg/chezmoi/boltpersistentstate_test.go
@@ -4,7 +4,7 @@ import (
"os"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
@@ -73,7 +73,7 @@ func TestBoltPersistentState(t *testing.T) {
string(bucket): {
string(key): string(value),
},
- }, data)
+ }, data.(map[string]map[string]string))
require.NoError(t, b1.Close())
@@ -121,7 +121,7 @@ func TestBoltPersistentStateMock(t *testing.T) {
require.NoError(t, m.Delete(bucket, key))
actualValue, err = m.Get(bucket, key)
require.NoError(t, err)
- assert.Nil(t, actualValue)
+ assert.Zero(t, actualValue)
actualValue, err = b.Get(bucket, key)
require.NoError(t, err)
assert.Equal(t, value1, actualValue)
diff --git a/pkg/chezmoi/chezmoi_test.go b/pkg/chezmoi/chezmoi_test.go
index f0594ae37ba..effe1e590a8 100644
--- a/pkg/chezmoi/chezmoi_test.go
+++ b/pkg/chezmoi/chezmoi_test.go
@@ -5,10 +5,10 @@ import (
"strings"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
- "github.com/stretchr/testify/assert"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/chezmoi/data_test.go b/pkg/chezmoi/data_test.go
index 5cd6d3a54d1..ec976f3710a 100644
--- a/pkg/chezmoi/data_test.go
+++ b/pkg/chezmoi/data_test.go
@@ -4,7 +4,7 @@ import (
"bytes"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
diff --git a/pkg/chezmoi/dumpsystem_test.go b/pkg/chezmoi/dumpsystem_test.go
index 006652ee917..91db24bd015 100644
--- a/pkg/chezmoi/dumpsystem_test.go
+++ b/pkg/chezmoi/dumpsystem_test.go
@@ -5,8 +5,8 @@ import (
"io/fs"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/coreos/go-semver/semver"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
@@ -78,6 +78,6 @@ func TestDumpSystem(t *testing.T) {
},
}
actualData := dumpSystem.Data()
- assert.Equal(t, expectedData, actualData)
+ assert.Equal(t, expectedData, actualData.(map[string]any))
})
}
diff --git a/pkg/chezmoi/encryption_test.go b/pkg/chezmoi/encryption_test.go
index 1462fe5c985..2da2364814b 100644
--- a/pkg/chezmoi/encryption_test.go
+++ b/pkg/chezmoi/encryption_test.go
@@ -7,7 +7,7 @@ import (
"os/exec"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/entrystate_test.go b/pkg/chezmoi/entrystate_test.go
index 5882f78ffb3..cc1b65005cd 100644
--- a/pkg/chezmoi/entrystate_test.go
+++ b/pkg/chezmoi/entrystate_test.go
@@ -6,8 +6,8 @@ import (
"runtime"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/muesli/combinator"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/entrytypeset_test.go b/pkg/chezmoi/entrytypeset_test.go
index 42d82006ee6..d00c1248a59 100644
--- a/pkg/chezmoi/entrytypeset_test.go
+++ b/pkg/chezmoi/entrytypeset_test.go
@@ -3,8 +3,8 @@ package chezmoi
import (
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/format_test.go b/pkg/chezmoi/format_test.go
index 693f29be205..053f6e02ca3 100644
--- a/pkg/chezmoi/format_test.go
+++ b/pkg/chezmoi/format_test.go
@@ -3,16 +3,16 @@ package chezmoi
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
func TestFormats(t *testing.T) {
- assert.Contains(t, FormatsByName, "json")
- assert.Contains(t, FormatsByName, "jsonc")
- assert.Contains(t, FormatsByName, "toml")
- assert.Contains(t, FormatsByName, "yaml")
- assert.NotContains(t, FormatsByName, "yml")
+ assert.NotZero(t, FormatsByName["json"])
+ assert.NotZero(t, FormatsByName["jsonc"])
+ assert.NotZero(t, FormatsByName["toml"])
+ assert.NotZero(t, FormatsByName["yaml"])
+ assert.Zero(t, FormatsByName["yml"])
}
func TestFormatRoundTrip(t *testing.T) {
diff --git a/pkg/chezmoi/hexbytes_test.go b/pkg/chezmoi/hexbytes_test.go
index abe748f4e52..15baeef310f 100644
--- a/pkg/chezmoi/hexbytes_test.go
+++ b/pkg/chezmoi/hexbytes_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/path_windows_test.go b/pkg/chezmoi/path_windows_test.go
index b964076e293..b03105294c7 100644
--- a/pkg/chezmoi/path_windows_test.go
+++ b/pkg/chezmoi/path_windows_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/chezmoi/patternset_test.go b/pkg/chezmoi/patternset_test.go
index 568c83b7ee7..013c8abbf49 100644
--- a/pkg/chezmoi/patternset_test.go
+++ b/pkg/chezmoi/patternset_test.go
@@ -3,7 +3,7 @@ package chezmoi
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
diff --git a/pkg/chezmoi/persistentstate_test.go b/pkg/chezmoi/persistentstate_test.go
index eb9fd636213..8864c4c9d4e 100644
--- a/pkg/chezmoi/persistentstate_test.go
+++ b/pkg/chezmoi/persistentstate_test.go
@@ -4,7 +4,7 @@ import (
"io"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
@@ -24,7 +24,7 @@ func testPersistentState(t *testing.T, constructor func() PersistentState) {
actualValue, err := s1.Get(bucket1, key)
require.NoError(t, err)
- assert.Nil(t, actualValue)
+ assert.Zero(t, actualValue)
require.NoError(t, s1.Set(bucket1, key, value))
@@ -57,7 +57,7 @@ func testPersistentState(t *testing.T, constructor func() PersistentState) {
require.NoError(t, s1.Delete(bucket1, key))
actualValue, err = s1.Get(bucket1, key)
require.NoError(t, err)
- assert.Nil(t, actualValue)
+ assert.Zero(t, actualValue)
require.NoError(t, s1.Set(bucket2, key, value))
actualValue, err = s1.Get(bucket2, key)
@@ -66,5 +66,5 @@ func testPersistentState(t *testing.T, constructor func() PersistentState) {
require.NoError(t, s1.DeleteBucket(bucket2))
actualValue, err = s1.Get(bucket2, key)
require.NoError(t, err)
- assert.Nil(t, actualValue)
+ assert.Zero(t, actualValue)
}
diff --git a/pkg/chezmoi/realsystem_test.go b/pkg/chezmoi/realsystem_test.go
index 11b05696efe..86ed65b9696 100644
--- a/pkg/chezmoi/realsystem_test.go
+++ b/pkg/chezmoi/realsystem_test.go
@@ -5,7 +5,7 @@ import (
"sort"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
diff --git a/pkg/chezmoi/recursivemerge_test.go b/pkg/chezmoi/recursivemerge_test.go
index 0c250517c7a..750dc773825 100644
--- a/pkg/chezmoi/recursivemerge_test.go
+++ b/pkg/chezmoi/recursivemerge_test.go
@@ -3,7 +3,7 @@ package chezmoi
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestRecursiveMerge(t *testing.T) {
diff --git a/pkg/chezmoi/sourcerelpath_test.go b/pkg/chezmoi/sourcerelpath_test.go
index 8d9052f5a8f..4fbc2e48fe2 100644
--- a/pkg/chezmoi/sourcerelpath_test.go
+++ b/pkg/chezmoi/sourcerelpath_test.go
@@ -3,7 +3,7 @@ package chezmoi
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestSourceRelPath(t *testing.T) {
diff --git a/pkg/chezmoi/sourcestate_test.go b/pkg/chezmoi/sourcestate_test.go
index 04a6d28e937..8064e150e60 100644
--- a/pkg/chezmoi/sourcestate_test.go
+++ b/pkg/chezmoi/sourcestate_test.go
@@ -14,8 +14,8 @@ import (
"text/template"
"time"
+ "github.com/alecthomas/assert/v2"
"github.com/coreos/go-semver/semver"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
diff --git a/pkg/chezmoi/sourcestatetreenode_test.go b/pkg/chezmoi/sourcestatetreenode_test.go
index 94bb092b90a..7d0d630b720 100644
--- a/pkg/chezmoi/sourcestatetreenode_test.go
+++ b/pkg/chezmoi/sourcestatetreenode_test.go
@@ -4,7 +4,7 @@ import (
"errors"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestSourceStateEntryTreeNodeEmpty(t *testing.T) {
@@ -20,10 +20,10 @@ func TestSourceStateEntryTreeNodeSingle(t *testing.T) {
n := newSourceStateTreeNode()
sourceStateFile := &SourceStateFile{}
n.Set(NewRelPath("file"), sourceStateFile)
- assert.Equal(t, sourceStateFile, n.Get(NewRelPath("file")))
+ assert.Equal(t, sourceStateFile, n.Get(NewRelPath("file")).(*SourceStateFile))
assert.NoError(t, n.ForEach(EmptyRelPath, func(targetRelPath RelPath, sourceStateEntry SourceStateEntry) error {
assert.Equal(t, NewRelPath("file"), targetRelPath)
- assert.Equal(t, sourceStateFile, sourceStateEntry)
+ assert.Equal(t, sourceStateFile, sourceStateEntry.(*SourceStateFile))
return nil
}))
}
diff --git a/pkg/chezmoi/system_test.go b/pkg/chezmoi/system_test.go
index 074e83991b2..97c4f83a440 100644
--- a/pkg/chezmoi/system_test.go
+++ b/pkg/chezmoi/system_test.go
@@ -7,7 +7,7 @@ import (
"sync"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
diff --git a/pkg/chezmoi/tarwritersystem_test.go b/pkg/chezmoi/tarwritersystem_test.go
index 44ca49bec8f..77d0e6c7b73 100644
--- a/pkg/chezmoi/tarwritersystem_test.go
+++ b/pkg/chezmoi/tarwritersystem_test.go
@@ -8,8 +8,8 @@ import (
"io/fs"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/coreos/go-semver/semver"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
diff --git a/pkg/chezmoi/template_test.go b/pkg/chezmoi/template_test.go
index 2576370db40..922f826b0f2 100644
--- a/pkg/chezmoi/template_test.go
+++ b/pkg/chezmoi/template_test.go
@@ -3,7 +3,7 @@ package chezmoi
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/chezmoi/zipwritersystem_test.go b/pkg/chezmoi/zipwritersystem_test.go
index 26731788d3d..2d517d0a0b4 100644
--- a/pkg/chezmoi/zipwritersystem_test.go
+++ b/pkg/chezmoi/zipwritersystem_test.go
@@ -8,9 +8,9 @@ import (
"testing"
"time"
+ "github.com/alecthomas/assert/v2"
"github.com/coreos/go-semver/semver"
"github.com/klauspost/compress/zip"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
diff --git a/pkg/chezmoibubbles/boolinputmodel_test.go b/pkg/chezmoibubbles/boolinputmodel_test.go
index f615b52bc9c..33051fa2582 100644
--- a/pkg/chezmoibubbles/boolinputmodel_test.go
+++ b/pkg/chezmoibubbles/boolinputmodel_test.go
@@ -3,7 +3,7 @@ package chezmoibubbles
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestBoolInputModel(t *testing.T) {
diff --git a/pkg/chezmoibubbles/choiceinputmodel_test.go b/pkg/chezmoibubbles/choiceinputmodel_test.go
index 13404c0561d..6fcd658073a 100644
--- a/pkg/chezmoibubbles/choiceinputmodel_test.go
+++ b/pkg/chezmoibubbles/choiceinputmodel_test.go
@@ -3,7 +3,7 @@ package chezmoibubbles
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestChoiceInputModel(t *testing.T) {
diff --git a/pkg/chezmoibubbles/intinputmodel_test.go b/pkg/chezmoibubbles/intinputmodel_test.go
index 9cac20de3c2..285573e3a85 100644
--- a/pkg/chezmoibubbles/intinputmodel_test.go
+++ b/pkg/chezmoibubbles/intinputmodel_test.go
@@ -3,7 +3,7 @@ package chezmoibubbles
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestIntInputModel(t *testing.T) {
diff --git a/pkg/chezmoibubbles/passwordinputmodel_test.go b/pkg/chezmoibubbles/passwordinputmodel_test.go
index 61b6daf32c0..88891e51f96 100644
--- a/pkg/chezmoibubbles/passwordinputmodel_test.go
+++ b/pkg/chezmoibubbles/passwordinputmodel_test.go
@@ -3,7 +3,7 @@ package chezmoibubbles
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestPasswordInputModel(t *testing.T) {
diff --git a/pkg/chezmoibubbles/stringinputmodel_test.go b/pkg/chezmoibubbles/stringinputmodel_test.go
index 4da5d079a5b..fce1f15874f 100644
--- a/pkg/chezmoibubbles/stringinputmodel_test.go
+++ b/pkg/chezmoibubbles/stringinputmodel_test.go
@@ -3,7 +3,7 @@ package chezmoibubbles
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestStringInputModel(t *testing.T) {
diff --git a/pkg/chezmoilog/chezmoilog_test.go b/pkg/chezmoilog/chezmoilog_test.go
index aedf524c9ab..6c1dc24dede 100644
--- a/pkg/chezmoilog/chezmoilog_test.go
+++ b/pkg/chezmoilog/chezmoilog_test.go
@@ -5,7 +5,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestOutput(t *testing.T) {
diff --git a/pkg/chezmoitest/chezmoitest_test.go b/pkg/chezmoitest/chezmoitest_test.go
index 3cb009377c5..8f514bd387c 100644
--- a/pkg/chezmoitest/chezmoitest_test.go
+++ b/pkg/chezmoitest/chezmoitest_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestJoinLines(t *testing.T) {
diff --git a/pkg/cmd/catcmd_test.go b/pkg/cmd/catcmd_test.go
index 658cd147534..1daeca4cc2b 100644
--- a/pkg/cmd/catcmd_test.go
+++ b/pkg/cmd/catcmd_test.go
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/cmd/chattrcmd_test.go b/pkg/cmd/chattrcmd_test.go
index 3e460c23ebf..fd9f33d7d63 100644
--- a/pkg/cmd/chattrcmd_test.go
+++ b/pkg/cmd/chattrcmd_test.go
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/cmd/cmd_test.go b/pkg/cmd/cmd_test.go
index f27127e6d40..060799ffa5f 100644
--- a/pkg/cmd/cmd_test.go
+++ b/pkg/cmd/cmd_test.go
@@ -5,7 +5,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/chezmoi/v2/pkg/chezmoi"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go
index 1df0af00fd4..34f28a899df 100644
--- a/pkg/cmd/config_test.go
+++ b/pkg/cmd/config_test.go
@@ -8,7 +8,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
xdg "github.com/twpayne/go-xdg/v6"
diff --git a/pkg/cmd/datacmd_test.go b/pkg/cmd/datacmd_test.go
index 39f4d559951..7538a02ccfa 100644
--- a/pkg/cmd/datacmd_test.go
+++ b/pkg/cmd/datacmd_test.go
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
diff --git a/pkg/cmd/diffcmd_test.go b/pkg/cmd/diffcmd_test.go
index e8bbd30794a..0f317d55431 100644
--- a/pkg/cmd/diffcmd_test.go
+++ b/pkg/cmd/diffcmd_test.go
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
diff --git a/pkg/cmd/initcmd_test.go b/pkg/cmd/initcmd_test.go
index 4b60f51c83e..2167a7da844 100644
--- a/pkg/cmd/initcmd_test.go
+++ b/pkg/cmd/initcmd_test.go
@@ -4,7 +4,7 @@ import (
"runtime"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
diff --git a/pkg/cmd/inittemplatefuncs_test.go b/pkg/cmd/inittemplatefuncs_test.go
index 20825c13da7..89f20fc78d6 100644
--- a/pkg/cmd/inittemplatefuncs_test.go
+++ b/pkg/cmd/inittemplatefuncs_test.go
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/cmd/keepassxctemplatefuncs_test.go b/pkg/cmd/keepassxctemplatefuncs_test.go
index dd7b4222c91..31dc2064ef3 100644
--- a/pkg/cmd/keepassxctemplatefuncs_test.go
+++ b/pkg/cmd/keepassxctemplatefuncs_test.go
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
)
diff --git a/pkg/cmd/lastpasstemplatefuncs_test.go b/pkg/cmd/lastpasstemplatefuncs_test.go
index 830eb884ecf..bdcab27aeaa 100644
--- a/pkg/cmd/lastpasstemplatefuncs_test.go
+++ b/pkg/cmd/lastpasstemplatefuncs_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
diff --git a/pkg/cmd/managedcmd_test.go b/pkg/cmd/managedcmd_test.go
index 6290b30161f..e1b8d576442 100644
--- a/pkg/cmd/managedcmd_test.go
+++ b/pkg/cmd/managedcmd_test.go
@@ -4,7 +4,7 @@ import (
"bytes"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
diff --git a/pkg/cmd/onepasswordtemplatefuncs_test.go b/pkg/cmd/onepasswordtemplatefuncs_test.go
index ce53ee2e5d9..3071c666508 100644
--- a/pkg/cmd/onepasswordtemplatefuncs_test.go
+++ b/pkg/cmd/onepasswordtemplatefuncs_test.go
@@ -3,7 +3,7 @@ package cmd
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestOnepasswordAccountMap(t *testing.T) {
diff --git a/pkg/cmd/readhttpresponse_test.go b/pkg/cmd/readhttpresponse_test.go
index 300baca137a..311724b487f 100644
--- a/pkg/cmd/readhttpresponse_test.go
+++ b/pkg/cmd/readhttpresponse_test.go
@@ -4,7 +4,7 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestMakeNightriderFrames(t *testing.T) {
diff --git a/pkg/cmd/shellquote_test.go b/pkg/cmd/shellquote_test.go
index b26306f8ff9..a975080a704 100644
--- a/pkg/cmd/shellquote_test.go
+++ b/pkg/cmd/shellquote_test.go
@@ -3,7 +3,7 @@ package cmd
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestShellQuote(t *testing.T) {
diff --git a/pkg/cmd/statuscmd_test.go b/pkg/cmd/statuscmd_test.go
index cc708a0393e..aaee97a4be2 100644
--- a/pkg/cmd/statuscmd_test.go
+++ b/pkg/cmd/statuscmd_test.go
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
vfs "github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
@@ -65,7 +65,7 @@ func TestStatusCmd(t *testing.T) {
stdout.Reset()
require.NoError(t, newTestConfig(t, fileSystem, withStdout(&stdout)).execute(append([]string{"status"}, tc.args...)))
- assert.Empty(t, stdout.String())
+ assert.Zero(t, stdout.String())
})
})
}
diff --git a/pkg/cmd/templatefuncs_test.go b/pkg/cmd/templatefuncs_test.go
index 3a14bcc6c66..78610f4aafd 100644
--- a/pkg/cmd/templatefuncs_test.go
+++ b/pkg/cmd/templatefuncs_test.go
@@ -5,9 +5,10 @@ import (
"strconv"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
+ "github.com/twpayne/chezmoi/v2/pkg/chezmoiassert"
"github.com/twpayne/chezmoi/v2/pkg/chezmoitest"
)
@@ -151,7 +152,7 @@ func TestDeleteValueAtPathTemplateFunc(t *testing.T) {
actual := c.deleteValueAtPathTemplateFunc(tc.path, tc.dict)
assert.Equal(t, tc.expected, actual)
} else {
- assert.PanicsWithError(t, tc.expectedErr, func() {
+ chezmoiassert.PanicsWithErrorString(t, tc.expectedErr, func() {
c.deleteValueAtPathTemplateFunc(tc.path, tc.dict)
})
}
@@ -351,7 +352,7 @@ func TestSetValueAtPathTemplateFunc(t *testing.T) {
actual := c.setValueAtPathTemplateFunc(tc.path, tc.value, tc.dict)
assert.Equal(t, tc.expected, actual)
} else {
- assert.PanicsWithError(t, tc.expectedErr, func() {
+ chezmoiassert.PanicsWithErrorString(t, tc.expectedErr, func() {
c.setValueAtPathTemplateFunc(tc.path, tc.value, tc.dict)
})
}
diff --git a/pkg/cmd/upgradecmd_test.go b/pkg/cmd/upgradecmd_test.go
index 3046a90cb3d..754c118db58 100644
--- a/pkg/cmd/upgradecmd_test.go
+++ b/pkg/cmd/upgradecmd_test.go
@@ -5,8 +5,8 @@ package cmd
import (
"testing"
+ "github.com/alecthomas/assert/v2"
"github.com/coreos/go-semver/semver"
- "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/twpayne/go-vfs/v4"
)
diff --git a/pkg/cmd/util_test.go b/pkg/cmd/util_test.go
index 669b8e7ca75..7e9841edbf1 100644
--- a/pkg/cmd/util_test.go
+++ b/pkg/cmd/util_test.go
@@ -3,7 +3,7 @@ package cmd
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestCamelCaseToUpperSnakeCase(t *testing.T) {
diff --git a/pkg/cmd/verifycmd_test.go b/pkg/cmd/verifycmd_test.go
index dccb9c74d06..7c236bf4a2f 100644
--- a/pkg/cmd/verifycmd_test.go
+++ b/pkg/cmd/verifycmd_test.go
@@ -4,7 +4,7 @@ import (
"io/fs"
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"
diff --git a/pkg/git/status_test.go b/pkg/git/status_test.go
index 768b6f5149a..58b8cebd8d4 100644
--- a/pkg/git/status_test.go
+++ b/pkg/git/status_test.go
@@ -3,7 +3,7 @@ package git
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
diff --git a/pkg/shell/shell_test.go b/pkg/shell/shell_test.go
index 73241b3ccfe..a769b005769 100644
--- a/pkg/shell/shell_test.go
+++ b/pkg/shell/shell_test.go
@@ -3,11 +3,11 @@ package shell
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/alecthomas/assert/v2"
)
func TestCurrentUserShell(t *testing.T) {
shell, ok := CurrentUserShell()
assert.True(t, ok)
- assert.NotEmpty(t, shell)
+ assert.NotEqual(t, "", shell)
}
|
chore
|
Use github.com/alecthomas/assert instead of github.com/stretchr/testify/assert
|
6010c30b2ed0fd35f33a09f4166e07421b57199d
|
2021-10-02 19:32:37
|
Tom Payne
|
chore: Add gzipped JSON format for internal use
| false
|
diff --git a/internal/chezmoi/format.go b/internal/chezmoi/format.go
index 5040f8252d9..b4b19eff137 100644
--- a/internal/chezmoi/format.go
+++ b/internal/chezmoi/format.go
@@ -1,7 +1,11 @@
package chezmoi
import (
+ "bytes"
+ "compress/gzip"
"encoding/json"
+ "io"
+ "strings"
"github.com/pelletier/go-toml"
"gopkg.in/yaml.v3"
@@ -21,6 +25,9 @@ type Format interface {
Unmarshal(data []byte, value interface{}) error
}
+// A formatGzippedJSON implements the gzipped JSON serialization format.
+type formatGzippedJSON struct{}
+
// A formatJSON implements the JSON serialization format.
type formatJSON struct{}
@@ -37,6 +44,43 @@ var Formats = map[string]Format{
"yaml": FormatYAML,
}
+// Marshal implements Format.Marshal.
+func (formatGzippedJSON) Marshal(value interface{}) ([]byte, error) {
+ jsonData, err := json.Marshal(value)
+ if err != nil {
+ return nil, err
+ }
+ sb := &strings.Builder{}
+ sb.Grow(len(jsonData))
+ w := gzip.NewWriter(sb)
+ if _, err := w.Write(jsonData); err != nil {
+ return nil, err
+ }
+ if err := w.Close(); err != nil {
+ return nil, err
+ }
+ return []byte(sb.String()), nil
+}
+
+// Name implements Format.Name.
+func (formatGzippedJSON) Name() string {
+ return "json.gz"
+}
+
+// Unmask implements Format.Unmarshal.
+func (formatGzippedJSON) Unmarshal(data []byte, value interface{}) error {
+ r, err := gzip.NewReader(bytes.NewReader(data))
+ if err != nil {
+ return err
+ }
+ defer r.Close()
+ jsonData, err := io.ReadAll(r)
+ if err != nil {
+ return err
+ }
+ return json.Unmarshal(jsonData, value)
+}
+
// Marshal implements Format.Marshal.
func (formatJSON) Marshal(value interface{}) ([]byte, error) {
data, err := json.MarshalIndent(value, "", " ")
diff --git a/internal/chezmoi/format_test.go b/internal/chezmoi/format_test.go
index 3cd8331b2ac..178ffa87022 100644
--- a/internal/chezmoi/format_test.go
+++ b/internal/chezmoi/format_test.go
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestFormats(t *testing.T) {
@@ -11,3 +12,39 @@ func TestFormats(t *testing.T) {
assert.Contains(t, Formats, "toml")
assert.Contains(t, Formats, "yaml")
}
+
+func TestFormatRoundTrip(t *testing.T) {
+ type value struct {
+ Bool bool
+ Bytes []byte
+ Int int
+ Float float64
+ Object map[string]interface{}
+ String string
+ }
+
+ for _, format := range []Format{
+ formatGzippedJSON{},
+ formatJSON{},
+ formatTOML{},
+ formatYAML{},
+ } {
+ t.Run(format.Name(), func(t *testing.T) {
+ v := value{
+ Bool: true,
+ Bytes: []byte("bytes"),
+ Int: 1,
+ Float: 2.3,
+ Object: map[string]interface{}{
+ "key": "value",
+ },
+ String: "string",
+ }
+ data, err := format.Marshal(v)
+ require.NoError(t, err)
+ var actualValue value
+ require.NoError(t, format.Unmarshal(data, &actualValue))
+ assert.Equal(t, v, actualValue)
+ })
+ }
+}
|
chore
|
Add gzipped JSON format for internal use
|
9cae870baa4095cf4643fa2993f2f1a8de65fe59
|
2021-11-01 02:00:37
|
Tom Payne
|
chore: Improve tracking of source state origins
| false
|
diff --git a/internal/chezmoi/chezmoi.go b/internal/chezmoi/chezmoi.go
index 7ed42ce5360..908ee5d1e5a 100644
--- a/internal/chezmoi/chezmoi.go
+++ b/internal/chezmoi/chezmoi.go
@@ -89,16 +89,12 @@ var modeTypeNames = map[fs.FileMode]string{
}
type duplicateTargetError struct {
- targetRelPath RelPath
- sourceRelPaths []SourceRelPath
+ targetRelPath RelPath
+ origins []string
}
func (e *duplicateTargetError) Error() string {
- sourceRelPathStrs := make([]string, 0, len(e.sourceRelPaths))
- for _, sourceRelPath := range e.sourceRelPaths {
- sourceRelPathStrs = append(sourceRelPathStrs, sourceRelPath.String())
- }
- return fmt.Sprintf("%s: duplicate source state entries (%s)", e.targetRelPath, strings.Join(sourceRelPathStrs, ", "))
+ return fmt.Sprintf("%s: duplicate source state entries (%s)", e.targetRelPath, strings.Join(e.origins, ", "))
}
type notInAbsDirError struct {
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index e462e618656..363dd0e3768 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -873,16 +873,15 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
if len(sourceStateEntries) == 1 {
continue
}
- sourceRelPaths := make([]SourceRelPath, 0, len(sourceStateEntries))
+
+ origins := make([]string, 0, len(sourceStateEntries))
for _, sourceStateEntry := range sourceStateEntries {
- sourceRelPaths = append(sourceRelPaths, sourceStateEntry.SourceRelPath())
+ origins = append(origins, sourceStateEntry.Origin())
}
- sort.Slice(sourceRelPaths, func(i, j int) bool {
- return sourceRelPaths[i].Less(sourceRelPaths[j])
- })
+ sort.Strings(origins)
err = multierr.Append(err, &duplicateTargetError{
- targetRelPath: targetRelPath,
- sourceRelPaths: sourceRelPaths,
+ targetRelPath: targetRelPath,
+ origins: origins,
})
}
if err != nil {
@@ -1205,6 +1204,7 @@ func (s *SourceState) newSourceStateDir(sourceRelPath SourceRelPath, dirAttr Dir
perm: dirAttr.perm() &^ s.umask,
}
return &SourceStateDir{
+ origin: sourceRelPath.String(),
sourceRelPath: sourceRelPath,
Attr: dirAttr,
targetStateEntry: targetStateDir,
@@ -1456,6 +1456,7 @@ func (s *SourceState) newSourceStateFile(sourceRelPath SourceRelPath, fileAttr F
return targetRelPath, &SourceStateFile{
lazyContents: sourceLazyContents,
+ origin: sourceRelPath.String(),
sourceRelPath: sourceRelPath,
Attr: fileAttr,
targetStateEntryFunc: targetStateEntryFunc,
@@ -1477,6 +1478,7 @@ func (s *SourceState) newSourceStateDirEntry(info fs.FileInfo, parentSourceRelPa
sourceRelPath := parentSourceRelPath.Join(NewSourceRelDirPath(dirAttr.SourceName()))
return &SourceStateDir{
Attr: dirAttr,
+ origin: sourceRelPath.String(),
sourceRelPath: sourceRelPath,
targetStateEntry: &TargetStateDir{
perm: 0o777 &^ s.umask,
@@ -1528,6 +1530,7 @@ func (s *SourceState) newSourceStateFileEntryFromFile(actualStateFile *ActualSta
sourceRelPath := parentSourceRelPath.Join(NewSourceRelPath(fileAttr.SourceName(s.encryption.EncryptedSuffix())))
return &SourceStateFile{
Attr: fileAttr,
+ origin: sourceRelPath.String(),
sourceRelPath: sourceRelPath,
lazyContents: lazyContents,
targetStateEntry: &TargetStateFile{
@@ -1612,7 +1615,6 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
if external.Encrypted {
urlPath = strings.TrimSuffix(urlPath, s.encryption.EncryptedSuffix())
}
- sourceRelPath := NewSourceRelPath(external.URL)
sourceStateEntries := map[RelPath][]SourceStateEntry{
externalRelPath: {
&SourceStateDir{
@@ -1620,7 +1622,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
TargetName: externalRelPath.Base(),
Exact: external.Exact,
},
- sourceRelPath: sourceRelPath,
+ origin: external.URL,
targetStateEntry: &TargetStateDir{
perm: 0o777 &^ s.umask,
},
@@ -1663,7 +1665,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
Private: isPrivate(info),
ReadOnly: isReadOnly(info),
},
- sourceRelPath: sourceRelPath,
+ origin: external.URL,
targetStateEntry: targetStateEntry,
}
case info.Mode()&fs.ModeType == 0:
@@ -1688,7 +1690,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
sourceStateEntry = &SourceStateFile{
lazyContents: lazyContents,
Attr: fileAttr,
- sourceRelPath: sourceRelPath,
+ origin: external.URL,
targetStateEntry: targetStateEntry,
}
case info.Mode()&fs.ModeType == fs.ModeSymlink:
@@ -1700,7 +1702,7 @@ func (s *SourceState) readExternalArchive(ctx context.Context, externalRelPath R
TargetName: info.Name(),
Type: SourceFileTypeSymlink,
},
- sourceRelPath: sourceRelPath,
+ origin: external.URL,
targetStateEntry: targetStateEntry,
}
default:
@@ -1730,7 +1732,7 @@ func (s *SourceState) readExternalFile(ctx context.Context, externalRelPath RelP
perm: fileAttr.perm() &^ s.umask,
}
sourceStateEntry := &SourceStateFile{
- sourceRelPath: NewSourceRelPath(external.URL),
+ origin: external.URL,
targetStateEntry: targetStateEntry,
}
return map[RelPath][]SourceStateEntry{
diff --git a/internal/chezmoi/sourcestate_test.go b/internal/chezmoi/sourcestate_test.go
index 445f09d9470..be1d2216fdf 100644
--- a/internal/chezmoi/sourcestate_test.go
+++ b/internal/chezmoi/sourcestate_test.go
@@ -792,6 +792,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("dir"): &SourceStateDir{
+ origin: "dir",
sourceRelPath: NewSourceRelDirPath("dir"),
Attr: DirAttr{
TargetName: "dir",
@@ -813,6 +814,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath(".file"): &SourceStateFile{
+ origin: "dot_file",
sourceRelPath: NewSourceRelPath("dot_file"),
Attr: FileAttr{
TargetName: ".file",
@@ -872,6 +874,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath(".file"): &SourceStateFile{
+ origin: "executable_dot_file",
sourceRelPath: NewSourceRelPath("executable_dot_file"),
Attr: FileAttr{
TargetName: ".file",
@@ -898,6 +901,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("script"): &SourceStateFile{
+ origin: "run_script",
sourceRelPath: NewSourceRelPath("run_script"),
Attr: FileAttr{
TargetName: "script",
@@ -922,6 +926,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("script"): &SourceStateFile{
+ origin: "run_script",
sourceRelPath: NewSourceRelPath("run_script"),
Attr: FileAttr{
TargetName: "script",
@@ -946,6 +951,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath(".symlink"): &SourceStateFile{
+ origin: "symlink_dot_symlink",
sourceRelPath: NewSourceRelPath("symlink_dot_symlink"),
Attr: FileAttr{
TargetName: ".symlink",
@@ -971,6 +977,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("dir"): &SourceStateDir{
+ origin: "dir",
sourceRelPath: NewSourceRelDirPath("dir"),
Attr: DirAttr{
TargetName: "dir",
@@ -980,6 +987,7 @@ func TestSourceStateRead(t *testing.T) {
},
},
NewRelPath("dir/file"): &SourceStateFile{
+ origin: "dir/file",
sourceRelPath: NewSourceRelPath("dir/file"),
Attr: FileAttr{
TargetName: "file",
@@ -1043,6 +1051,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("dir"): &SourceStateDir{
+ origin: "exact_dir",
sourceRelPath: NewSourceRelDirPath("exact_dir"),
Attr: DirAttr{
TargetName: "dir",
@@ -1053,6 +1062,7 @@ func TestSourceStateRead(t *testing.T) {
},
},
NewRelPath("dir/file1"): &SourceStateFile{
+ origin: "exact_dir/file1",
sourceRelPath: NewSourceRelPath("exact_dir/file1"),
Attr: FileAttr{
TargetName: "file1",
@@ -1163,6 +1173,7 @@ func TestSourceStateRead(t *testing.T) {
expectedSourceState: NewSourceState(
withEntries(map[RelPath]SourceStateEntry{
NewRelPath("dir"): &SourceStateDir{
+ origin: "dir",
sourceRelPath: NewSourceRelDirPath("dir"),
Attr: DirAttr{
TargetName: "dir",
diff --git a/internal/chezmoi/sourcestateentry.go b/internal/chezmoi/sourcestateentry.go
index 957072a81d5..b4e4fe1181b 100644
--- a/internal/chezmoi/sourcestateentry.go
+++ b/internal/chezmoi/sourcestateentry.go
@@ -13,6 +13,7 @@ type SourceStateEntry interface {
zerolog.LogObjectMarshaler
Evaluate() error
Order() ScriptOrder
+ Origin() string
SourceRelPath() SourceRelPath
TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
}
@@ -20,6 +21,7 @@ type SourceStateEntry interface {
// A SourceStateDir represents the state of a directory in the source state.
type SourceStateDir struct {
Attr DirAttr
+ origin string
sourceRelPath SourceRelPath
targetStateEntry TargetStateEntry
}
@@ -28,6 +30,7 @@ type SourceStateDir struct {
type SourceStateFile struct {
*lazyContents
Attr FileAttr
+ origin string
sourceRelPath SourceRelPath
targetStateEntryFunc targetStateEntryFunc
targetStateEntry TargetStateEntry
@@ -63,6 +66,11 @@ func (s *SourceStateDir) Order() ScriptOrder {
return ScriptOrderDuring
}
+// Origin returns s's origin.
+func (s *SourceStateDir) Origin() string {
+ return s.origin
+}
+
// SourceRelPath returns s's source relative path.
func (s *SourceStateDir) SourceRelPath() SourceRelPath {
return s.sourceRelPath
@@ -102,6 +110,11 @@ func (s *SourceStateFile) Order() ScriptOrder {
return s.Attr.Order
}
+// Origin returns s's origin.
+func (s *SourceStateFile) Origin() string {
+ return s.origin
+}
+
// SourceRelPath returns s's source relative path.
func (s *SourceStateFile) SourceRelPath() SourceRelPath {
return s.sourceRelPath
@@ -131,6 +144,11 @@ func (s *SourceStateRemove) Order() ScriptOrder {
return ScriptOrderDuring
}
+// Origin returns s's origin.
+func (s *SourceStateRemove) Origin() string {
+ return ""
+}
+
// SourceRelPath returns s's source relative path.
func (s *SourceStateRemove) SourceRelPath() SourceRelPath {
return SourceRelPath{}
@@ -158,6 +176,11 @@ func (s *SourceStateRenameDir) Order() ScriptOrder {
return ScriptOrderBefore
}
+// Origin returns s's origin.
+func (s *SourceStateRenameDir) Origin() string {
+ return ""
+}
+
// SourceRelPath returns s's source relative path.
func (s *SourceStateRenameDir) SourceRelPath() SourceRelPath {
return s.newSourceRelPath
|
chore
|
Improve tracking of source state origins
|
2ba64dbd758ea3cc4e7c2a578c919457cf03b1b8
|
2024-10-23 23:57:44
|
Tom Payne
|
chore: Compact if statement
| false
|
diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go
index 0d426a3c585..16b80847cae 100644
--- a/internal/cmd/cmd.go
+++ b/internal/cmd/cmd.go
@@ -207,12 +207,11 @@ func extractHelp(command string, data []byte, longHelpTermRenderer, exampleTermR
}
case stateInOptions:
if !stateChange(line, &state) {
- matches := helpFlagsRx.FindStringSubmatch(line)
- if matches != nil {
- if matches[1] != "" {
- shortFlags.Add(matches[1])
+ if m := helpFlagsRx.FindStringSubmatch(line); m != nil {
+ if m[1] != "" {
+ shortFlags.Add(m[1])
}
- longFlags.Add(matches[2])
+ longFlags.Add(m[2])
}
}
default:
|
chore
|
Compact if statement
|
bd1cae40350bdca296dab383a9064553c8cec6a3
|
2024-11-30 06:00:12
|
Tom Payne
|
chore: Abandon hope of github.com/Netflix/go-expect ever being maintained
| false
|
diff --git a/go.mod b/go.mod
index b4c30435154..ea25874c22f 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,6 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.3.0
github.com/Masterminds/sprig/v3 v3.3.0
- github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
github.com/Shopify/ejson v1.5.3
github.com/alecthomas/assert/v2 v2.11.0
github.com/aws/aws-sdk-go-v2 v1.32.5
@@ -37,6 +36,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
+ github.com/twpayne/go-expect v0.0.2-0.20241130000624-916db2914efd
github.com/twpayne/go-pinentry/v4 v4.0.0
github.com/twpayne/go-shell v0.4.0
github.com/twpayne/go-vfs/v5 v5.0.4
@@ -168,6 +168,3 @@ exclude (
github.com/microcosm-cc/bluemonday v1.0.26 // https://github.com/microcosm-cc/bluemonday/pull/195
github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b // Requires Go 1.23.
)
-
-// github.com/Netflix/go-expect is unmaintained. Use a temporary fork.
-replace github.com/Netflix/go-expect => github.com/twpayne/go-expect v0.0.1
diff --git a/go.sum b/go.sum
index 98f3588858f..c1cd9dd9eec 100644
--- a/go.sum
+++ b/go.sum
@@ -446,8 +446,8 @@ github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 h1:ZF+QBjOI+tILZ
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk=
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
-github.com/twpayne/go-expect v0.0.1 h1:cRJ552FIdQzs4z98Q2OLQsGLSbkB7Xpm/IU6cyQ6mUM=
-github.com/twpayne/go-expect v0.0.1/go.mod h1:+ffr+YtUt8ifebyvRQ3NhVTiLch/HnfxsAQqO5LeXss=
+github.com/twpayne/go-expect v0.0.2-0.20241130000624-916db2914efd h1:/ekqcdG89euFEeFfuFYGF2An2AwsaJHnYxVwW8hqvcw=
+github.com/twpayne/go-expect v0.0.2-0.20241130000624-916db2914efd/go.mod h1:Z1PlEHxKw23bid0pq2RhO4NMScxckEhBXZLebwJpjrk=
github.com/twpayne/go-pinentry/v4 v4.0.0 h1:8WcNa+UDVRzz7y9OEEU/nRMX+UGFPCAvl5XsqWRxTY4=
github.com/twpayne/go-pinentry/v4 v4.0.0/go.mod h1:aXvy+awVXqdH+GS0ddQ7AKHZ3tXM6fJ2NK+e16p47PI=
github.com/twpayne/go-shell v0.4.0 h1:RAAMbjEj7mcwDdwC7SiFHGUKR+WDAURU6mnyd3r2p2E=
diff --git a/internal/cmd/keepassxctemplatefuncs.go b/internal/cmd/keepassxctemplatefuncs.go
index 01ca7660bdc..7d6f44f568f 100644
--- a/internal/cmd/keepassxctemplatefuncs.go
+++ b/internal/cmd/keepassxctemplatefuncs.go
@@ -13,8 +13,8 @@ import (
"strings"
"time"
- "github.com/Netflix/go-expect"
"github.com/coreos/go-semver/semver"
+ "github.com/twpayne/go-expect"
"github.com/twpayne/chezmoi/v2/internal/chezmoi"
"github.com/twpayne/chezmoi/v2/internal/chezmoilog"
|
chore
|
Abandon hope of github.com/Netflix/go-expect ever being maintained
|
88d4f3b2cd5181129e3890afe52f48fa8feb0dec
|
2021-10-28 03:29:25
|
Tom Payne
|
chore: Copy Code of Conduct from Go
| false
|
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000000..2b4a5fccdaf
--- /dev/null
+++ b/.github/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+# Code of Conduct
+
+Please read the [Go Community Code of Conduct](https://golang.org/conduct).
|
chore
|
Copy Code of Conduct from Go
|
439edb87c04527c610c46dd1af40eff4531d147d
|
2022-09-25 19:54:34
|
Tom Payne
|
chore: Tidy up txtar archives
| false
|
diff --git a/pkg/cmd/testdata/scripts/add.txtar b/pkg/cmd/testdata/scripts/add.txtar
index 01c49f72818..4469d76adf7 100644
--- a/pkg/cmd/testdata/scripts/add.txtar
+++ b/pkg/cmd/testdata/scripts/add.txtar
@@ -78,11 +78,11 @@ cmp $CHEZMOISOURCEDIR/dot_file golden/edited_dot_file
# edited
-- home2/user/.dir/non_empty_subdir/file --
# contents of .dir/non_empty_subdir/file
--- home3/user/.local/share/chezmoi/.chezmoiignore --
-**/ignore
-- home3/user/.dir/file --
# contents of .dir/file
-- home3/user/.dir/ignore --
# contents of .dir/ignore
+-- home3/user/.local/share/chezmoi/.chezmoiignore --
+**/ignore
-- home4/user/.file --
# contents of .file
diff --git a/pkg/cmd/testdata/scripts/addautotemplate.txtar b/pkg/cmd/testdata/scripts/addautotemplate.txtar
index d31b8bb59ab..e7b477c42e8 100644
--- a/pkg/cmd/testdata/scripts/addautotemplate.txtar
+++ b/pkg/cmd/testdata/scripts/addautotemplate.txtar
@@ -19,16 +19,16 @@ cmp $CHEZMOISOURCEDIR/dot_vimrc.tmpl golden/dot_vimrc.tmpl
# contents of .file
-- golden/dot_template.tmpl --
key = {{ .variable }}
--- golden/symlink_dot_symlink.tmpl --
-.target-{{ .variable }}
-- golden/dot_vimrc.tmpl --
set foldmarker={{ "{{" }},{{ "}}" }}
+-- golden/symlink_dot_symlink.tmpl --
+.target-{{ .variable }}
-- home/user/.config/chezmoi/chezmoi.toml --
[data]
variable = "value"
-- home/user/.file --
# contents of .file
--- home/user/.vimrc --
-set foldmarker={{,}}
-- home/user/.template --
key = value
+-- home/user/.vimrc --
+set foldmarker={{,}}
diff --git a/pkg/cmd/testdata/scripts/applyverbose.txtar b/pkg/cmd/testdata/scripts/applyverbose.txtar
index c31199be4fe..7a2b1a63208 100644
--- a/pkg/cmd/testdata/scripts/applyverbose.txtar
+++ b/pkg/cmd/testdata/scripts/applyverbose.txtar
@@ -9,17 +9,17 @@ chhome home2/user
exec chezmoi apply --dry-run --force --verbose
! stdout .
--- golden/apply.diff --
+-- golden/apply-windows.diff --
diff --git a/.file b/.file
-new file mode 100644
+new file mode 100666
index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
--- /dev/null
+++ b/.file
@@ -0,0 +1 @@
+# contents of .file
--- golden/apply-windows.diff --
+-- golden/apply.diff --
diff --git a/.file b/.file
-new file mode 100666
+new file mode 100644
index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
--- /dev/null
+++ b/.file
diff --git a/pkg/cmd/testdata/scripts/chattr.txtar b/pkg/cmd/testdata/scripts/chattr.txtar
index b8772bbf769..9d427db106f 100644
--- a/pkg/cmd/testdata/scripts/chattr.txtar
+++ b/pkg/cmd/testdata/scripts/chattr.txtar
@@ -132,9 +132,9 @@ cmp stdout golden/chattr-diff
diff --git a/dot_file b/executable_dot_file
rename from dot_file
rename to executable_dot_file
--- home/user/.local/share/chezmoi/run_script.sh --
-#!/bin/sh
-- home/user/.local/share/chezmoi/modify_dot_modify --
#!/bin/sh
cat
+-- home/user/.local/share/chezmoi/run_script.sh --
+#!/bin/sh
diff --git a/pkg/cmd/testdata/scripts/completion.txtar b/pkg/cmd/testdata/scripts/completion.txtar
index 7dc300afd09..e66a854eedf 100644
--- a/pkg/cmd/testdata/scripts/completion.txtar
+++ b/pkg/cmd/testdata/scripts/completion.txtar
@@ -42,15 +42,15 @@ true
file
symlink
:4
--- golden/use-builtin-flags --
---use-builtin-age Use builtin age
---use-builtin-git Use builtin git
-:4
-- golden/read-data --
json
toml
yaml
:4
+-- golden/use-builtin-flags --
+--use-builtin-age Use builtin age
+--use-builtin-git Use builtin git
+:4
-- golden/write-data --
json
yaml
diff --git a/pkg/cmd/testdata/scripts/completion_unix.txtar b/pkg/cmd/testdata/scripts/completion_unix.txtar
index c4eeefe01f9..727dc0f6e18 100644
--- a/pkg/cmd/testdata/scripts/completion_unix.txtar
+++ b/pkg/cmd/testdata/scripts/completion_unix.txtar
@@ -25,14 +25,14 @@ cmpenv stdout golden/complete-target-home
-- golden/complete-attribute-p --
private
:4
+-- golden/complete-dot-f-in-home --
+.file
+:4
-- golden/complete-target-home --
$HOME/.dir/
$HOME/.dir/file
$HOME/.file
:4
--- golden/complete-dot-f-in-home --
-.file
-:4
-- golden/complete-target-home-dot-f --
$HOME/.file
:4
diff --git a/pkg/cmd/testdata/scripts/diff.txtar b/pkg/cmd/testdata/scripts/diff.txtar
index d9c0696fed4..707e8d800ea 100644
--- a/pkg/cmd/testdata/scripts/diff.txtar
+++ b/pkg/cmd/testdata/scripts/diff.txtar
@@ -81,22 +81,16 @@ index 0000000000000000000000000000000000000000..06e05235fdd12fd5c367b6d629fef945
+++ b/.newfile
@@ -0,0 +1 @@
+# contents of .newfile
--- golden/modify-file-diff-unix.diff --
-diff --git a/.file b/.file
-index 5d2730a8850a2db479af83de87cc8345437aef06..8a52cb9ce9551221716a53786ad74104c5902362 100644
---- a/.file
-+++ b/.file
-@@ -1,2 +1 @@
- # contents of .file
--# edited
--- golden/modify-file-diff-windows.diff --
+-- golden/chmod-dir-diff.diff --
+diff --git a/.dir b/.dir
+old mode 40700
+new mode 40755
+-- golden/chmod-file-diff.diff --
diff --git a/.file b/.file
-index 5d2730a8850a2db479af83de87cc8345437aef06..8a52cb9ce9551221716a53786ad74104c5902362 100666
---- a/.file
-+++ b/.file
-@@ -1,2 +1 @@
- # contents of .file
--# edited
+old mode 100777
+new mode 100644
+-- golden/dot_newfile --
+# contents of .newfile
-- golden/modify-file-diff-reverse-unix.diff --
diff --git a/.file b/.file
index 8a52cb9ce9551221716a53786ad74104c5902362..5d2730a8850a2db479af83de87cc8345437aef06 100644
@@ -113,22 +107,22 @@ index 8a52cb9ce9551221716a53786ad74104c5902362..5d2730a8850a2db479af83de87cc8345
@@ -1 +1,2 @@
# contents of .file
+# edited
--- golden/restore-file-diff-unix.diff --
+-- golden/modify-file-diff-unix.diff --
diff --git a/.file b/.file
-new file mode 100644
-index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
---- /dev/null
+index 5d2730a8850a2db479af83de87cc8345437aef06..8a52cb9ce9551221716a53786ad74104c5902362 100644
+--- a/.file
+++ b/.file
-@@ -0,0 +1 @@
-+# contents of .file
--- golden/restore-file-diff-windows.diff --
+@@ -1,2 +1 @@
+ # contents of .file
+-# edited
+-- golden/modify-file-diff-windows.diff --
diff --git a/.file b/.file
-new file mode 100666
-index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
---- /dev/null
+index 5d2730a8850a2db479af83de87cc8345437aef06..8a52cb9ce9551221716a53786ad74104c5902362 100666
+--- a/.file
+++ b/.file
-@@ -0,0 +1 @@
-+# contents of .file
+@@ -1,2 +1 @@
+ # contents of .file
+-# edited
-- golden/restore-dir-diff-unix.diff --
diff --git a/.dir b/.dir
new file mode 40755
@@ -141,6 +135,22 @@ new file mode 40777
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/.dir
+-- golden/restore-file-diff-unix.diff --
+diff --git a/.file b/.file
+new file mode 100644
+index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
+--- /dev/null
++++ b/.file
+@@ -0,0 +1 @@
++# contents of .file
+-- golden/restore-file-diff-windows.diff --
+diff --git a/.file b/.file
+new file mode 100666
+index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
+--- /dev/null
++++ b/.file
+@@ -0,0 +1 @@
++# contents of .file
-- golden/symlink-file-diff-unix.diff --
diff --git a/.symlink b/.symlink
deleted file mode 100644
@@ -158,15 +168,3 @@ index 8a52cb9ce9551221716a53786ad74104c5902362..9b91fdbb83798a67fbbc5cc4f120c3f7
@@ -1 +1 @@
-# contents of .file
+.dir/subdir/file
--- golden/dot_newfile --
-# contents of .newfile
--- golden/chmod-file-diff.diff --
-diff --git a/.file b/.file
-old mode 100777
-new mode 100644
--- golden/chmod-dir-diff.diff --
-diff --git a/.dir b/.dir
-old mode 40700
-new mode 40755
--- golden/dot_newfile --
-# contents of .newfile
diff --git a/pkg/cmd/testdata/scripts/dumpjson.txtar b/pkg/cmd/testdata/scripts/dumpjson.txtar
index ff980a694be..8121e20093e 100644
--- a/pkg/cmd/testdata/scripts/dumpjson.txtar
+++ b/pkg/cmd/testdata/scripts/dumpjson.txtar
@@ -17,6 +17,48 @@ cmp stdout golden/dump-dir-non-recursive.json
! exec chezmoi dump $HOME${/}.inputrc
stderr 'not in source state'
+-- golden/dump-dir-non-recursive.json --
+{
+ ".dir": {
+ "type": "dir",
+ "name": ".dir",
+ "perm": 493
+ }
+}
+-- golden/dump-dir.json --
+{
+ ".dir": {
+ "type": "dir",
+ "name": ".dir",
+ "perm": 493
+ },
+ ".dir/file": {
+ "type": "file",
+ "name": ".dir/file",
+ "contents": "# contents of .dir/file\n",
+ "perm": 420
+ },
+ ".dir/subdir": {
+ "type": "dir",
+ "name": ".dir/subdir",
+ "perm": 493
+ },
+ ".dir/subdir/file": {
+ "type": "file",
+ "name": ".dir/subdir/file",
+ "contents": "# contents of .dir/subdir/file\n",
+ "perm": 420
+ }
+}
+-- golden/dump-file.json --
+{
+ ".file": {
+ "type": "file",
+ "name": ".file",
+ "contents": "# contents of .file\n",
+ "perm": 420
+ }
+}
-- golden/dump.json --
{
".create": {
@@ -89,45 +131,3 @@ stderr 'not in source state'
"perm": 420
}
}
--- golden/dump-file.json --
-{
- ".file": {
- "type": "file",
- "name": ".file",
- "contents": "# contents of .file\n",
- "perm": 420
- }
-}
--- golden/dump-dir.json --
-{
- ".dir": {
- "type": "dir",
- "name": ".dir",
- "perm": 493
- },
- ".dir/file": {
- "type": "file",
- "name": ".dir/file",
- "contents": "# contents of .dir/file\n",
- "perm": 420
- },
- ".dir/subdir": {
- "type": "dir",
- "name": ".dir/subdir",
- "perm": 493
- },
- ".dir/subdir/file": {
- "type": "file",
- "name": ".dir/subdir/file",
- "contents": "# contents of .dir/subdir/file\n",
- "perm": 420
- }
-}
--- golden/dump-dir-non-recursive.json --
-{
- ".dir": {
- "type": "dir",
- "name": ".dir",
- "perm": 493
- }
-}
diff --git a/pkg/cmd/testdata/scripts/dumpyaml.txtar b/pkg/cmd/testdata/scripts/dumpyaml.txtar
index 4725e345ee5..8c1e5b33414 100644
--- a/pkg/cmd/testdata/scripts/dumpyaml.txtar
+++ b/pkg/cmd/testdata/scripts/dumpyaml.txtar
@@ -8,27 +8,19 @@ cmp stdout golden/dump.yaml
exec chezmoi dump --exclude=dirs --format=yaml
cmp stdout golden/dump-except-dirs.yaml
--- golden/dump.yaml --
+-- golden/dump-except-dirs.yaml --
.create:
type: file
name: .create
contents: |
# contents of .create
perm: 420
-.dir:
- type: dir
- name: .dir
- perm: 493
.dir/file:
type: file
name: .dir/file
contents: |
# contents of .dir/file
perm: 420
-.dir/subdir:
- type: dir
- name: .dir/subdir
- perm: 493
.dir/subdir/file:
type: file
name: .dir/subdir/file
@@ -74,19 +66,27 @@ cmp stdout golden/dump-except-dirs.yaml
contents: |
key = value
perm: 420
--- golden/dump-except-dirs.yaml --
+-- golden/dump.yaml --
.create:
type: file
name: .create
contents: |
# contents of .create
perm: 420
+.dir:
+ type: dir
+ name: .dir
+ perm: 493
.dir/file:
type: file
name: .dir/file
contents: |
# contents of .dir/file
perm: 420
+.dir/subdir:
+ type: dir
+ name: .dir/subdir
+ perm: 493
.dir/subdir/file:
type: file
name: .dir/subdir/file
diff --git a/pkg/cmd/testdata/scripts/errors.txtar b/pkg/cmd/testdata/scripts/errors.txtar
index e6bbacd6fc1..0c12a134cc4 100644
--- a/pkg/cmd/testdata/scripts/errors.txtar
+++ b/pkg/cmd/testdata/scripts/errors.txtar
@@ -42,10 +42,10 @@ stderr 'inconsistent state'
# contents of .local/share/chezmoi
-- home4/user/.local/share/chezmoi/.chezmoiversion --
3.0.0
--- home5/user/.local/share/chezmoi/.chezmoiversion --
-3.0.0
-- home5/user/.local/share/chezmoi/.chezmoiroot --
home
+-- home5/user/.local/share/chezmoi/.chezmoiversion --
+3.0.0
-- home6/user/.local/share/chezmoi/run_install_packages --
# contents of install_packages
-- home6/user/.local/share/chezmoi/run_once_install_packages --
diff --git a/pkg/cmd/testdata/scripts/exclude.txtar b/pkg/cmd/testdata/scripts/exclude.txtar
index d80fea91761..2a906ffdcb7 100644
--- a/pkg/cmd/testdata/scripts/exclude.txtar
+++ b/pkg/cmd/testdata/scripts/exclude.txtar
@@ -15,16 +15,18 @@ exec chezmoi diff
[!windows] cmp stdout golden/diff-no-scripts.diff
[windows] cmp stdout golden/diff-no-scripts-windows.diff
--- home/user/.local/share/chezmoi/dot_file --
-# contents of .file
--- home/user/.local/share/chezmoi/run_script.sh --
-#!/bin/sh
-
-echo $*
-- golden/chezmoi.toml --
[diff]
exclude = ["scripts"]
--- golden/diff.diff --
+-- golden/diff-no-scripts-windows.diff --
+diff --git a/.file b/.file
+new file mode 100666
+index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
+--- /dev/null
++++ b/.file
+@@ -0,0 +1 @@
++# contents of .file
+-- golden/diff-no-scripts.diff --
diff --git a/.file b/.file
new file mode 100644
index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
@@ -32,14 +34,6 @@ index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104
+++ b/.file
@@ -0,0 +1 @@
+# contents of .file
-diff --git a/script.sh b/script.sh
-index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3747a7ba08ee591c41b7c518e430d2802137eac4 100755
---- a/script.sh
-+++ b/script.sh
-@@ -0,0 +1,3 @@
-+#!/bin/sh
-+
-+echo $*
-- golden/diff-windows.diff --
diff --git a/.file b/.file
new file mode 100666
@@ -56,7 +50,7 @@ index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3747a7ba08ee591c41b7c518e430d280
+#!/bin/sh
+
+echo $*
--- golden/diff-no-scripts.diff --
+-- golden/diff.diff --
diff --git a/.file b/.file
new file mode 100644
index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
@@ -64,11 +58,17 @@ index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104
+++ b/.file
@@ -0,0 +1 @@
+# contents of .file
--- golden/diff-no-scripts-windows.diff --
-diff --git a/.file b/.file
-new file mode 100666
-index 0000000000000000000000000000000000000000..8a52cb9ce9551221716a53786ad74104c5902362
---- /dev/null
-+++ b/.file
-@@ -0,0 +1 @@
-+# contents of .file
+diff --git a/script.sh b/script.sh
+index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3747a7ba08ee591c41b7c518e430d2802137eac4 100755
+--- a/script.sh
++++ b/script.sh
+@@ -0,0 +1,3 @@
++#!/bin/sh
++
++echo $*
+-- home/user/.local/share/chezmoi/dot_file --
+# contents of .file
+-- home/user/.local/share/chezmoi/run_script.sh --
+#!/bin/sh
+
+echo $*
diff --git a/pkg/cmd/testdata/scripts/ignore.txtar b/pkg/cmd/testdata/scripts/ignore.txtar
index 8aa0b8af4b3..9ad157f1a54 100644
--- a/pkg/cmd/testdata/scripts/ignore.txtar
+++ b/pkg/cmd/testdata/scripts/ignore.txtar
@@ -76,9 +76,9 @@ README.md
{{ end }}
-- home/user/.local/share/chezmoi/README.md --
# contents of README.md
--- home2/user/.local/share/chezmoi/dot_file.txt --
-# contents of .file.txt
-- home2/user/.local/share/chezmoi/dot_dir/file.txt --
# contents of .dir/file.txt
-- home2/user/.local/share/chezmoi/dot_dir/subdir/file.txt --
# contents of .dir/subdir/file.txt
+-- home2/user/.local/share/chezmoi/dot_file.txt --
+# contents of .file.txt
diff --git a/pkg/cmd/testdata/scripts/init.txtar b/pkg/cmd/testdata/scripts/init.txtar
index ab32312bb8e..d7eb557d786 100644
--- a/pkg/cmd/testdata/scripts/init.txtar
+++ b/pkg/cmd/testdata/scripts/init.txtar
@@ -135,15 +135,22 @@ data:
bool: true
int: 1
string: string
+-- home12/user/.local/share/chezmoi/.chezmoi.yaml.tmpl --
+data:
+ bool: {{ promptBool "bool" }}
+ int: {{ promptInt "int" }}
+ string: {{ promptString "bool" }}
+-- home13/user/.local/share/chezmoi/.chezmoi.yml.tmpl --
+data:
+ key: value
-- home4/user/.config/chezmoi/chezmoi.toml --
--- home5/user/dotfiles/.git/.keep --
-- home5/user/dotfiles/.chezmoi.toml.tmpl --
[data]
email = "[email protected]"
+-- home5/user/dotfiles/.git/.keep --
-- home7/user/.config/chezmoi/chezmoi.toml --
[data]
email = "[email protected]"
--- home7/user/.local/share/chezmoi/.git/.keep --
-- home7/user/.local/share/chezmoi/.chezmoi.toml.tmpl --
{{- $email := get . "email" -}}
{{- if not $email -}}
@@ -151,14 +158,7 @@ data:
{{- end -}}
[data]
email = {{ $email | quote }}
+-- home7/user/.local/share/chezmoi/.git/.keep --
-- home8/user/.local/share/chezmoi/.chezmoi.toml.tmpl --
[diff]
exclude: ["scripts"]
--- home12/user/.local/share/chezmoi/.chezmoi.yaml.tmpl --
-data:
- bool: {{ promptBool "bool" }}
- int: {{ promptInt "int" }}
- string: {{ promptString "bool" }}
--- home13/user/.local/share/chezmoi/.chezmoi.yml.tmpl --
-data:
- key: value
diff --git a/pkg/cmd/testdata/scripts/issue2300.txtar b/pkg/cmd/testdata/scripts/issue2300.txtar
index 55416dd91b2..bde676dddfc 100644
--- a/pkg/cmd/testdata/scripts/issue2300.txtar
+++ b/pkg/cmd/testdata/scripts/issue2300.txtar
@@ -4,10 +4,10 @@
exec chezmoi edit --apply $HOME/.dir
grep '# edited' $HOME/.dir/file
--- home/user/.dir/file --
-# contents of .dir/file
-- home/user/.config/chezmoi/chezmoi.toml --
[edit]
minDuration = 0
+-- home/user/.dir/file --
+# contents of .dir/file
-- home/user/.local/share/chezmoi/dot_dir/file --
# contents of .dir/file
diff --git a/pkg/cmd/testdata/scripts/issue2315.txtar b/pkg/cmd/testdata/scripts/issue2315.txtar
index 40763a41d9c..a8889a44527 100644
--- a/pkg/cmd/testdata/scripts/issue2315.txtar
+++ b/pkg/cmd/testdata/scripts/issue2315.txtar
@@ -11,11 +11,11 @@ output
#!/bin/sh
echo output
+-- home/user/.local/share/chezmoi/dot_file.tmpl --
+{{ output "binary.sh" -}}
-- home/user/.local/share/chezmoi/run_before_install-binary.sh --
#!/bin/sh
cp $WORK/golden/binary.sh $HOME/bin
chmod a+x $HOME/bin/binary.sh
--- home/user/.local/share/chezmoi/dot_file.tmpl --
-{{ output "binary.sh" -}}
-- home/user/bin/.keep --
diff --git a/pkg/cmd/testdata/scripts/keepassxc.txtar b/pkg/cmd/testdata/scripts/keepassxc.txtar
index 1d925e8e0f2..14c5d3aa800 100644
--- a/pkg/cmd/testdata/scripts/keepassxc.txtar
+++ b/pkg/cmd/testdata/scripts/keepassxc.txtar
@@ -60,9 +60,9 @@ IF "%*" == "--version" (
echo keepass-test: invalid command: %*
exit /b 1
)
--- home/user/input --
-fakepassword
-- home/user/.config/chezmoi/chezmoi.toml --
[keepassxc]
command = "keepass-test"
database = "/secrets.kdbx"
+-- home/user/input --
+fakepassword
diff --git a/pkg/cmd/testdata/scripts/literal.txtar b/pkg/cmd/testdata/scripts/literal.txtar
index baf6785091c..fdae2095317 100644
--- a/pkg/cmd/testdata/scripts/literal.txtar
+++ b/pkg/cmd/testdata/scripts/literal.txtar
@@ -11,23 +11,23 @@ cmp $HOME/run_script golden/run_script
cmp $HOME/symlink_symlink golden/symlink_symlink
cmp $HOME/template.tmpl golden/template.tmpl
--- home/user/dot_file --
+-- golden/dot_file --
# contents of dot_file
--- home/user/run_script --
+-- golden/run_script --
#!/bin/sh
echo contents of run_script
--- home/user/symlink_symlink --
+-- golden/symlink_symlink --
# contents of symlink_symlink
--- home/user/template.tmpl --
+-- golden/template.tmpl --
# contents of template.tmpl
--- golden/dot_file --
+-- home/user/dot_file --
# contents of dot_file
--- golden/run_script --
+-- home/user/run_script --
#!/bin/sh
echo contents of run_script
--- golden/symlink_symlink --
+-- home/user/symlink_symlink --
# contents of symlink_symlink
--- golden/template.tmpl --
+-- home/user/template.tmpl --
# contents of template.tmpl
diff --git a/pkg/cmd/testdata/scripts/managed.txtar b/pkg/cmd/testdata/scripts/managed.txtar
index 3b4e2d1219c..7fda52f1141 100644
--- a/pkg/cmd/testdata/scripts/managed.txtar
+++ b/pkg/cmd/testdata/scripts/managed.txtar
@@ -77,6 +77,10 @@ cmp stdout golden/managed2
-- golden/managed-dirs --
.dir
.dir/subdir
+-- golden/managed-except-files --
+.dir
+.dir/subdir
+.symlink
-- golden/managed-files --
.create
.dir/file
@@ -88,36 +92,32 @@ cmp stdout golden/managed2
.readonly
.remove
.template
+-- golden/managed-in-managed --
+.dir/subdir
+.dir/subdir/file
-- golden/managed-symlinks --
.symlink
--- golden/managed-except-files --
+-- golden/managed-with-absent-args --
.dir
+.dir/file
.dir/subdir
-.symlink
--- golden/managed2 --
-.create
-.file
-.symlink
-.template
-script
+.dir/subdir/file
-- golden/managed-with-args --
.create
.dir
.dir/file
.dir/subdir
.dir/subdir/file
--- golden/managed-in-managed --
-.dir/subdir
-.dir/subdir/file
-- golden/managed-with-nodir-args --
.create
.dir/file
.dir/subdir/file
--- golden/managed-with-absent-args --
-.dir
-.dir/file
-.dir/subdir
-.dir/subdir/file
+-- golden/managed2 --
+.create
+.file
+.symlink
+.template
+script
-- home/user/.local/share/chezmoi/.chezmoiremove --
.remove
-- home2/user/.local/share/chezmoi/create_dot_create.tmpl --
@@ -126,7 +126,7 @@ script
{{ fail "Template should not be executed }}
-- home2/user/.local/share/chezmoi/modify_dot_file.tmpl --
{{ fail "Template should not be executed }}
--- home2/user/.local/share/chezmoi/symlink_dot_symlink.tmpl --
-{{ fail "Template should not be executed }}
-- home2/user/.local/share/chezmoi/run_script.tmpl --
{{ fail "Template should not be executed }}
+-- home2/user/.local/share/chezmoi/symlink_dot_symlink.tmpl --
+{{ fail "Template should not be executed }}
diff --git a/pkg/cmd/testdata/scripts/mergeall_unix.txtar b/pkg/cmd/testdata/scripts/mergeall_unix.txtar
index 032f9969af4..3b1d6cac169 100644
--- a/pkg/cmd/testdata/scripts/mergeall_unix.txtar
+++ b/pkg/cmd/testdata/scripts/mergeall_unix.txtar
@@ -9,10 +9,10 @@ edit $HOME/.file
exec chezmoi merge-all
stdout ^${HOME@R}/\.file\s+${CHEZMOISOURCEDIR@R}/dot_file\.tmpl\s+${WORK@R}/.*/\.file$
--- home/user/.file --
-# contents of .file
-- home/user/.config/chezmoi/chezmoi.toml --
[merge]
command = "echo"
+-- home/user/.file --
+# contents of .file
-- home/user/.local/share/chezmoi/dot_file.tmpl --
{{ "# contents of .file" }}
diff --git a/pkg/cmd/testdata/scripts/mergeencryptedgpg_unix.txtar b/pkg/cmd/testdata/scripts/mergeencryptedgpg_unix.txtar
index 3981b305a50..33f2f6e9164 100644
--- a/pkg/cmd/testdata/scripts/mergeencryptedgpg_unix.txtar
+++ b/pkg/cmd/testdata/scripts/mergeencryptedgpg_unix.txtar
@@ -35,12 +35,12 @@ cmp stdout golden/edited-target
echo "# edited" >> $2
-- golden/destination --
destination
+-- golden/edited-target --
+target
+# edited
-- golden/expected --
destination
{{ "target" }}
target
-- golden/source --
{{ "target" }}
--- golden/edited-target --
-target
-# edited
diff --git a/pkg/cmd/testdata/scripts/modify_unix.txtar b/pkg/cmd/testdata/scripts/modify_unix.txtar
index 3ba491ddc8d..b99cc3a6fc1 100644
--- a/pkg/cmd/testdata/scripts/modify_unix.txtar
+++ b/pkg/cmd/testdata/scripts/modify_unix.txtar
@@ -85,15 +85,15 @@ index f91830d4ecd80adfe9a6aea9dca579397aa86921..6b6d41aae5e8d64a54afd8b8ad5a38a3
sed 's/middle/modified-middle/g'
-- home2/user/.file --
# contents of .file
--- home2/user/.local/share/chezmoi/modify_dot_not_exist --
-#!/bin/sh
-
-cat
-- home2/user/.local/share/chezmoi/modify_dot_error --
#!/bin/sh
echo error >2
exit 1
+-- home2/user/.local/share/chezmoi/modify_dot_not_exist --
+#!/bin/sh
+
+cat
-- home2/user/.local/share/chezmoi/modify_private_executable_dot_file --
#!/bin/sh
@@ -102,11 +102,11 @@ cat
beginning
middle
end
--- home4/user/.modify --
-beginning
-middle
-end
-- home4/user/.local/share/chezmoi/modify_dot_modify.tmpl --
#!/bin/sh
{{ "sed 's/middle/modified-middle/g'" }}
+-- home4/user/.modify --
+beginning
+middle
+end
diff --git a/pkg/cmd/testdata/scripts/remove.txtar b/pkg/cmd/testdata/scripts/remove.txtar
index eb0bbad9ddb..bdfcc3450e2 100644
--- a/pkg/cmd/testdata/scripts/remove.txtar
+++ b/pkg/cmd/testdata/scripts/remove.txtar
@@ -41,12 +41,12 @@ exec chezmoi apply --destination=$HOME/
-- home2/user/.dir/.keep --
-- home2/user/.file --
# contents of .file
--- home2/user/.local/share/chezmoi/remove_dot_file --
-- home2/user/.local/share/chezmoi/remove_dot_dir --
--- home3/user/.star-dir/.keep --
--- home3/user/.star-file --
-# contents of .star-file
+-- home2/user/.local/share/chezmoi/remove_dot_file --
-- home3/user/.local/share/chezmoi/.chezmoiremove --
.*-dir/
.*-file
+-- home3/user/.star-dir/.keep --
+-- home3/user/.star-file --
+# contents of .star-file
diff --git a/pkg/cmd/testdata/scripts/scriptonchange_unix.txtar b/pkg/cmd/testdata/scripts/scriptonchange_unix.txtar
index f34cac3f53a..2e31208abfc 100644
--- a/pkg/cmd/testdata/scripts/scriptonchange_unix.txtar
+++ b/pkg/cmd/testdata/scripts/scriptonchange_unix.txtar
@@ -39,15 +39,15 @@ cmp stdout golden/script-one-state.json
"type": "script",
"contentsSHA256": "a07f0271151ee0271ed379ebbddc5ef49d0f625417c8fe23254179e56f98d2df"
}
+-- golden/script-one.sh --
+#!/bin/sh
+
+echo one
-- golden/script-two-state.json --
{
"type": "script",
"contentsSHA256": "7c8d714586cecf4f0ffb735ad10334df98428bc5282c0d0a6b78f5c074365159"
}
--- golden/script-one.sh --
-#!/bin/sh
-
-echo one
-- golden/script-two.sh --
#!/bin/sh
diff --git a/pkg/cmd/testdata/scripts/scriptsdir_unix.txtar b/pkg/cmd/testdata/scripts/scriptsdir_unix.txtar
index e961ae0eaa6..8b4f1759b92 100644
--- a/pkg/cmd/testdata/scripts/scriptsdir_unix.txtar
+++ b/pkg/cmd/testdata/scripts/scriptsdir_unix.txtar
@@ -35,6 +35,6 @@ echo script
echo script in subdir
-- home2/user/.local/share/chezmoi/.chezmoiscripts/dot_file --
--- home3/user/.local/share/chezmoi/.chezmoiscripts/run_script.sh --
-- home3/user/.local/share/chezmoi/.chezmoiscripts/run_once_script.sh --
+-- home3/user/.local/share/chezmoi/.chezmoiscripts/run_script.sh --
-- home4/user/.local/share/chezmoi/.chezmoiscripts/.chezmoiignore --
diff --git a/pkg/cmd/testdata/scripts/state.txtar b/pkg/cmd/testdata/scripts/state.txtar
index dae2f66d292..70fe1254191 100644
--- a/pkg/cmd/testdata/scripts/state.txtar
+++ b/pkg/cmd/testdata/scripts/state.txtar
@@ -17,8 +17,8 @@ exec chezmoi state delete --bucket=bucket --key=key
exec chezmoi state data --format=yaml
cmp stdout golden/data-after-delete.yaml
+-- golden/data-after-delete.yaml --
+bucket: {}
-- golden/data.yaml --
bucket:
key: value
--- golden/data-after-delete.yaml --
-bucket: {}
diff --git a/pkg/cmd/testdata/scripts/templatedata.txtar b/pkg/cmd/testdata/scripts/templatedata.txtar
index ab19af65de8..a755223d937 100644
--- a/pkg/cmd/testdata/scripts/templatedata.txtar
+++ b/pkg/cmd/testdata/scripts/templatedata.txtar
@@ -31,10 +31,10 @@ stdout ok
{{ .chezmoi.sourceFile }}
-- home2/user/.local/share/chezmoi/.chezmoidata.toml --
filename = ".file2"
--- home2/user/.local/share/chezmoi/.chezmoitemplates/ignore --
-{{ .filename }}
-- home2/user/.local/share/chezmoi/.chezmoiignore --
{{ template "ignore" . }}
+-- home2/user/.local/share/chezmoi/.chezmoitemplates/ignore --
+{{ .filename }}
-- home2/user/.local/share/chezmoi/dot_file1 --
# contents of .file1
-- home2/user/.local/share/chezmoi/dot_file2 --
@@ -43,11 +43,11 @@ filename = ".file2"
{{ "invalid template"
-- home3/user/.local/share/chezmoi/.chezmoidata.yaml --
message: ok
--- home3/user/.local/share/chezmoi/.chezmoitemplates/template --
-{{ .message }}
-- home3/user/.local/share/chezmoi/.chezmoiexternal.toml --
{{ "invalid template"
-- home3/user/.local/share/chezmoi/.chezmoiignore --
{{ "invalid template"
-- home3/user/.local/share/chezmoi/.chezmoiremove --
{{ "invalid template"
+-- home3/user/.local/share/chezmoi/.chezmoitemplates/template --
+{{ .message }}
diff --git a/pkg/cmd/testdata/scripts/templatefuncs.txtar b/pkg/cmd/testdata/scripts/templatefuncs.txtar
index 44866d5a14c..ceb331a644c 100644
--- a/pkg/cmd/testdata/scripts/templatefuncs.txtar
+++ b/pkg/cmd/testdata/scripts/templatefuncs.txtar
@@ -164,10 +164,10 @@ key = value
subkey = subvalue
-- home/user/.include --
# contents of .include
--- home/user/.local/share/chezmoi/.include --
-# contents of .local/share/chezmoi/.include
-- home/user/.local/share/chezmoi/.chezmoitemplates/template --
{{ . }}
+-- home/user/.local/share/chezmoi/.include --
+# contents of .local/share/chezmoi/.include
-- home/user/.local/share/chezmoi/.template --
{{ . }}
-- home/user/.local/share/chezmoi/template --
diff --git a/pkg/cmd/testdata/scripts/unmanaged.txtar b/pkg/cmd/testdata/scripts/unmanaged.txtar
index 1378a997017..4c130dd71f9 100644
--- a/pkg/cmd/testdata/scripts/unmanaged.txtar
+++ b/pkg/cmd/testdata/scripts/unmanaged.txtar
@@ -36,10 +36,10 @@ cmp stdout golden/unmanaged-with-some-managed
.dir
.file
.local
+-- golden/unmanaged-inside-unmanaged --
+.dir/subdir
-- golden/unmanaged-with-args --
.dir
.file
--- golden/unmanaged-inside-unmanaged --
-.dir/subdir
-- golden/unmanaged-with-some-managed --
.file
|
chore
|
Tidy up txtar archives
|
9769b0f325a0dfc75cd3ded23ac991fc745c909d
|
2021-02-06 15:24:53
|
Tom Payne
|
docs: Fix media page on chezmoi.io
| false
|
diff --git a/chezmoi2/cmd/docs.gen.go b/chezmoi2/cmd/docs.gen.go
index 0b3990e444f..e94c09e8a26 100644
--- a/chezmoi2/cmd/docs.gen.go
+++ b/chezmoi2/cmd/docs.gen.go
@@ -1813,7 +1813,7 @@ func init() {
assets["docs/MEDIA.md"] = []byte("" +
"# chezmoi in the media\n" +
"\n" +
- "<!-- toc -->\n" +
+ "<!--- toc --->\n" +
"\n" +
"Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/)\n" +
"\n" +
diff --git a/cmd/docs.gen.go b/cmd/docs.gen.go
index d12aa8a666c..782a30663b7 100644
--- a/cmd/docs.gen.go
+++ b/cmd/docs.gen.go
@@ -1813,7 +1813,7 @@ func init() {
assets["docs/MEDIA.md"] = []byte("" +
"# chezmoi in the media\n" +
"\n" +
- "<!-- toc -->\n" +
+ "<!--- toc --->\n" +
"\n" +
"Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/)\n" +
"\n" +
diff --git a/docs/MEDIA.md b/docs/MEDIA.md
index 28fbe51f7ce..060e496a915 100644
--- a/docs/MEDIA.md
+++ b/docs/MEDIA.md
@@ -1,6 +1,6 @@
# chezmoi in the media
-<!-- toc -->
+<!--- toc --->
Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/)
|
docs
|
Fix media page on chezmoi.io
|
19b54983f0024eadaee9d353b65be73c1f61df22
|
2023-07-18 22:36:45
|
Tom Payne
|
chore: Set branch name for microsoft/winget-pkgs PRs
| false
|
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 976569ca5d0..ed162cfc92b 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -272,6 +272,7 @@ winget:
repository:
owner: twpayne
name: winget-pkgs
+ branch: 'chezmoi-{{ .Version }}'
token: '{{ .Env.WINGET_GITHUB_TOKEN }}'
pull_request:
enabled: true
|
chore
|
Set branch name for microsoft/winget-pkgs PRs
|
964810aa28319a720fe800b6e6b0a1934e2c8056
|
2022-10-13 18:49:11
|
Tom Payne
|
feat: Expose template data in environment variables
| false
|
diff --git a/pkg/chezmoi/data.go b/pkg/chezmoi/data.go
index 830b0410a35..75849668860 100644
--- a/pkg/chezmoi/data.go
+++ b/pkg/chezmoi/data.go
@@ -52,12 +52,12 @@ func Kernel(fileSystem vfs.FS) (map[string]any, error) {
// OSRelease returns the operating system identification data as defined by the
// os-release specification.
-func OSRelease(system System) (map[string]any, error) {
- for _, filename := range []AbsPath{
- NewAbsPath("/etc/os-release"),
- NewAbsPath("/usr/lib/os-release"),
+func OSRelease(fileSystem vfs.FS) (map[string]any, error) {
+ for _, filename := range []string{
+ "/etc/os-release",
+ "/usr/lib/os-release",
} {
- data, err := system.ReadFile(filename)
+ data, err := fileSystem.ReadFile(filename)
if errors.Is(err, fs.ErrNotExist) {
continue
} else if err != nil {
diff --git a/pkg/chezmoi/data_test.go b/pkg/chezmoi/data_test.go
index bbcddaf02a9..5cd6d3a54d1 100644
--- a/pkg/chezmoi/data_test.go
+++ b/pkg/chezmoi/data_test.go
@@ -159,8 +159,7 @@ func TestOSRelease(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
chezmoitest.WithTestFS(t, tc.root, func(fileSystem vfs.FS) {
- system := NewRealSystem(fileSystem)
- actual, err := OSRelease(system)
+ actual, err := OSRelease(fileSystem)
assert.NoError(t, err)
assert.Equal(t, tc.expected, actual)
})
diff --git a/pkg/chezmoi/realsystem.go b/pkg/chezmoi/realsystem.go
index 6825fb5d606..2c6dde2ffb6 100644
--- a/pkg/chezmoi/realsystem.go
+++ b/pkg/chezmoi/realsystem.go
@@ -18,13 +18,6 @@ import (
// A RealSystemOption sets an option on a RealSystem.
type RealSystemOption func(*RealSystem)
-// RealSystemWithScriptEnv sets the environment.
-func RealSystemWithScriptEnv(scriptEnv []string) RealSystemOption {
- return func(s *RealSystem) {
- s.scriptEnv = scriptEnv
- }
-}
-
// Chtimes implements System.Chtimes.
func (s *RealSystem) Chtimes(name AbsPath, atime, mtime time.Time) error {
return s.fileSystem.Chtimes(name.String(), atime, mtime)
@@ -138,6 +131,11 @@ func (s *RealSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, int
return s.RunCmd(cmd)
}
+// SetScriptEnv sets the environment variables for scripts.
+func (s *RealSystem) SetScriptEnv(scriptEnv []string) {
+ s.scriptEnv = scriptEnv
+}
+
// Stat implements System.Stat.
func (s *RealSystem) Stat(name AbsPath) (fs.FileInfo, error) {
return s.fileSystem.Stat(name.String())
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index ba1c2b81c67..4c0128699b3 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -195,6 +195,7 @@ type Config struct {
sourceDirAbsPathErr error
sourceState *chezmoi.SourceState
sourceStateErr error
+ templateData *templateData
stdin io.Reader
stdout io.Writer
@@ -208,6 +209,28 @@ type Config struct {
restoreWindowsConsole func() error
}
+type templateData struct {
+ Arch string `json:"arch"`
+ Args []string `json:"args"`
+ CacheDir chezmoi.AbsPath `json:"cacheDir"`
+ ConfigFile chezmoi.AbsPath `json:"configFile"`
+ Executable chezmoi.AbsPath `json:"executable"`
+ FQDNHostname string `json:"fqdnHostname"`
+ GID string `json:"gid"`
+ Group string `json:"group"`
+ HomeDir chezmoi.AbsPath `json:"homeDir"`
+ Hostname string `json:"hostname"`
+ Kernel map[string]any `json:"kernel"`
+ OS string `json:"os"`
+ OSRelease map[string]any `json:"osRelease"`
+ SourceDir chezmoi.AbsPath `json:"sourceDir"`
+ UID string `json:"uid"`
+ Username string `json:"username"`
+ Version map[string]any `json:"version"`
+ WindowsVersion map[string]any `json:"windowsVersion"`
+ WorkingTree chezmoi.AbsPath `json:"workingTree"`
+}
+
// A configOption sets and option on a Config.
type configOption func(*Config) error
@@ -685,7 +708,7 @@ func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte
}
builder := strings.Builder{}
- templateData := c.defaultTemplateData()
+ templateData := c.getTemplateDataMap()
if c.init.data {
chezmoi.RecursiveMerge(templateData, c.Data)
}
@@ -930,126 +953,6 @@ func (c *Config) defaultSourceDir(fileSystem vfs.Stater, bds *xdg.BaseDirectoryS
return dataHomeAbsPath.Join(chezmoiRelPath), nil
}
-// defaultTemplateData returns the default template data.
-func (c *Config) defaultTemplateData() map[string]any {
- // Determine the user's username and group, if possible.
- //
- // user.Current and user.LookupGroupId in Go's standard library are
- // generally unreliable, so work around errors if possible, or ignore them.
- //
- // If CGO is disabled, then the Go standard library falls back to parsing
- // /etc/passwd and /etc/group, which will return incorrect results without
- // error if the system uses an alternative password database such as NIS or
- // LDAP.
- //
- // If CGO is enabled then user.Current and user.LookupGroupId will use the
- // underlying libc functions, namely getpwuid_r and getgrnam_r. If linked
- // with glibc this will return the correct result. If linked with musl then
- // they will use musl's implementation which, like Go's non-CGO
- // implementation, also only parses /etc/passwd and /etc/group and so also
- // returns incorrect results without error if NIS or LDAP are being used.
- //
- // On Windows, the user's group ID returned by user.Current() is an SID and
- // no further useful lookup is possible with Go's standard library.
- //
- // Since neither the username nor the group are likely widely used in
- // templates, leave these variables unset if their values cannot be
- // determined. Unset variables will trigger template errors if used,
- // alerting the user to the problem and allowing them to find alternative
- // solutions.
- var gid, group, uid, username string
- if currentUser, err := user.Current(); err == nil {
- gid = currentUser.Gid
- uid = currentUser.Uid
- username = currentUser.Username
- if runtime.GOOS != "windows" {
- if rawGroup, err := user.LookupGroupId(currentUser.Gid); err == nil {
- group = rawGroup.Name
- } else {
- c.logger.Info().
- Str("gid", currentUser.Gid).
- Err(err).
- Msg("user.LookupGroupId")
- }
- }
- } else {
- c.logger.Info().
- Err(err).
- Msg("user.Current")
- var ok bool
- username, ok = os.LookupEnv("USER")
- if !ok {
- c.logger.Info().
- Str("key", "USER").
- Bool("ok", ok).
- Msg("os.LookupEnv")
- }
- }
-
- fqdnHostname, err := chezmoi.FQDNHostname(c.fileSystem)
- if err != nil {
- c.logger.Info().
- Err(err).
- Msg("chezmoi.FQDNHostname")
- }
- hostname, _, _ := strings.Cut(fqdnHostname, ".")
-
- kernel, err := chezmoi.Kernel(c.fileSystem)
- if err != nil {
- c.logger.Info().
- Err(err).
- Msg("chezmoi.Kernel")
- }
-
- var osRelease map[string]any
- switch runtime.GOOS {
- case "openbsd", "windows":
- // Don't populate osRelease on OSes where /etc/os-release does not
- // exist.
- default:
- if rawOSRelease, err := chezmoi.OSRelease(c.baseSystem); err == nil {
- osRelease = upperSnakeCaseToCamelCaseMap(rawOSRelease)
- } else {
- c.logger.Info().
- Err(err).
- Msg("chezmoi.OSRelease")
- }
- }
-
- executable, _ := os.Executable()
-
- windowsVersion, _ := windowsVersion()
-
- return map[string]any{
- "chezmoi": map[string]any{
- "arch": runtime.GOARCH,
- "args": os.Args,
- "cacheDir": c.CacheDirAbsPath.String(),
- "configFile": c.configFileAbsPath.String(),
- "executable": executable,
- "fqdnHostname": fqdnHostname,
- "gid": gid,
- "group": group,
- "homeDir": c.homeDir,
- "hostname": hostname,
- "kernel": kernel,
- "os": runtime.GOOS,
- "osRelease": osRelease,
- "sourceDir": c.SourceDirAbsPath.String(),
- "uid": uid,
- "username": username,
- "version": map[string]any{
- "builtBy": c.versionInfo.BuiltBy,
- "commit": c.versionInfo.Commit,
- "date": c.versionInfo.Date,
- "version": c.versionInfo.Version,
- },
- "windowsVersion": windowsVersion,
- "workingTree": c.WorkingTreeAbsPath.String(),
- },
- }
-}
-
type destAbsPathInfosOptions struct {
follow bool
ignoreNotExist bool
@@ -1231,7 +1134,7 @@ type configTemplate struct {
// format, and contents. It returns an error if multiple config file templates
// are found.
func (c *Config) findConfigTemplate() (*configTemplate, error) {
- sourceDirAbsPath, err := c.getSourceDirAbsPath()
+ sourceDirAbsPath, err := c.getSourceDirAbsPath(nil)
if err != nil {
return nil, err
}
@@ -1300,11 +1203,17 @@ func (c *Config) getHTTPClient() (*http.Client, error) {
return c.httpClient, nil
}
+type getSourceDirAbsPathOptions struct {
+ refresh bool
+}
+
// getSourceDirAbsPath returns the source directory, using .chezmoiroot if it
// exists.
-func (c *Config) getSourceDirAbsPath() (chezmoi.AbsPath, error) {
- if !c.sourceDirAbsPath.Empty() || c.sourceDirAbsPathErr != nil {
- return c.sourceDirAbsPath, c.sourceDirAbsPathErr
+func (c *Config) getSourceDirAbsPath(options *getSourceDirAbsPathOptions) (chezmoi.AbsPath, error) {
+ if options == nil || !options.refresh {
+ if !c.sourceDirAbsPath.Empty() || c.sourceDirAbsPathErr != nil {
+ return c.sourceDirAbsPath, c.sourceDirAbsPathErr
+ }
}
switch data, err := c.sourceSystem.ReadFile(c.SourceDirAbsPath.JoinString(chezmoi.RootName)); {
@@ -1327,6 +1236,31 @@ func (c *Config) getSourceState(ctx context.Context) (*chezmoi.SourceState, erro
return c.sourceState, c.sourceStateErr
}
+// getTemplateData returns the default template data.
+func (c *Config) getTemplateData() *templateData {
+ if c.templateData == nil {
+ c.templateData = c.newTemplateData()
+ }
+ return c.templateData
+}
+
+// getTemplateDataMao returns the template data as a map.
+func (c *Config) getTemplateDataMap() map[string]any {
+ templateData := c.getTemplateData()
+ // FIXME round-tripping via JSON is a horrible hack
+ data, err := json.Marshal(templateData)
+ if err != nil {
+ panic(err)
+ }
+ var templateDataMap map[string]any
+ if err := json.Unmarshal(data, &templateDataMap); err != nil {
+ panic(err)
+ }
+ return map[string]any{
+ "chezmoi": templateDataMap,
+ }
+}
+
// gitAutoAdd adds all changes to the git index and returns the new git status.
func (c *Config) gitAutoAdd() (*git.Status, error) {
if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, []string{"add", "."}); err != nil {
@@ -1540,7 +1474,7 @@ func (c *Config) newSourceState(
sourceStateLogger := c.logger.With().Str(logComponentKey, logComponentValueSourceState).Logger()
- c.SourceDirAbsPath, err = c.getSourceDirAbsPath()
+ c.SourceDirAbsPath, err = c.getSourceDirAbsPath(nil)
if err != nil {
return nil, err
}
@@ -1548,7 +1482,7 @@ func (c *Config) newSourceState(
sourceState := chezmoi.NewSourceState(append([]chezmoi.SourceStateOption{
chezmoi.WithBaseSystem(c.baseSystem),
chezmoi.WithCacheDir(c.CacheDirAbsPath),
- chezmoi.WithDefaultTemplateDataFunc(c.defaultTemplateData),
+ chezmoi.WithDefaultTemplateDataFunc(c.getTemplateDataMap),
chezmoi.WithDestDir(c.DestDirAbsPath),
chezmoi.WithEncryption(c.encryption),
chezmoi.WithHTTPClient(httpClient),
@@ -1736,17 +1670,11 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
Strs("args", os.Args).
Str("goVersion", runtime.Version()).
Msg("persistentPreRunRootE")
-
- scriptEnv := os.Environ()
- for key, value := range c.ScriptEnv {
- scriptEnv = append(scriptEnv, key+"="+value)
- }
-
- c.baseSystem = chezmoi.NewRealSystem(c.fileSystem,
- chezmoi.RealSystemWithScriptEnv(scriptEnv),
+ realSystem := chezmoi.NewRealSystem(c.fileSystem,
chezmoi.RealSystemWithSafe(c.Safe),
chezmoi.RealSystemWithScriptTempDir(c.ScriptTempDir),
)
+ c.baseSystem = realSystem
if c.debug {
systemLogger := c.logger.With().Str(logComponentKey, logComponentValueSystem).Logger()
c.baseSystem = chezmoi.NewDebugSystem(c.baseSystem, &systemLogger)
@@ -1899,6 +1827,44 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
}
}
+ scriptEnv := os.Environ()
+ templateData := c.getTemplateData()
+ for key, value := range map[string]string{
+ "ARCH": templateData.Arch,
+ "ARGS": strings.Join(templateData.Args, " "),
+ "CACHE_DIR": templateData.CacheDir.String(),
+ "CONFIG_FILE": templateData.ConfigFile.String(),
+ "EXECUTABLE": templateData.Executable.String(),
+ "FQDN_HOSTNAME": templateData.FQDNHostname,
+ "GID": templateData.GID,
+ "GROUP": templateData.Group,
+ "HOME_DIR": templateData.HomeDir.String(),
+ "HOSTNAME": templateData.Hostname,
+ "OS": templateData.OS,
+ "SOURCE_DIR": templateData.SourceDir.String(),
+ "UID": templateData.UID,
+ "USERNAME": templateData.Username,
+ "WORKING_TREE": templateData.WorkingTree.String(),
+ } {
+ scriptEnv = append(scriptEnv, "CHEZMOI_"+key+"="+value)
+ }
+ for groupKey, group := range map[string]map[string]any{
+ "KERNEL": templateData.Kernel,
+ "OS_RELEASE": templateData.OSRelease,
+ "VERSION": templateData.Version,
+ "WINDOWS_VERSION": templateData.WindowsVersion,
+ } {
+ for key, value := range group {
+ upperSnakeCaseKey := camelCaseToUpperSnakeCase(key)
+ valueStr := fmt.Sprintf("%s", value)
+ scriptEnv = append(scriptEnv, "CHEZMOI_"+groupKey+"_"+upperSnakeCaseKey+"="+valueStr)
+ }
+ }
+ for key, value := range c.ScriptEnv {
+ scriptEnv = append(scriptEnv, key+"="+value)
+ }
+ realSystem.SetScriptEnv(scriptEnv)
+
return nil
}
@@ -1929,6 +1895,123 @@ func (c *Config) persistentStateFile() (chezmoi.AbsPath, error) {
return defaultConfigFileAbsPath.Dir().Join(persistentStateFileRelPath), nil
}
+func (c *Config) newTemplateData() *templateData {
+ // Determine the user's username and group, if possible.
+ //
+ // user.Current and user.LookupGroupId in Go's standard library are
+ // generally unreliable, so work around errors if possible, or ignore them.
+ //
+ // If CGO is disabled, then the Go standard library falls back to parsing
+ // /etc/passwd and /etc/group, which will return incorrect results without
+ // error if the system uses an alternative password database such as NIS or
+ // LDAP.
+ //
+ // If CGO is enabled then user.Current and user.LookupGroupId will use the
+ // underlying libc functions, namely getpwuid_r and getgrnam_r. If linked
+ // with glibc this will return the correct result. If linked with musl then
+ // they will use musl's implementation which, like Go's non-CGO
+ // implementation, also only parses /etc/passwd and /etc/group and so also
+ // returns incorrect results without error if NIS or LDAP are being used.
+ //
+ // On Windows, the user's group ID returned by user.Current() is an SID and
+ // no further useful lookup is possible with Go's standard library.
+ //
+ // Since neither the username nor the group are likely widely used in
+ // templates, leave these variables unset if their values cannot be
+ // determined. Unset variables will trigger template errors if used,
+ // alerting the user to the problem and allowing them to find alternative
+ // solutions.
+ var gid, group, uid, username string
+ if currentUser, err := user.Current(); err == nil {
+ gid = currentUser.Gid
+ uid = currentUser.Uid
+ username = currentUser.Username
+ if runtime.GOOS != "windows" {
+ if rawGroup, err := user.LookupGroupId(currentUser.Gid); err == nil {
+ group = rawGroup.Name
+ } else {
+ c.logger.Info().
+ Str("gid", currentUser.Gid).
+ Err(err).
+ Msg("user.LookupGroupId")
+ }
+ }
+ } else {
+ c.logger.Info().
+ Err(err).
+ Msg("user.Current")
+ var ok bool
+ username, ok = os.LookupEnv("USER")
+ if !ok {
+ c.logger.Info().
+ Str("key", "USER").
+ Bool("ok", ok).
+ Msg("os.LookupEnv")
+ }
+ }
+
+ fqdnHostname, err := chezmoi.FQDNHostname(c.fileSystem)
+ if err != nil {
+ c.logger.Info().
+ Err(err).
+ Msg("chezmoi.FQDNHostname")
+ }
+ hostname, _, _ := strings.Cut(fqdnHostname, ".")
+
+ kernel, err := chezmoi.Kernel(c.fileSystem)
+ if err != nil {
+ c.logger.Info().
+ Err(err).
+ Msg("chezmoi.Kernel")
+ }
+
+ var osRelease map[string]any
+ switch runtime.GOOS {
+ case "openbsd", "windows":
+ // Don't populate osRelease on OSes where /etc/os-release does not
+ // exist.
+ default:
+ if rawOSRelease, err := chezmoi.OSRelease(c.fileSystem); err == nil {
+ osRelease = upperSnakeCaseToCamelCaseMap(rawOSRelease)
+ } else {
+ c.logger.Info().
+ Err(err).
+ Msg("chezmoi.OSRelease")
+ }
+ }
+
+ executable, _ := os.Executable()
+ windowsVersion, _ := windowsVersion()
+ sourceDirAbsPath, _ := c.getSourceDirAbsPath(nil)
+
+ return &templateData{
+ Arch: runtime.GOARCH,
+ Args: os.Args,
+ CacheDir: c.CacheDirAbsPath,
+ ConfigFile: c.configFileAbsPath,
+ Executable: chezmoi.NewAbsPath(executable),
+ FQDNHostname: fqdnHostname,
+ GID: gid,
+ Group: group,
+ HomeDir: c.homeDirAbsPath,
+ Hostname: hostname,
+ Kernel: kernel,
+ OS: runtime.GOOS,
+ OSRelease: osRelease,
+ SourceDir: sourceDirAbsPath,
+ UID: uid,
+ Username: username,
+ Version: map[string]any{
+ "builtBy": c.versionInfo.BuiltBy,
+ "commit": c.versionInfo.Commit,
+ "date": c.versionInfo.Date,
+ "version": c.versionInfo.Version,
+ },
+ WindowsVersion: windowsVersion,
+ WorkingTree: c.WorkingTreeAbsPath,
+ }
+}
+
// readConfig reads the config file, if it exists.
func (c *Config) readConfig() error {
switch err := c.decodeConfigFile(c.configFileAbsPath, &c.ConfigFile); {
diff --git a/pkg/cmd/doctorcmd.go b/pkg/cmd/doctorcmd.go
index fb8eaf4db83..d2dde4169d6 100644
--- a/pkg/cmd/doctorcmd.go
+++ b/pkg/cmd/doctorcmd.go
@@ -641,7 +641,7 @@ func (osArchCheck) Name() string {
func (osArchCheck) Run(system chezmoi.System, homeDirAbsPath chezmoi.AbsPath) (checkResult, string) {
fields := []string{runtime.GOOS + "/" + runtime.GOARCH}
- if osRelease, err := chezmoi.OSRelease(system); err == nil {
+ if osRelease, err := chezmoi.OSRelease(system.UnderlyingFS()); err == nil {
if name, ok := osRelease["NAME"].(string); ok {
if version, ok := osRelease["VERSION"].(string); ok {
fields = append(fields, "("+name+" "+version+")")
diff --git a/pkg/cmd/initcmd.go b/pkg/cmd/initcmd.go
index b6cd07bd0ea..3935908e131 100644
--- a/pkg/cmd/initcmd.go
+++ b/pkg/cmd/initcmd.go
@@ -208,7 +208,9 @@ func (c *Config) runInitCmd(cmd *cobra.Command, args []string) error {
}
var err error
- c.SourceDirAbsPath, err = c.getSourceDirAbsPath()
+ c.SourceDirAbsPath, err = c.getSourceDirAbsPath(&getSourceDirAbsPathOptions{
+ refresh: true,
+ })
if err != nil {
return err
}
diff --git a/pkg/cmd/sourcepathcmd.go b/pkg/cmd/sourcepathcmd.go
index 961443c7c1b..e149d80ec81 100644
--- a/pkg/cmd/sourcepathcmd.go
+++ b/pkg/cmd/sourcepathcmd.go
@@ -22,7 +22,7 @@ func (c *Config) newSourcePathCmd() *cobra.Command {
func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
- sourceDirAbsPath, err := c.getSourceDirAbsPath()
+ sourceDirAbsPath, err := c.getSourceDirAbsPath(nil)
if err != nil {
return err
}
diff --git a/pkg/cmd/testdata/scripts/scriptenv.txtar b/pkg/cmd/testdata/scripts/scriptenv.txtar
index 8ff629467d6..94bbefd1df2 100644
--- a/pkg/cmd/testdata/scripts/scriptenv.txtar
+++ b/pkg/cmd/testdata/scripts/scriptenv.txtar
@@ -1,15 +1,22 @@
-[!exec:python3] skip 'python3 not found in $PATH'
+[windows] skip 'UNIX only'
# test that chezmoi sets environment variables for scripts
exec chezmoi apply
-stdout VALUE
+stdout ^WORK=${WORK@R}$
+[darwin] stdout ^CHEZMOI_OS=darwin$
+[linux] stdout ^CHEZMOI_OS=linux$
+stdout ^CHEZMOI_SOURCE_DIR=${CHEZMOISOURCEDIR@R}/home$
+stdout ^SCRIPTENV_KEY=SCRIPTENV_VALUE$
-- home/user/.config/chezmoi/chezmoi.toml --
[scriptEnv]
- VARIABLE = "VALUE"
--- home/user/.local/share/chezmoi/run_print-variable.py --
-#!/usr/bin/env python3
+ SCRIPTENV_KEY = "SCRIPTENV_VALUE"
+-- home/user/.local/share/chezmoi/.chezmoiroot --
+home
+-- home/user/.local/share/chezmoi/home/run_print-variable.sh --
+#!/bin/sh
-import os
-
-print(os.getenv("VARIABLE"))
+echo "WORK=${WORK}"
+echo "CHEZMOI_OS=${CHEZMOI_OS}"
+echo "CHEZMOI_SOURCE_DIR=${CHEZMOI_SOURCE_DIR}"
+echo "SCRIPTENV_KEY=${SCRIPTENV_KEY}"
diff --git a/pkg/cmd/testdata/scripts/templatevars.txtar b/pkg/cmd/testdata/scripts/templatevars.txtar
index b7a55b6ff05..6528b164e0a 100644
--- a/pkg/cmd/testdata/scripts/templatevars.txtar
+++ b/pkg/cmd/testdata/scripts/templatevars.txtar
@@ -12,8 +12,8 @@ stdout execute-template
exec chezmoi execute-template '{{ .chezmoi.executable }}'
stdout [\\/]chezmoi(.exe)?$
-exec chezmoi execute-template '{{ .chezmoi.homeDir }}'
-stdout ${HOME@R}
+[!windows] exec chezmoi execute-template '{{ .chezmoi.homeDir }}'
+[!windows] stdout ${HOME@R}
exec chezmoi execute-template '{{ .chezmoi.os }}'
[darwin] stdout darwin
diff --git a/pkg/cmd/upgradecmd.go b/pkg/cmd/upgradecmd.go
index f16ce33a1e4..b64c1ebf92d 100644
--- a/pkg/cmd/upgradecmd.go
+++ b/pkg/cmd/upgradecmd.go
@@ -539,7 +539,7 @@ func getUpgradeMethod(fileSystem vfs.Stater, executableAbsPath chezmoi.AbsPath)
// getPackageType returns the distributions package type based on is OS release.
func getPackageType(system chezmoi.System) (string, error) {
- osRelease, err := chezmoi.OSRelease(system)
+ osRelease, err := chezmoi.OSRelease(system.UnderlyingFS())
if err != nil {
return packageTypeNone, err
}
diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go
index baf1832639e..990bfa2a66d 100644
--- a/pkg/cmd/util.go
+++ b/pkg/cmd/util.go
@@ -26,6 +26,35 @@ var (
}
)
+// camelCaseToUpperSnakeCase converts a string in camelCase to UPPER_SNAKE_CASE.
+func camelCaseToUpperSnakeCase(s string) string {
+ if s == "" {
+ return ""
+ }
+
+ runes := []rune(s)
+ var wordBoundaries []int
+ for i, r := range runes[1:] {
+ if unicode.IsLower(runes[i]) && unicode.IsUpper(r) {
+ wordBoundaries = append(wordBoundaries, i+1)
+ }
+ }
+
+ if len(wordBoundaries) == 0 {
+ return strings.ToUpper(s)
+ }
+
+ wordBoundaries = append(wordBoundaries, len(runes))
+ words := make([]string, 0, len(wordBoundaries))
+ prevWordBoundary := 0
+ for _, wordBoundary := range wordBoundaries {
+ word := string(runes[prevWordBoundary:wordBoundary])
+ words = append(words, strings.ToUpper(word))
+ prevWordBoundary = wordBoundary
+ }
+ return strings.Join(words, "_")
+}
+
// englishList returns ss formatted as a list, including an Oxford comma.
func englishList(ss []string) string {
switch n := len(ss); n {
@@ -107,8 +136,8 @@ func upperSnakeCaseToCamelCase(s string) string {
// upperSnakeCaseToCamelCaseKeys returns m with all keys converted from
// UPPER_SNAKE_CASE to camelCase.
-func upperSnakeCaseToCamelCaseMap(m map[string]any) map[string]any {
- result := make(map[string]any)
+func upperSnakeCaseToCamelCaseMap[V any](m map[string]V) map[string]V {
+ result := make(map[string]V)
for k, v := range m {
result[upperSnakeCaseToCamelCase(k)] = v
}
diff --git a/pkg/cmd/util_test.go b/pkg/cmd/util_test.go
index cd7d4f68a67..669b8e7ca75 100644
--- a/pkg/cmd/util_test.go
+++ b/pkg/cmd/util_test.go
@@ -6,6 +6,35 @@ import (
"github.com/stretchr/testify/assert"
)
+func TestCamelCaseToUpperSnakeCase(t *testing.T) {
+ for _, tc := range []struct {
+ s string
+ expected string
+ }{
+ {
+ "",
+ "",
+ },
+ {
+ "camel",
+ "CAMEL",
+ },
+ {
+ "camelCase",
+ "CAMEL_CASE",
+ },
+ {
+ "bugReportURL",
+ "BUG_REPORT_URL",
+ },
+ } {
+ t.Run(tc.s, func(t *testing.T) {
+ actual := camelCaseToUpperSnakeCase(tc.s)
+ assert.Equal(t, tc.expected, actual)
+ })
+ }
+}
+
func TestEnglishList(t *testing.T) {
for _, tc := range []struct {
ss []string
|
feat
|
Expose template data in environment variables
|
5d2fb13e34e9594ba46bd274f1977a158a232b19
|
2021-10-22 01:43:17
|
Tom Payne
|
feat: Add Illumos support
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d0ba536c082..97867a3b3fa 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -108,6 +108,23 @@ jobs:
- name: Test
run: |
( cd assets/vagrant && ./test.sh openbsd6 )
+ test-openindiana:
+ runs-on: macos-latest
+ env:
+ VAGRANT_BOX: openindiana
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Cache Vagrant Boxes
+ uses: actions/cache@v2
+ with:
+ path: ~/.vagrant.d
+ key: ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-${{ hashFiles('assets/vagrant/*.Vagrantfile') }}
+ restore-keys: |
+ ${{ runner.os }}-vagrant-${{ env.VAGRANT_BOX }}-
+ - name: Test
+ run: |
+ ( cd assets/vagrant && ./test.sh openindiana )
test-ubuntu:
runs-on: ubuntu-18.04
steps:
@@ -169,6 +186,11 @@ jobs:
with:
name: chezmoi-darwin-arm64
path: dist/chezmoi-nocgo_darwin_arm64/chezmoi
+ - name: Upload artifact chezmoi-illumos-amd64
+ uses: actions/upload-artifact@v2
+ with:
+ name: chezmoi-illumos-amd64
+ path: dist/chezmoi-nocgo_illumos_amd64/chezmoi
- name: Upload artifact chezmoi-linux-amd64
uses: actions/upload-artifact@v2
with:
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index b915e7d44a1..f0dc99e0339 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -40,6 +40,7 @@ builds:
env:
- CGO_ENABLED=0
goos:
+ - illumos
- linux
- darwin
- freebsd
diff --git a/Makefile b/Makefile
index 3bc8dd0e854..d1089489a47 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,7 @@ test-docker:
.PHONY: test-vagrant
test-vagrant:
- ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 openbsd6 )
+ ( cd assets/vagrant && ./test.sh debian11-i386 freebsd13 openbsd6 openindiana )
.PHONY: coverage-html
coverage-html: coverage
diff --git a/assets/scripts/install.sh b/assets/scripts/install.sh
index abcea444d90..1267a83ec01 100644
--- a/assets/scripts/install.sh
+++ b/assets/scripts/install.sh
@@ -142,6 +142,7 @@ check_goos_goarch() {
freebsd/amd64) return 0 ;;
freebsd/arm) return 0 ;;
freebsd/arm64) return 0 ;;
+ illumos/amd64) return 0 ;;
linux/386) return 0 ;;
linux/amd64) return 0 ;;
linux/arm) return 0 ;;
diff --git a/assets/vagrant/openindiana.Vagrantfile b/assets/vagrant/openindiana.Vagrantfile
new file mode 100644
index 00000000000..c9b30cbe522
--- /dev/null
+++ b/assets/vagrant/openindiana.Vagrantfile
@@ -0,0 +1,9 @@
+Vagrant.configure("2") do |config|
+ config.vm.box = "openindiana/hipster"
+ config.vm.box_version = "202109"
+ config.vm.synced_folder ".", "/chezmoi", type: "rsync"
+ config.vm.provision "shell", inline: <<-SHELL
+ pkg install -q compress/zip developer/gcc-7 developer/golang developer/versioning/git
+ SHELL
+ config.vm.provision "file", source: "assets/vagrant/openindiana.test-chezmoi.sh", destination: "test-chezmoi.sh"
+end
diff --git a/assets/vagrant/openindiana.test-chezmoi.sh b/assets/vagrant/openindiana.test-chezmoi.sh
new file mode 100755
index 00000000000..a27de7948e0
--- /dev/null
+++ b/assets/vagrant/openindiana.test-chezmoi.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+set -eufo pipefail
+
+( cd /chezmoi && go test ./... )
diff --git a/docs/INSTALL.md b/docs/INSTALL.md
index 0832c1c360f..fd998e6814d 100644
--- a/docs/INSTALL.md
+++ b/docs/INSTALL.md
@@ -92,6 +92,7 @@ documentation, and shell completions.
| OS | Architectures | Archive |
| ---------- | --------------------------------------------------- | -------------------------------------------------------------- |
| FreeBSD | `amd64`, `arm`, `arm64`, `i386` | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
+| Illumos | `amd64` | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
| Linux | `amd64`, `arm`, `arm64`, `i386`, `ppc64`, `ppc64le` | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
| macOS | `amd64`, `arm64` | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
| OpenBSD | `amd64`, `arm`, `arm64`, `i386` | [`tar.gz`](https://github.com/twpayne/chezmoi/releases/latest) |
diff --git a/go.sum b/go.sum
index 153299d3d95..fc88b437987 100644
--- a/go.sum
+++ b/go.sum
@@ -22,31 +22,41 @@ cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAV
cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM=
cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY=
cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ=
+cloud.google.com/go v0.93.3 h1:wPBktZFzYBcCZVARvwVKqH1uEj+aLXofJEtrb4oOsio=
cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
+cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/firestore v1.6.0 h1:dMIWvm+3O0E3DM7kcZPH0FBQ94Xg/OMkdTNDaY9itbI=
cloud.google.com/go/firestore v1.6.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
+cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
+cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/age v1.0.0 h1:V6q14n0mqYU3qKFkZ6oOaF9oXneOviS3ubXsSVBRSzc=
filippo.io/age v1.0.0/go.mod h1:PaX+Si/Sd5G8LgfCwldsSba3H1DDQZhIhFGkhbHaBq8=
+filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
@@ -59,31 +69,42 @@ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugX
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
+github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7 h1:DSqTh6nEes/uO8BlNcGk8PzZsxY2sN9ZL//veWBdTRI=
github.com/ProtonMail/go-crypto v0.0.0-20210920160938-87db9fbc61c7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
+github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.8.2/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
github.com/alecthomas/chroma v0.9.4 h1:YL7sOAE3p8HS96T9km7RgvmsZIctqbK1qJ0b7hzed44=
github.com/alecthomas/chroma v0.9.4/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
+github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
+github.com/alecthomas/kong v0.2.4 h1:Y0ZBCHAvHhTHw7FFJ2FzCAAG4pkbTgA45nc7BpMhDNk=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
+github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
+github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
+github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bketelsen/crypt v0.0.4 h1:w/jqZtC9YD4DS/Vp9GhWfWcCpuAL58oTnLoI8vE9YHU=
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/bmatcuk/doublestar/v4 v4.0.2 h1:X0krlUVAVmtr2cRoTqR8aDMrDqnB36ht8wpWTiQ3jsA=
github.com/bmatcuk/doublestar/v4 v4.0.2/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
@@ -91,26 +112,38 @@ github.com/bradenhilton/cityhash v1.0.0 h1:1QauDCwfxwIGwO2jBTJdEBqXgfCusAgQOSgdl
github.com/bradenhilton/cityhash v1.0.0/go.mod h1:Wmb8yW1egA9ulrsRX4mxfYx5zq4nBWOCZ+j63oK6uz8=
github.com/bradenhilton/mozillainstallhash v1.0.0 h1:QL9byVGb4FrVOI7MubnME3uPNj5R78tqYQPlxuBmXMw=
github.com/bradenhilton/mozillainstallhash v1.0.0/go.mod h1:yVD0OX1izZHYl1lBm2UDojyE/k0xIqKJK78k+tdWV+k=
+github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/charmbracelet/glamour v0.3.0 h1:3H+ZrKlSg8s+WU6V7eF2eRVYt8lCueffbi7r2+ffGkc=
github.com/charmbracelet/glamour v0.3.0/go.mod h1:TzF0koPZhqq0YVBNL100cPHznAAjVj7fksX2RInwjGw=
+github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed h1:OZmjad4L3H8ncOIR8rnb5MREYqG8ixi5+WbeUsquF0c=
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
+github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
+github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -126,14 +159,19 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0 h1:dulLQAYQFYtG5MTplgNGHWuV2D+OBD+Z8lmDBmbLg+s=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
+github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
+github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
+github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
@@ -146,17 +184,22 @@ github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2Su
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.5 h1:9Eg0XUhQxtkV8ykTMKtMMYY72g4NgxtRq4jgh4Ih5YM=
github.com/godbus/dbus/v5 v5.0.5/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -166,6 +209,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -185,8 +229,10 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -205,10 +251,13 @@ github.com/google/go-github/v39 v39.2.0 h1:rNNM311XtPOz5rDdsJXAp2o8F67X9FnROXTvt
github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
+github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ=
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
@@ -223,6 +272,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
@@ -234,44 +284,66 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/googleapis/gax-go/v2 v2.1.0 h1:6DWmvNpomjL1+3liNSZbVns3zsYzzCjm6pRBO1tLeso=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
+github.com/hashicorp/consul/api v1.10.1 h1:MwZJp86nlnL+6+W1Zly4JUuVn9YHhMggBirMpHGD7kw=
github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU=
github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
+github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM=
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
+github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI=
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
+github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
+github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go.net v0.0.1 h1:sNCoNyDEvN1xa+X0baata4RdcpKwcMS6DH+xwfqPgjw=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
+github.com/hashicorp/mdns v1.0.1 h1:XFSOubp8KWB+Jd2PDyaX5xUd5bhSP/+pTDZVDMzZJM8=
github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/memberlist v0.2.2 h1:5+RffWKwqJ71YPu9mWsF7ZOscZmwfasdA8kbdC7AO2g=
github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
+github.com/hashicorp/serf v0.9.5 h1:EBWvyu9tcRszt3Bxp3KNssBMP1KuHWyO51lz9+786iM=
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
@@ -281,22 +353,31 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
+github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kevinburke/ssh_config v1.1.0 h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o=
github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -309,6 +390,7 @@ github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
+github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
@@ -327,8 +409,10 @@ github.com/microcosm-cc/bluemonday v1.0.6/go.mod h1:HOT/6NaBlR0f9XlxD3zolN6Z3N8L
github.com/microcosm-cc/bluemonday v1.0.16 h1:kHmAq2t7WPWLjiGvzKa5o3HzSfahUKiOq7fAPUiMNIc=
github.com/microcosm-cc/bluemonday v1.0.16/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/miekg/dns v1.1.26 h1:gPxPSwALAeHJSjarOs00QjVdV9QoBvc1D2ujQUr5BzU=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
+github.com/mitchellh/cli v1.1.0 h1:tEElEatulEHDeedTxwckzyYMA5c86fbmNIUL1hBIiTg=
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -336,8 +420,11 @@ github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HK
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
+github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
@@ -347,8 +434,10 @@ github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/muesli/combinator v0.3.0 h1:SZDuRzzwmVPLkbOzbhGzBTwd5+Y6aFN4UusOW2azrNA=
github.com/muesli/combinator v0.3.0/go.mod h1:ttPegJX0DPQaGDtJKMInIP6Vfp5pN8RX7QntFCcpy18=
@@ -358,9 +447,11 @@ github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKt
github.com/muesli/termenv v0.8.1/go.mod h1:kzt/D/4a88RoheZmwfqorY3A+tnsSMA9HJC/fQSFKo0=
github.com/muesli/termenv v0.9.0 h1:wnbOaGz+LUR3jNT0zOzinPnyDaCZUQRZj9GxK8eRVl8=
github.com/muesli/termenv v0.9.0/go.mod h1:R/LzAKf+suGs4IsO95y7+7DpFHO0KABgnZqtlyx2mBw=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
@@ -370,25 +461,34 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/sftp v1.10.1 h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
+github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
+github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.25.0 h1:Rj7XygbUHKUlDPcVdoLyR91fJBsduXj5fRxyqIQj/II=
github.com/rs/zerolog v1.25.0/go.mod h1:7KHcEGe0QZPOm2IE4Kpb5rTh6n1h2hIgS5OOnu1rUaI=
+github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f h1:UFr9zpz4xgTnIE5yIMtWAMngCdZ9p/+q6lTbgelo80M=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/sagikazarmark/crypt v0.1.0 h1:AyO7PGna28P9TMH93Bsxd7m9QC4xE6zyGQTXCo7ZrA8=
github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE=
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
@@ -396,11 +496,16 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.0 h1:KK3gWIXskZ2O1U/JNTisNcvH+jveJxZYrjbTsrbbnh8=
github.com/shopspring/decimal v1.3.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
+github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
@@ -454,8 +559,11 @@ github.com/zalando/go-keyring v0.1.1 h1:w2V9lcx/Uj4l+dzAf1m9s+DJ1O8ROkEHnynonHjT
github.com/zalando/go-keyring v0.1.1/go.mod h1:OIC+OZ28XbmwFxU/Rp9V7eKzZjamBJwRzC8UFJH9+L8=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
+go.etcd.io/etcd/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
+go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/6PU=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
+go.etcd.io/etcd/client/v2 v2.305.0 h1:ftQ0nOOHMcbMS3KIaDQ0g5Qcd6bhaBrQT6b89DfwLTs=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
@@ -463,7 +571,9 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
+go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
+go.opentelemetry.io/proto/otlp v0.7.0 h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
@@ -471,6 +581,7 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
+go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -497,8 +608,10 @@ golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
+golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -511,8 +624,10 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
@@ -522,6 +637,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -594,6 +710,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -679,6 +796,7 @@ golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -735,6 +853,7 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -768,6 +887,7 @@ google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtuk
google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw=
google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU=
google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k=
+google.golang.org/api v0.56.0 h1:08F9XVYTLOGeSQb3xI9C0gXMuQanhdGed0cWFhDozbI=
google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@@ -828,6 +948,7 @@ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKr
google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w=
google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
+google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs=
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
@@ -853,7 +974,9 @@ google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
+google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
+google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
@@ -899,9 +1022,13 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v0.0.0-20201203080718-1454fab16a06 h1:QDxUo/w2COstK1wIBYpzQlHX/NqaQTcf9jyz347nI58=
howett.net/plist v0.0.0-20201203080718-1454fab16a06/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
+rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
+rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/internal/cmd/testdata/scripts/archivetar.txt b/internal/cmd/testdata/scripts/archivetar.txt
index 591143bb548..c39f27e6dff 100644
--- a/internal/cmd/testdata/scripts/archivetar.txt
+++ b/internal/cmd/testdata/scripts/archivetar.txt
@@ -4,12 +4,14 @@ mksourcedir
chezmoi archive --output=archive.tar
exec tar -tf archive.tar
-[!openbsd] cmp stdout golden/archive-tar
+[!(illumos||openbsd)] cmp stdout golden/archive-tar
+[illumos] cmp stdout golden/archive-tar-illumos
[openbsd] cmp stdout golden/archive-tar-openbsd
chezmoi archive --gzip --output=archive.tar.gz
exec tar -tzf archive.tar.gz
-[!openbsd] cmp stdout golden/archive-tar
+[!(illumos||openbsd)] cmp stdout golden/archive-tar
+[illumos] cmp stdout golden/archive-tar-illumos
[openbsd] cmp stdout golden/archive-tar-openbsd
-- golden/archive-tar --
@@ -25,6 +27,19 @@ exec tar -tzf archive.tar.gz
.readonly
.symlink
.template
+-- golden/archive-tar-illumos --
+.create
+.dir/
+.dir/file
+.dir/subdir/
+.dir/subdir/file
+.empty
+.executable
+.file
+.private
+.readonly
+.symlink symbolic link to .dir/subdir/file
+.template
-- golden/archive-tar-openbsd --
.create
.dir
diff --git a/internal/cmd/testdata/scripts/templatefuncs.txt b/internal/cmd/testdata/scripts/templatefuncs.txt
index 7408c3c5bca..c4d9f234b70 100644
--- a/internal/cmd/testdata/scripts/templatefuncs.txt
+++ b/internal/cmd/testdata/scripts/templatefuncs.txt
@@ -40,7 +40,8 @@ stdout 2656FF1E876E9973
# test that the output function returns an error if the command fails
[!windows] ! chezmoi execute-template '{{ output "false" }}'
-[!windows] stderr 'error calling output: exit status 1'
+[!(windows||illumos)] stderr 'error calling output: exit status 1'
+[illumos] stderr 'error calling output: exit status 255'
# test stat template function
chezmoi execute-template '{{ (stat ".").isDir }}'
|
feat
|
Add Illumos support
|
d73ac6e386bed43846d966eb6580cdaef18f4712
|
2022-02-23 05:29:07
|
Tom Payne
|
chore: Use pip3, not pip, to install MkDocs dependencies
| false
|
diff --git a/assets/chezmoi.io/docs/developer/website.md b/assets/chezmoi.io/docs/developer/website.md
index 6acac64aca8..6d0328b9aad 100644
--- a/assets/chezmoi.io/docs/developer/website.md
+++ b/assets/chezmoi.io/docs/developer/website.md
@@ -8,7 +8,7 @@ the [`gh-pages` branch](https://github.com/twpayne/chezmoi/tree/gh-pages).
Install Material for MkDocs and the required plugins with:
```console
-$ pip install mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks
+$ pip3 install mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks
```
Test the website locally by running:
|
chore
|
Use pip3, not pip, to install MkDocs dependencies
|
66070dcf58bc4e47dfdddfb5149b926f459d5059
|
2023-09-26 16:24:02
|
N3WK1D
|
docs: Added an example for promptChoice
| false
|
diff --git a/assets/chezmoi.io/docs/reference/templates/init-functions/promptChoice.md b/assets/chezmoi.io/docs/reference/templates/init-functions/promptChoice.md
index 2c292b4d185..9df5cdb5ce6 100644
--- a/assets/chezmoi.io/docs/reference/templates/init-functions/promptChoice.md
+++ b/assets/chezmoi.io/docs/reference/templates/init-functions/promptChoice.md
@@ -1,3 +1,12 @@
# `promptChoice` *prompt* *choices* [*default*]
`promptChoice` prompts the user with *prompt* and *choices* and returns the user's response. *choices* must be a list of strings. If *default* is passed and the user's response is empty then it returns *default*.
+
+!!! example
+
+ ```
+ {{- $choices := list "desktop" "server" -}}
+ {{- $hosttype := promptChoice "What type of host are you on" $choices -}}
+ [data]
+ hosttype = {{- $hosttype | quote -}}
+ ```
|
docs
|
Added an example for promptChoice
|
cbc2f1e7222b51f8f7f1e4bbdb2ef433a2c85eb7
|
2021-09-28 01:02:12
|
Tom Payne
|
docs: Add FAQ entry on diff colors not working
| false
|
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 5cf5b5ebcad..450980fb08e 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -17,6 +17,7 @@
* [Why doesn't chezmoi use symlinks like GNU Stow?](#why-doesnt-chezmoi-use-symlinks-like-gnu-stow)
* [What are the limitations of chezmoi's symlink mode?](#what-are-the-limitations-of-chezmois-symlink-mode)
* [Can I change how chezmoi's source state is represented on disk?](#can-i-change-how-chezmois-source-state-is-represented-on-disk)
+ * [The output of `chezmoi diff` is broken and does not contain color. What could be wrong?](#the-output-of-chezmoi-diff-is-broken-and-does-not-contain-color-what-could-be-wrong)
* [gpg encryption fails. What could be wrong?](#gpg-encryption-fails-what-could-be-wrong)
* [chezmoi reports `chezmoi: user: lookup userid NNNNN: input/output error`](#chezmoi-reports-chezmoi-user-lookup-userid-nnnnn-inputoutput-error)
* [chezmoi reports `chezmoi: timeout` or `chezmoi: timeout obtaining persistent state lock`](#chezmoi-reports-chezmoi-timeout-or-chezmoi-timeout-obtaining-persistent-state-lock)
@@ -355,6 +356,39 @@ but must meet the following criteria, in order of importance:
---
+### The output of `chezmoi diff` is broken and does not contain color. What could be wrong?
+
+By default, chezmoi's diff output includes ANSI color escape sequences (e.g.
+`ESC[37m`) and is piped into your pager (by default `less`). chezmoi assumes
+that your pager passes through the ANSI color escape sequences, as configured on
+many systems, but not all. If your pager does not pass through ANSI color escape
+sequences then you will see monochrome diff output with uninterpreted ANSI color
+escape sequences.
+
+This can typically by fixed by setting the environment variable
+
+```console
+$ export LESS=-R
+```
+
+which instructs `less` to display "raw" control characters via the `-R` /
+`--RAW-CONTROL-CHARS` option.
+
+You can also set the `pager` configuration variable in your config file, for
+example:
+
+```toml
+pager = "less -R"
+```
+
+If you have set a different pager (via the `pager` configuration variable or
+`PAGER` environment variable) then you must ensure that it passes through raw
+control characters. Alternatively, you can use the `--color=false` option to
+chezmoi to disable colors or the `--no-pager` option to chezmoi to disable the
+pager.
+
+---
+
## gpg encryption fails. What could be wrong?
The `gpg.recipient` key should be ultimately trusted, otherwise encryption will
|
docs
|
Add FAQ entry on diff colors not working
|
39de9bcd96326c7731b9688b249a6d92833e4cda
|
2024-05-25 19:58:05
|
Tom Payne
|
chore: Update tools
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c5f980dbaff..54fa2b025c9 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ on:
schedule:
- cron: 32 2 * * *
env:
- ACTIONLINT_VERSION: 1.6.27 # https://github.com/rhysd/actionlint/releases
+ ACTIONLINT_VERSION: 1.7.0 # https://github.com/rhysd/actionlint/releases
AGE_VERSION: 1.1.1 # https://github.com/FiloSottile/age/releases
CHOCOLATEY_VERSION: 2.2.2 # https://github.com/chocolatey/choco/releases
EDITORCONFIG_CHECKER_VERSION: 3.0.1 # https://github.com/editorconfig-checker/editorconfig-checker/releases
@@ -20,7 +20,7 @@ env:
GOFUMPT_VERSION: 0.6.0 # https://github.com/mvdan/gofumpt/releases
GOLANGCI_LINT_VERSION: 1.58.2 # https://github.com/golangci/golangci-lint/releases
GOLINES_VERSION: 0.12.2 # https://github.com/segmentio/golines/releases
- GORELEASER_VERSION: 1.26.0 # https://github.com/goreleaser/goreleaser/releases
+ GORELEASER_VERSION: 1.26.2 # https://github.com/goreleaser/goreleaser/releases
GOVERSIONINFO_VERSION: 1.4.0 # https://github.com/josephspurrier/goversioninfo/releases
RAGE_VERSION: 0.10.0 # https://github.com/str4d/rage/releases
jobs:
|
chore
|
Update tools
|
83ea50af8c31438aec1e682b331a15aa70b0ba7f
|
2022-12-01 23:32:11
|
dependabot[bot]
|
chore(deps): bump reviewdog/action-misspell from 1.12.2 to 1.12.3
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 07a5cdd3c57..b2036e2343c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- - uses: reviewdog/action-misspell@811b1e15f531430be3a5784e3d591bd657df18b0
+ - uses: reviewdog/action-misspell@fe8d5c98c3761ef40755a7bb95460b2a33f6b346
with:
locale: US
test-alpine:
|
chore
|
bump reviewdog/action-misspell from 1.12.2 to 1.12.3
|
5d568f2e7a97fa3a6de8f683ffbd39c708095323
|
2024-10-30 20:36:55
|
Ruslan Sayfutdinov
|
fix: Perform post-run actions on error
| false
|
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index a85baa3f5b5..f2344f21d06 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -1642,6 +1642,8 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
SilenceUsage: true,
}
+ cobra.OnFinalize(c.finalizeRootCmd)
+
persistentFlags := rootCmd.PersistentFlags()
persistentFlags.Var(&c.CacheDirAbsPath, "cache", "Set cache directory")
@@ -1846,27 +1848,7 @@ func (c *Config) newSourceState(
func (c *Config) persistentPostRunRootE(cmd *cobra.Command, args []string) error {
annotations := getAnnotations(cmd)
- if err := c.persistentState.Close(); err != nil {
- return err
- }
-
- // Close any connection to keepassxc-cli.
- if err := c.keepassxcClose(); err != nil {
- return err
- }
-
- // Wait for any diff pager process to terminate.
- if c.diffPagerCmd != nil {
- if err := c.diffPagerCmdStdin.Close(); err != nil {
- return err
- }
- if c.diffPagerCmd.Process != nil {
- if err := chezmoilog.LogCmdWait(c.logger, c.diffPagerCmd); err != nil {
- return err
- }
- }
- }
-
+ // Verify modified config
if annotations.hasTag(modifiesConfigFile) {
configFileContents, err := c.baseSystem.ReadFile(c.getConfigFileAbsPath())
switch {
@@ -1890,6 +1872,7 @@ func (c *Config) persistentPostRunRootE(cmd *cobra.Command, args []string) error
}
}
+ // Perform auto git commands
if annotations.hasTag(modifiesSourceDirectory) {
var status *chezmoigit.Status
if c.Git.AutoAdd || c.Git.AutoCommit || c.Git.AutoPush {
@@ -1911,17 +1894,43 @@ func (c *Config) persistentPostRunRootE(cmd *cobra.Command, args []string) error
}
}
+ if err := c.runHookPost(cmd.Name()); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// persistentPostRunRootE is not run if command returns error, perform cleanup here.
+func (c *Config) finalizeRootCmd() {
+ if c.persistentState != nil {
+ if err := c.persistentState.Close(); err != nil {
+ c.errorf("error: failed to close persistent state: %v\n", err)
+ }
+ }
+
+ // Wait for any diff pager process to terminate.
+ if c.diffPagerCmd != nil {
+ if err := c.diffPagerCmdStdin.Close(); err != nil {
+ c.errorf("error: failed to close diff pager stdin: %v\n", err)
+ }
+ if c.diffPagerCmd.Process != nil {
+ if err := chezmoilog.LogCmdWait(c.logger, c.diffPagerCmd); err != nil {
+ c.errorf("error: failed to wait for diff pager to close: %v\n", err)
+ }
+ }
+ }
+
if c.restoreWindowsConsole != nil {
if err := c.restoreWindowsConsole(); err != nil {
- return err
+ c.errorf("error: failed to restore console: %v\n", err)
}
}
- if err := c.runHookPost(cmd.Name()); err != nil {
- return err
+ // Close any connection to keepassxc-cli.
+ if err := c.keepassxcClose(); err != nil {
+ c.errorf("error: failed to close connection to keepassxc-cli: %v\n", err)
}
-
- return nil
}
// pageDiffOutput pages the diff output to stdout.
|
fix
|
Perform post-run actions on error
|
4db2fe2af4775c585c3ddfbc47b53cf32751ef43
|
2023-12-12 04:55:46
|
Tom Payne
|
chore: Update dependencies
| false
|
diff --git a/go.mod b/go.mod
index 06875897d46..cdc68e5f921 100644
--- a/go.mod
+++ b/go.mod
@@ -8,10 +8,10 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1
github.com/Masterminds/sprig/v3 v3.2.3
github.com/Shopify/ejson v1.4.1
- github.com/alecthomas/assert/v2 v2.4.0
- github.com/aws/aws-sdk-go-v2 v1.23.5
- github.com/aws/aws-sdk-go-v2/config v1.25.11
- github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.2
+ github.com/alecthomas/assert/v2 v2.4.1
+ github.com/aws/aws-sdk-go-v2 v1.24.0
+ github.com/aws/aws-sdk-go-v2/config v1.26.1
+ github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.5
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/bradenhilton/mozillainstallhash v1.0.1
github.com/charmbracelet/bubbles v0.16.1
@@ -19,7 +19,7 @@ require (
github.com/charmbracelet/glamour v0.6.0
github.com/coreos/go-semver v0.3.1
github.com/fsnotify/fsnotify v1.7.0
- github.com/go-git/go-git/v5 v5.10.1
+ github.com/go-git/go-git/v5 v5.11.0
github.com/google/go-github/v57 v57.0.0
github.com/google/renameio/v2 v2.0.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
@@ -45,7 +45,7 @@ require (
github.com/zalando/go-keyring v0.2.3
go.etcd.io/bbolt v1.3.8
golang.org/x/crypto v0.16.0
- golang.org/x/exp v0.0.0-20231127185646-65229373498e
+ golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb
golang.org/x/oauth2 v0.15.0
golang.org/x/sync v0.5.0
golang.org/x/sys v0.15.0
@@ -58,8 +58,8 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
- github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 // indirect
- github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect
+ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 // indirect
+ github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
@@ -70,17 +70,17 @@ require (
github.com/alecthomas/repr v0.3.0 // indirect
github.com/alessio/shellescape v1.4.2 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
- github.com/aws/aws-sdk-go-v2/credentials v1.16.9 // indirect
- github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.9 // indirect
- github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.8 // indirect
- github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.8 // indirect
- github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 // indirect
- github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.3 // indirect
- github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.8 // indirect
- github.com/aws/aws-sdk-go-v2/service/sso v1.18.2 // indirect
- github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.2 // indirect
- github.com/aws/aws-sdk-go-v2/service/sts v1.26.2 // indirect
- github.com/aws/smithy-go v1.18.1 // indirect
+ github.com/aws/aws-sdk-go-v2/credentials v1.16.12 // indirect
+ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 // indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 // indirect
+ github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 // indirect
+ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect
+ github.com/aws/aws-sdk-go-v2/service/sts v1.26.5 // indirect
+ github.com/aws/smithy-go v1.19.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/bradenhilton/cityhash v1.0.0 // indirect
diff --git a/go.sum b/go.sum
index e72242aa6c6..5d97ee68096 100644
--- a/go.sum
+++ b/go.sum
@@ -8,12 +8,12 @@ filippo.io/age v1.1.1 h1:pIpO7l151hCnQ4BdyBujnGP2YlUo0uj6sAVNHGBvXHg=
filippo.io/age v1.1.1/go.mod h1:l03SrzDUrBkdBx8+IILdnn2KZysqQdbEBUQ4p3sqEQE=
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q=
+github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ=
+github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs=
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs=
-github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI=
+github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA=
+github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1 h1:8TkzQBrN9PWIwo7ekdd696KpC6IfTltV2/F8qKKBWik=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1/go.mod h1:aprFpXPQiTyG5Rkz6Ot5pvU6y6YKg/AKYOcLCoxN0bk=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80=
@@ -34,8 +34,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/Shopify/ejson v1.4.1 h1:zGGojGJNTdIWza/kOT8gd2HKCg3ZkSi3CZ1ZX70NHsw=
github.com/Shopify/ejson v1.4.1/go.mod h1:VZMUtDzvBW/PAXRUF5fzp1ffb1ucT8MztrZXXLYZurw=
-github.com/alecthomas/assert/v2 v2.4.0 h1:/ZiZ0NnriAWPYYO+4eOjgzNELrFQLaHNr92mHSHFj9U=
-github.com/alecthomas/assert/v2 v2.4.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM=
+github.com/alecthomas/assert/v2 v2.4.1 h1:mwPZod/d35nlaCppr6sFP0rbCL05WH9fIo7lvsf47zo=
+github.com/alecthomas/assert/v2 v2.4.1/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8=
@@ -48,34 +48,34 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
-github.com/aws/aws-sdk-go-v2 v1.23.5 h1:xK6C4udTyDMd82RFvNkDQxtAd00xlzFUtX4fF2nMZyg=
-github.com/aws/aws-sdk-go-v2 v1.23.5/go.mod h1:t3szzKfP0NeRU27uBFczDivYJjsmSnqI8kIvKyWb9ds=
-github.com/aws/aws-sdk-go-v2/config v1.25.11 h1:RWzp7jhPRliIcACefGkKp03L0Yofmd2p8M25kbiyvno=
-github.com/aws/aws-sdk-go-v2/config v1.25.11/go.mod h1:BVUs0chMdygHsQtvaMyEOpW2GIW+ubrxJLgIz/JU29s=
-github.com/aws/aws-sdk-go-v2/credentials v1.16.9 h1:LQo3MUIOzod9JdUK+wxmSdgzLVYUbII3jXn3S/HJZU0=
-github.com/aws/aws-sdk-go-v2/credentials v1.16.9/go.mod h1:R7mDuIJoCjH6TxGUc/cylE7Lp/o0bhKVoxdBThsjqCM=
-github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.9 h1:FZVFahMyZle6WcogZCOxo6D/lkDA2lqKIn4/ueUmVXw=
-github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.9/go.mod h1:kjq7REMIkxdtcEC9/4BVXjOsNY5isz6jQbEgk6osRTU=
-github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.8 h1:8GVZIR0y6JRIUNSYI1xAMF4HDfV8H/bOsZ/8AD/uY5Q=
-github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.8/go.mod h1:rwBfu0SoUkBUZndVgPZKAD9Y2JigaZtRP68unRiYToQ=
-github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.8 h1:ZE2ds/qeBkhk3yqYvS3CDCFNvd9ir5hMjlVStLZWrvM=
-github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.8/go.mod h1:/lAPPymDYL023+TS6DJmjuL42nxix2AvEvfjqOBRODk=
-github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 h1:uR9lXYjdPX0xY+NhvaJ4dD8rpSRz5VY81ccIIoNG+lw=
-github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY=
-github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.3 h1:e3PCNeEaev/ZF01cQyNZgmYE9oYYePIMJs2mWSKG514=
-github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.3/go.mod h1:gIeeNyaL8tIEqZrzAnTeyhHcE0yysCtcaP+N9kxLZ+E=
-github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.8 h1:EamsKe+ZjkOQjDdHd86/JCEucjFKQ9T0atWKO4s2Lgs=
-github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.8/go.mod h1:Q0vV3/csTpbkfKLI5Sb56cJQTCTtJ0ixdb7P+Wedqiw=
-github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.2 h1:JKbfiLwEqJp8zaOAOn6AVSMS96gdwP3TjBMvZYsbxqE=
-github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.2/go.mod h1:pbBOMK8UicdDK11zsPSGbpFh9Xwbd1oD3t7pSxXgNxU=
-github.com/aws/aws-sdk-go-v2/service/sso v1.18.2 h1:xJPydhNm0Hiqct5TVKEuHG7weC0+sOs4MUnd7A5n5F4=
-github.com/aws/aws-sdk-go-v2/service/sso v1.18.2/go.mod h1:zxk6y1X2KXThESWMS5CrKRvISD8mbIMab6nZrCGxDG0=
-github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.2 h1:8dU9zqA77C5egbU6yd4hFLaiIdPv3rU+6cp7sz5FjCU=
-github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.2/go.mod h1:7Lt5mjQ8x5rVdKqg+sKKDeuwoszDJIIPmkd8BVsEdS0=
-github.com/aws/aws-sdk-go-v2/service/sts v1.26.2 h1:fFrLsy08wEbAisqW3KDl/cPHrF43GmV79zXB9EwJiZw=
-github.com/aws/aws-sdk-go-v2/service/sts v1.26.2/go.mod h1:7Ld9eTqocTvJqqJ5K/orbSDwmGcpRdlDiLjz2DO+SL8=
-github.com/aws/smithy-go v1.18.1 h1:pOdBTUfXNazOlxLrgeYalVnuTpKreACHtc62xLwIB3c=
-github.com/aws/smithy-go v1.18.1/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE=
+github.com/aws/aws-sdk-go-v2 v1.24.0 h1:890+mqQ+hTpNuw0gGP6/4akolQkSToDJgHfQE7AwGuk=
+github.com/aws/aws-sdk-go-v2 v1.24.0/go.mod h1:LNh45Br1YAkEKaAqvmE1m8FUx6a5b/V0oAKV7of29b4=
+github.com/aws/aws-sdk-go-v2/config v1.26.1 h1:z6DqMxclFGL3Zfo+4Q0rLnAZ6yVkzCRxhRMsiRQnD1o=
+github.com/aws/aws-sdk-go-v2/config v1.26.1/go.mod h1:ZB+CuKHRbb5v5F0oJtGdhFTelmrxd4iWO1lf0rQwSAg=
+github.com/aws/aws-sdk-go-v2/credentials v1.16.12 h1:v/WgB8NxprNvr5inKIiVVrXPuuTegM+K8nncFkr1usU=
+github.com/aws/aws-sdk-go-v2/credentials v1.16.12/go.mod h1:X21k0FjEJe+/pauud82HYiQbEr9jRKY3kXEIQ4hXeTQ=
+github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 h1:w98BT5w+ao1/r5sUuiH6JkVzjowOKeOJRHERyy1vh58=
+github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10/go.mod h1:K2WGI7vUvkIv1HoNbfBA1bvIZ+9kL3YVmWxeKuLQsiw=
+github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 h1:v+HbZaCGmOwnTTVS86Fleq0vPzOd7tnJGbFhP0stNLs=
+github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9/go.mod h1:Xjqy+Nyj7VDLBtCMkQYOw1QYfAEZCVLrfI0ezve8wd4=
+github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 h1:N94sVhRACtXyVcjXxrwK1SKFIJrA9pOJ5yu2eSHnmls=
+github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9/go.mod h1:hqamLz7g1/4EJP+GH5NBhcUMLjW+gKLQabgyz6/7WAU=
+github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 h1:GrSw8s0Gs/5zZ0SX+gX4zQjRnRsMJDJ2sLur1gRBhEM=
+github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY=
+github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 h1:/b31bi3YVNlkzkBrm9LfpaKoaYZUxIAj4sHfOTmLfqw=
+github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4/go.mod h1:2aGXHFmbInwgP9ZfpmdIfOELL79zhdNYNmReK8qDfdQ=
+github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 h1:Nf2sHxjMJR8CSImIVCONRi4g0Su3J+TSTbS7G0pUeMU=
+github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9/go.mod h1:idky4TER38YIjr2cADF1/ugFMKvZV7p//pVeV5LZbF0=
+github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.5 h1:qYi/BfDrWXZxlmRjlKCyFmtI4HKJwW8OKDKhKRAOZQI=
+github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.5/go.mod h1:4Ae1NCLK6ghmjzd45Tc33GgCKhUWD2ORAlULtMO1Cbs=
+github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 h1:ldSFWz9tEHAwHNmjx2Cvy1MjP5/L9kNoR0skc6wyOOM=
+github.com/aws/aws-sdk-go-v2/service/sso v1.18.5/go.mod h1:CaFfXLYL376jgbP7VKC96uFcU8Rlavak0UlAwk1Dlhc=
+github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 h1:2k9KmFawS63euAkY4/ixVNsYYwrwnd5fIvgEKkfZFNM=
+github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5/go.mod h1:W+nd4wWDVkSUIox9bacmkBP5NMFQeTJ/xqNabpzSR38=
+github.com/aws/aws-sdk-go-v2/service/sts v1.26.5 h1:5UYvv8JUvllZsRnfrcMQ+hJ9jNICmcgKPAO1CER25Wg=
+github.com/aws/aws-sdk-go-v2/service/sts v1.26.5/go.mod h1:XX5gh4CB7wAs4KhcF46G6C8a2i7eupU19dcAAE+EydU=
+github.com/aws/smithy-go v1.19.0 h1:KWFKQV80DpP3vJrrA9sVAHQ5gc2z8i4EzrLhLlWXcBM=
+github.com/aws/smithy-go v1.19.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE=
github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg=
github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
@@ -145,8 +145,8 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
-github.com/go-git/go-git/v5 v5.10.1 h1:tu8/D8i+TWxgKpzQ3Vc43e+kkhXqtsZCKI/egajKnxk=
-github.com/go-git/go-git/v5 v5.10.1/go.mod h1:uEuHjxkHap8kAl//V5F/nNWwqIYtP/402ddd05mp0wg=
+github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
+github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -367,8 +367,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
-golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No=
-golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
+golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8=
+golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
chore
|
Update dependencies
|
cb8624415f095efd73b7ae91af71274c7537fa29
|
2024-11-19 22:41:06
|
mohamedhany01
|
docs: Add article info
| false
|
diff --git a/assets/chezmoi.io/docs/links/articles.md.yaml b/assets/chezmoi.io/docs/links/articles.md.yaml
index 2a9c7cbc205..15b3d0343ba 100644
--- a/assets/chezmoi.io/docs/links/articles.md.yaml
+++ b/assets/chezmoi.io/docs/links/articles.md.yaml
@@ -462,3 +462,8 @@ articles:
version: 2.53.1
title: 'dotfiles management: chezmoi'
url: https://blg.gkr.one/20241107-chezmoi/
+- date: '2024-11-19'
+ version: 2.54.0
+ lang: AR
+ title: شيموا (chezmoi) ببساطة
+ url: https://github.com/mohamedhany01/chezmoi-tutorial-arabic
|
docs
|
Add article info
|
b3ddde76036a9058838fdd837df3554f91f15388
|
2021-10-19 02:27:12
|
Tom Payne
|
docs: Add docs on configuring editor
| false
|
diff --git a/docs/HOWTO.md b/docs/HOWTO.md
index e15cdfb3fc6..ccfd9f5c48c 100644
--- a/docs/HOWTO.md
+++ b/docs/HOWTO.md
@@ -15,6 +15,7 @@
* [Manage a file's permissions, but not its contents](#manage-a-files-permissions-but-not-its-contents)
* [Populate `~/.ssh/authorized_keys` with your public SSH keys from GitHub](#populate-sshauthorized_keys-with-your-public-ssh-keys-from-github)
* [Integrate chezmoi with your editor](#integrate-chezmoi-with-your-editor)
+ * [Use your preferred editor with `chezmoi edit` and `chezmoi edit-config`](#use-your-preferred-editor-with-chezmoi-edit-and-chezmoi-edit-config)
* [Configure VIM to run `chezmoi apply` whenever you save a dotfile](#configure-vim-to-run-chezmoi-apply-whenever-you-save-a-dotfile)
* [Include dotfiles from elsewhere](#include-dotfiles-from-elsewhere)
* [Include a subdirectory from another repository, like Oh My Zsh](#include-a-subdirectory-from-another-repository-like-oh-my-zsh)
@@ -340,6 +341,38 @@ GitHub username:
---
+### Use your preferred editor with `chezmoi edit` and `chezmoi edit-config`
+
+By default, chezmoi will use your preferred editor as defined by the `$VISUAL`
+or `$EDITOR` environment variables, falling back to a default editor depending
+on your operating system (`vi` on UNIX-like operating systems, `notepad.exe` on
+Windows).
+
+You can configure chezmoi to use your preferred editor by either setting the
+`$EDITOR` environment variable or setting the `edit.command` variable in your
+configuration file.
+
+The editor command must only return when you have finished editing the files.
+chezmoi will emit a warning if your editor command returns too quickly.
+
+In the specific case of using [VSCode](https://code.visualstudio.com/) or
+[Codium](https://vscodium.com/) as your editor, you must pass the `--wait` flag,
+for example, in your shell config:
+
+```console
+$ export EDITOR="code --wait"
+```
+
+Or in chezmoi's configuration file:
+
+```toml
+[edit]
+ command = "code"
+ args = ["--wait"]
+```
+
+---
+
### Configure VIM to run `chezmoi apply` whenever you save a dotfile
Put the following in your `.vimrc`:
|
docs
|
Add docs on configuring editor
|
3fbc646bf0ff6df4c295f019c74ae28807937595
|
2024-03-11 01:33:38
|
dependabot[bot]
|
chore(deps): bump the actions group with 1 update
| false
|
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index f2b3aa78727..3e4dfa9dfe2 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -21,6 +21,6 @@ jobs:
id: go-version
run: |
echo go-version="$(awk '/GO_VERSION:/ { print $2 }' .github/workflows/main.yml | tr -d \')" >> "${GITHUB_OUTPUT}"
- - uses: golang/govulncheck-action@7da72f730e37eeaad891fcff0a532d27ed737cd4
+ - uses: golang/govulncheck-action@3a32958c2706f7048305d5a2e53633d7e37e97d0
with:
go-version-input: ${{ steps.go-version.outputs.go-version }}
|
chore
|
bump the actions group with 1 update
|
0d5fa6c536f59b13db20a8c4ab7d4659e99c37a2
|
2024-08-06 06:55:24
|
Tom Payne
|
chore: Ignore whitespace errors in Python virtualenvs
| false
|
diff --git a/internal/cmds/lint-whitespace/main.go b/internal/cmds/lint-whitespace/main.go
index ef530472f0c..5f84511c63b 100644
--- a/internal/cmds/lint-whitespace/main.go
+++ b/internal/cmds/lint-whitespace/main.go
@@ -18,10 +18,9 @@ var (
regexp.MustCompile(`\A\.git\z`),
regexp.MustCompile(`\A\.idea\z`),
regexp.MustCompile(`\A\.vagrant\z`),
- regexp.MustCompile(`\A\.venv\z`),
+ regexp.MustCompile(`\b\.?venv\b`),
regexp.MustCompile(`\A\.vscode\z`),
regexp.MustCompile(`\ACOMMIT\z`),
- regexp.MustCompile(`\Aassets/chezmoi\.io/\.venv\z`),
regexp.MustCompile(`\Aassets/chezmoi\.io/site\z`),
regexp.MustCompile(`\Aassets/scripts/install\.ps1\z`),
regexp.MustCompile(`\Acompletions/chezmoi\.ps1\z`),
|
chore
|
Ignore whitespace errors in Python virtualenvs
|
126cb0c4cd039d31645cb8bbed8affe28323aea1
|
2021-12-11 18:46:42
|
Tom Payne
|
feat: Add --cache option and .chezmoi.cacheDir template variable
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index 261c4a78d85..df4fc07ebc0 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -5,6 +5,7 @@ Manage your dotfiles across multiple machines, securely.
<!--- toc --->
* [Concepts](#concepts)
* [Global command line flags](#global-command-line-flags)
+ * [`--cache` *directory*](#--cache-directory)
* [`--color` *value*](#--color-value)
* [`-c`, `--config` *filename*](#-c---config-filename)
* [`--config-format` `json`|`toml`|`yaml`](#--config-format-jsontomlyaml)
@@ -174,6 +175,10 @@ destination directory, where:
Command line flags override any values set in the configuration file.
+### `--cache` *directory*
+
+Use *directory* as the cache directory.
+
### `--color` *value*
Colorize diffs, *value* can be `on`, `off`, `auto`, or any boolean-like value
@@ -1891,6 +1896,7 @@ chezmoi provides the following automatically-populated variables:
| -------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `.chezmoi.arch` | `string` | Architecture, e.g. `amd64`, `arm`, etc. as returned by [runtime.GOARCH](https://pkg.go.dev/runtime?tab=doc#pkg-constants) |
| `.chezmoi.args` | `[]string` | The arguments passed to the `chezmoi` command, starting with the program command |
+| `.chezmoi.cacheDir` | `string` | The cache directory |
| `.chezmoi.configFile` | `string` | The path to the configuration file used by chezmoi, if any |
| `.chezmoi.executable` | `string` | The path to the `chezmoi` executable, if available |
| `.chezmoi.fqdnHostname` | `string` | The fully-qualified domain name hostname of the machine chezmoi is running on |
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 1d935ff80e7..4b566aa87d9 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -930,6 +930,7 @@ func (c *Config) defaultTemplateData() map[string]interface{} {
"chezmoi": map[string]interface{}{
"arch": runtime.GOARCH,
"args": os.Args,
+ "cacheDir": c.CacheDirAbsPath.String(),
"configFile": c.configFileAbsPath.String(),
"executable": executable,
"fqdnHostname": fqdnHostname,
@@ -1245,6 +1246,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
persistentFlags := rootCmd.PersistentFlags()
+ persistentFlags.Var(&c.CacheDirAbsPath, "cache", "Set cache directory")
persistentFlags.Var(&c.Color, "color", "Colorize output")
persistentFlags.VarP(&c.DestDirAbsPath, "destination", "D", "Set destination directory")
persistentFlags.Var(&c.Mode, "mode", "Mode")
@@ -1256,6 +1258,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
persistentFlags.BoolVarP(&c.Verbose, "verbose", "v", c.Verbose, "Make output more verbose")
persistentFlags.VarP(&c.WorkingTreeAbsPath, "working-tree", "W", "Set working tree directory")
for viperKey, key := range map[string]string{
+ "cacheDir": "cache",
"color": "color",
"destDir": "destination",
"persistentState": "persistent-state",
diff --git a/internal/cmd/testdata/scripts/config.txt b/internal/cmd/testdata/scripts/config.txt
index e23bef76246..04f1245fe68 100644
--- a/internal/cmd/testdata/scripts/config.txt
+++ b/internal/cmd/testdata/scripts/config.txt
@@ -20,6 +20,10 @@ stdout 'sourceDir: .*/config/source'
chezmoi data --config=$CHEZMOICONFIGDIR/chezmoi.yaml --format=yaml
stdout 'sourceDir: .*/config2/source'
+# test that the cache directory can be set
+chezmoi data --cache=/flag/cache --format=yaml
+stdout 'cacheDir: .*/flag/cache'
+
[windows] stop 'remaining tests require /dev/stdin'
# test that chezmoi can read the config from stdin
|
feat
|
Add --cache option and .chezmoi.cacheDir template variable
|
84e7a9393b432bf58649cccec473149375c909ce
|
2022-07-28 04:16:45
|
Ruijie Yu
|
feat: Make managed command accept destination directory args
| false
|
diff --git a/assets/chezmoi.io/docs/reference/commands/managed.md b/assets/chezmoi.io/docs/reference/commands/managed.md
index f911710e948..2f0298d2802 100644
--- a/assets/chezmoi.io/docs/reference/commands/managed.md
+++ b/assets/chezmoi.io/docs/reference/commands/managed.md
@@ -1,6 +1,8 @@
-# `managed`
+# `managed` [*target*...]
-List all managed entries in the destination directory in alphabetical order.
+List all managed entries in the destination directory under all *target*s in
+alphabetical order. When no *target*s are supplied, list all managed entries in
+the destination directory in alphabetical order.
## `-i`, `--include` *types*
@@ -14,4 +16,5 @@ Only include entries of type *types*.
$ chezmoi managed --include=files,symlinks
$ chezmoi managed -i dirs
$ chezmoi managed -i dirs,files
+ $ chezmoi managed -i files ~/.config
```
diff --git a/pkg/cmd/managedcmd.go b/pkg/cmd/managedcmd.go
index 492b6139f74..8c6abbcf846 100644
--- a/pkg/cmd/managedcmd.go
+++ b/pkg/cmd/managedcmd.go
@@ -17,12 +17,12 @@ type managedCmdConfig struct {
func (c *Config) newManagedCmd() *cobra.Command {
managedCmd := &cobra.Command{
- Use: "managed",
+ Use: "managed [paths]...",
Aliases: []string{"list"},
Short: "List the managed entries in the destination directory",
Long: mustLongHelp("managed"),
Example: example("managed"),
- Args: cobra.NoArgs,
+ Args: cobra.ArbitraryArgs,
RunE: c.makeRunEWithSourceState(c.runManagedCmd),
}
@@ -35,6 +35,22 @@ func (c *Config) newManagedCmd() *cobra.Command {
func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
include := c.managed.include.Sub(c.managed.exclude)
+
+ // Build queued paths. When no arguments, start from root; otherwise start
+ // from arguments.
+ paths := []chezmoi.RelPath{}
+ if len(args) != 0 {
+ for _, arg := range args {
+ if p, err := chezmoi.NormalizePath(arg); err != nil {
+ return err
+ } else if p, err := p.TrimDirPrefix(c.DestDirAbsPath); err != nil {
+ return err
+ } else {
+ paths = append(paths, p)
+ }
+ }
+ }
+
var targetRelPaths chezmoi.RelPaths
_ = sourceState.ForEach(func(targetRelPath chezmoi.RelPath, sourceStateEntry chezmoi.SourceStateEntry) error {
targetStateEntry, err := sourceStateEntry.TargetStateEntry(c.destSystem, c.DestDirAbsPath.Join(targetRelPath))
@@ -44,6 +60,21 @@ func (c *Config) runManagedCmd(cmd *cobra.Command, args []string, sourceState *c
if !include.IncludeTargetStateEntry(targetStateEntry) {
return nil
}
+
+ // when specified arguments, only include paths under these arguments
+ if len(paths) != 0 {
+ included := false
+ for _, path := range paths {
+ if targetRelPath.HasDirPrefix(path) || targetRelPath.String() == path.String() {
+ included = true
+ break
+ }
+ }
+ if !included {
+ return nil
+ }
+ }
+
targetRelPaths = append(targetRelPaths, targetRelPath)
return nil
})
diff --git a/pkg/cmd/testdata/scripts/managed.txt b/pkg/cmd/testdata/scripts/managed.txt
index eef0556f8aa..b4a29abdf49 100644
--- a/pkg/cmd/testdata/scripts/managed.txt
+++ b/pkg/cmd/testdata/scripts/managed.txt
@@ -24,6 +24,22 @@ cmp stdout golden/managed-symlinks
chezmoi managed --exclude=files
cmp stdout golden/managed-except-files
+# test chezmoi managed with arguments
+chezmoi managed $HOME${/}.dir $HOME${/}.create
+cmp stdout golden/managed-with-args
+
+# test chezmoi managed with child of managed dir as argument
+chezmoi managed $HOME${/}.dir/subdir
+cmp stdout golden/managed-in-managed
+
+# test chezmoi managed --exclude=dir with arguments
+chezmoi managed --exclude=dirs $HOME${/}.dir $HOME${/}.create
+cmp stdout golden/managed-with-nodir-args
+
+# test chezmoi managed with absent arguments
+chezmoi managed $HOME${/}.dir $HOME${/}.non-exist
+cmp stdout golden/managed-with-absent-args
+
chhome home2/user
# test that chezmoi managed does not evaluate templates
@@ -84,6 +100,24 @@ cmp stdout golden/managed2
.symlink
.template
script
+-- golden/managed-with-args --
+.create
+.dir
+.dir/file
+.dir/subdir
+.dir/subdir/file
+-- golden/managed-in-managed --
+.dir/subdir
+.dir/subdir/file
+-- golden/managed-with-nodir-args --
+.create
+.dir/file
+.dir/subdir/file
+-- golden/managed-with-absent-args --
+.dir
+.dir/file
+.dir/subdir
+.dir/subdir/file
-- home/user/.local/share/chezmoi/.chezmoiremove --
.remove
-- home2/user/.local/share/chezmoi/create_dot_create.tmpl --
|
feat
|
Make managed command accept destination directory args
|
59764c88d5831fdd4c109b51f12172ce1fe191c0
|
2024-03-03 05:51:04
|
Tom Payne
|
fix: Fix panic in unmanaged on some dir permission errors
| false
|
diff --git a/go.mod b/go.mod
index f7a8ee28c94..76730c7d66e 100644
--- a/go.mod
+++ b/go.mod
@@ -40,7 +40,7 @@ require (
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
github.com/twpayne/go-pinentry/v3 v3.0.1
github.com/twpayne/go-shell v0.4.0
- github.com/twpayne/go-vfs/v5 v5.0.2
+ github.com/twpayne/go-vfs/v5 v5.0.3
github.com/twpayne/go-xdg/v6 v6.1.2
github.com/ulikunitz/xz v0.5.11
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
diff --git a/go.sum b/go.sum
index 79f46539521..5ef65103cf9 100644
--- a/go.sum
+++ b/go.sum
@@ -427,8 +427,8 @@ github.com/twpayne/go-shell v0.4.0 h1:RAAMbjEj7mcwDdwC7SiFHGUKR+WDAURU6mnyd3r2p2
github.com/twpayne/go-shell v0.4.0/go.mod h1:MP3aUA0TQ3IGoJc15ahjb+7A7wZH4NeGrvLZ/aFQsHc=
github.com/twpayne/go-vfs/v4 v4.3.0 h1:rTqFzzOQ/6ESKTSiwVubHlCBedJDOhQyVSnw8rQNZhU=
github.com/twpayne/go-vfs/v4 v4.3.0/go.mod h1:tq2UVhnUepesc0lSnPJH/jQ8HruGhzwZe2r5kDFpEIw=
-github.com/twpayne/go-vfs/v5 v5.0.2 h1:5y6tVvQ5lPltcRauIRmX9qC/XYvV++DSRGZxUaiHzMQ=
-github.com/twpayne/go-vfs/v5 v5.0.2/go.mod h1:zTPFJUbgsEMFNSWnWQlLq9wh4AN83edZzx3VXbxrS1w=
+github.com/twpayne/go-vfs/v5 v5.0.3 h1:9jeacSMvwh8sSLCuS4Ay0QmyAv1ToG1ITeQn6+Zsq1k=
+github.com/twpayne/go-vfs/v5 v5.0.3/go.mod h1:zTPFJUbgsEMFNSWnWQlLq9wh4AN83edZzx3VXbxrS1w=
github.com/twpayne/go-xdg/v6 v6.1.2 h1:KbfCsAP4bBR5+dzfTIh/M9onOPCSqlYsIER79IKwt+s=
github.com/twpayne/go-xdg/v6 v6.1.2/go.mod h1:BFHclQaEPLq3jRRYjf1PdFzUEvAfPeLjNymIO/7/7o4=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
diff --git a/internal/cmd/unmanagedcmd.go b/internal/cmd/unmanagedcmd.go
index 1a74866e226..152ef4369d7 100644
--- a/internal/cmd/unmanagedcmd.go
+++ b/internal/cmd/unmanagedcmd.go
@@ -54,11 +54,11 @@ func (c *Config) runUnmanagedCmd(cmd *cobra.Command, args []string, sourceState
unmanagedRelPaths := make(map[chezmoi.RelPath]struct{})
walkFunc := func(destAbsPath chezmoi.AbsPath, fileInfo fs.FileInfo, err error) error {
if err != nil {
- if c.keepGoing {
- c.errorf("%s: %v", destAbsPath, err)
- return nil
+ c.errorf("%s: %v", destAbsPath, err)
+ if fileInfo == nil || fileInfo.IsDir() {
+ return fs.SkipDir
}
- return err
+ return nil
}
if destAbsPath == c.DestDirAbsPath {
return nil
|
fix
|
Fix panic in unmanaged on some dir permission errors
|
a632eb1f31987692738290149abe2ed851886fc7
|
2023-04-17 03:30:59
|
Tom Payne
|
chore: Add test for reported .chezmoiroot issue
| false
|
diff --git a/pkg/cmd/testdata/scripts/issue2865.txtar b/pkg/cmd/testdata/scripts/issue2865.txtar
new file mode 100644
index 00000000000..2e5793b987c
--- /dev/null
+++ b/pkg/cmd/testdata/scripts/issue2865.txtar
@@ -0,0 +1,16 @@
+[windows] skip 'UNIX only'
+
+# test that .chezmoi.sourceDir is set correctly when .chezmoiroot is present
+exec chezmoi execute-template '{{ .chezmoi.sourceDir }}'
+stdout ${CHEZMOISOURCEDIR@R}/home
+
+# test that .chezmoi.sourceDir is set correctly in chezmoi apply
+exec chezmoi apply
+stdout ${CHEZMOISOURCEDIR@R}/home
+
+-- home/user/.local/share/chezmoi/.chezmoiroot --
+home
+-- home/user/.local/share/chezmoi/home/.chezmoiscripts/run_once_echo.sh.tmpl --
+#!/bin/sh
+
+echo {{ .chezmoi.sourceDir }}
|
chore
|
Add test for reported .chezmoiroot issue
|
4e13f769b46f546215a74eecb6d40aa970a00674
|
2022-12-29 05:21:10
|
Tom Payne
|
feat: Allow cd command to take the destination directory as an argument
| false
|
diff --git a/pkg/cmd/cdcmd.go b/pkg/cmd/cdcmd.go
index 856760cc6db..bb2a6d83fea 100644
--- a/pkg/cmd/cdcmd.go
+++ b/pkg/cmd/cdcmd.go
@@ -39,6 +39,13 @@ func (c *Config) runCDCmd(cmd *cobra.Command, args []string) error {
var dir chezmoi.AbsPath
if len(args) == 0 {
dir = c.WorkingTreeAbsPath
+ } else if argAbsPath, err := chezmoi.NewAbsPathFromExtPath(args[0], c.homeDirAbsPath); err != nil { //nolint:gocritic
+ return err
+ } else if argAbsPath == c.DestDirAbsPath {
+ dir, err = c.getSourceDirAbsPath(nil)
+ if err != nil {
+ return err
+ }
} else {
sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
diff --git a/pkg/cmd/testdata/scripts/cd_unix.txtar b/pkg/cmd/testdata/scripts/cd_unix.txtar
index a6427115e7b..0cac7b48c4f 100644
--- a/pkg/cmd/testdata/scripts/cd_unix.txtar
+++ b/pkg/cmd/testdata/scripts/cd_unix.txtar
@@ -5,15 +5,18 @@ chmod 755 bin/shell
# test that chezmoi cd creates source directory if needed
exec chezmoi cd
exists $CHEZMOISOURCEDIR
-grep -count=1 ${CHEZMOISOURCEDIR@R} shell.log
+grep ${CHEZMOISOURCEDIR@R} shell.log
+rm shell.log
# test that chezmoi cd changes into an existing directory
exec chezmoi cd
-grep -count=2 ${CHEZMOISOURCEDIR@R} shell.log
+grep ${CHEZMOISOURCEDIR@R} shell.log
+rm shell.log
# test chat chezmoi cd with an argument changes into the corresponding source directory
exec chezmoi cd $HOME${/}.dir
grep ${CHEZMOISOURCEDIR@R}/dot_dir shell.log
+rm shell.log
# test that chezmoi cd works when $SHELL environment variable contains spaces
env SHELL='shell arg1'
@@ -26,10 +29,19 @@ chhome home2/user
exec chezmoi cd
stdout '^shell arg2$'
+env SHELL=$WORK/bin/shell
+
+chhome home3/user
+
+# test that chezmoi cd $HOME with .chezmoiroot changes into .chezmoiroot
+exec chezmoi cd $HOME
+grep ${CHEZMOISOURCEDIR@R}/home shell.log
+rm shell.log
+
-- bin/shell --
#!/bin/sh
-pwd >> $WORK/shell.log
+pwd > $WORK/shell.log
echo shell $*
-- home/user/.dir/.keep --
-- home/user/.local/share/chezmoi/dot_dir/.keep --
@@ -37,3 +49,6 @@ echo shell $*
[cd]
command = "shell"
args = ["arg2"]
+-- home3/user/.local/share/chezmoi/.chezmoiroot --
+home
+-- home3/user/.local/share/chezmoi/home/.keep --
|
feat
|
Allow cd command to take the destination directory as an argument
|
2c9ea64556d851cffcab00c9f0b901b3987866c4
|
2023-01-31 21:50:19
|
Tom Payne
|
docs: Remove old redirections
| false
|
diff --git a/assets/chezmoi.io/mkdocs.yml b/assets/chezmoi.io/mkdocs.yml
index e3f45e588dc..d2cef1c10bc 100644
--- a/assets/chezmoi.io/mkdocs.yml
+++ b/assets/chezmoi.io/mkdocs.yml
@@ -307,20 +307,6 @@ plugins:
on_pre_build: docs.hooks:on_pre_build
on_files: docs.hooks:on_files
on_post_build: docs.hooks:on_post_build
-- redirects:
- redirect_maps:
- # redirect links from previous Hugo-generated website
- docs/architecture.md: developer/architecture.md
- docs/comparison.md: comparison-table.md
- docs/faq.md: user-guide/frequently-asked-questions/design.md
- docs/how-to.md: user-guide/setup.md
- docs/install.md: install.md
- docs/media.md: links/articles-podcasts-and-videos.md
- docs/quick-start.md: quick-start.md
- docs/reference.md: reference/index.md
- docs/related.md: links/related-software.md
- docs/security.md: developer/security.md
- docs/templating.md: user-guide/templating.md
- search
extra_javascript:
|
docs
|
Remove old redirections
|
a53be5d73ac44540b95e361ba136a268fa7aedde
|
2022-09-27 20:23:38
|
Tom Payne
|
chore: Bump gofumpt to version 0.4.0
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 37379604407..f18d91f45f7 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ on:
env:
AGE_VERSION: 1.0.0
GO_VERSION: 1.19.1
- GOFUMPT_VERSION: 0.3.1
+ GOFUMPT_VERSION: 0.4.0
GOLANGCI_LINT_VERSION: 1.49.0
TPARSE_VERSION: 0.11.1
jobs:
|
chore
|
Bump gofumpt to version 0.4.0
|
ecf706d8f60a5a7c71af62683bd076efefcc9211
|
2024-01-23 03:21:12
|
Tom Payne
|
chore: Add missing double quote
| false
|
diff --git a/assets/chezmoi.io/docs/user-guide/password-managers/custom.md b/assets/chezmoi.io/docs/user-guide/password-managers/custom.md
index 582f6e3a04c..225f5ec16b1 100644
--- a/assets/chezmoi.io/docs/user-guide/password-managers/custom.md
+++ b/assets/chezmoi.io/docs/user-guide/password-managers/custom.md
@@ -13,7 +13,7 @@ way:
| Bitwarden | `bw` | `{{ secretJSON "get" "$ID" }}` |
| Doppler | `doppler` | `{{ secretJSON "secrets" "download" "--json" "--no-file" }}` |
| HashiCorp Vault | `vault` | `{{ secretJSON "kv" "get" "-format=json" "$ID" }}` |
-| HCP Vault Secrets | `vlt` | `{{ secret "secrets" "get" "--plaintext" "$ID }}` |
+| HCP Vault Secrets | `vlt` | `{{ secret "secrets" "get" "--plaintext" "$ID" }}` |
| LastPass | `lpass` | `{{ secretJSON "show" "--json" "$ID" }}` |
| KeePassXC | `keepassxc-cli` | Not possible (interactive command only) |
| Keeper | `keeper` | `{{ secretJSON "get" "--format=json" "$ID" }}` |
|
chore
|
Add missing double quote
|
55a4b93d6587737b4aba42bb6810209a76200851
|
2021-09-30 03:33:34
|
Tom Payne
|
feat: Add --init option to update command
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index 26725a4fbd2..6d822d6c3e3 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -1593,6 +1593,11 @@ Pull changes from the source repo and apply any changes.
Only update entries of type *types*.
+#### `--init`
+
+Regenerate and reread the config file from the config file template before
+applying any changes.
+
#### `update` examples
```console
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index ac48c7c62f1..d216ea1247f 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -551,6 +551,101 @@ func (c *Config) colorAutoFunc() bool {
return false
}
+// createAndReloadConfigFile creates a config file if it there is a config file
+// template and reloads it.
+func (c *Config) createAndReloadConfigFile() error {
+ // Find config template, execute it, and create config file.
+ configTemplateRelPath, ext, configTemplateContents, err := c.findConfigTemplate()
+ if err != nil {
+ return err
+ }
+ var configFileContents []byte
+ if configTemplateRelPath == "" {
+ if err := c.persistentState.Delete(chezmoi.ConfigStateBucket, configStateKey); err != nil {
+ return err
+ }
+ } else {
+ configFileContents, err = c.createConfigFile(configTemplateRelPath, configTemplateContents)
+ if err != nil {
+ return err
+ }
+
+ // Validate the config.
+ v := viper.New()
+ v.SetConfigType(ext)
+ if err := v.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
+ return err
+ }
+ if err := v.Unmarshal(&Config{}, viperDecodeConfigOptions...); err != nil {
+ return err
+ }
+
+ // Write the config.
+ configPath := c.init.configPath
+ if c.init.configPath.Empty() {
+ configPath = chezmoi.NewAbsPath(c.bds.ConfigHome).Join("chezmoi").Join(configTemplateRelPath)
+ }
+ if err := chezmoi.MkdirAll(c.baseSystem, configPath.Dir(), 0o777); err != nil {
+ return err
+ }
+ if err := c.baseSystem.WriteFile(configPath, configFileContents, 0o600); err != nil {
+ return err
+ }
+
+ configStateValue, err := json.Marshal(configState{
+ ConfigTemplateContentsSHA256: chezmoi.HexBytes(chezmoi.SHA256Sum(configTemplateContents)),
+ })
+ if err != nil {
+ return err
+ }
+ if err := c.persistentState.Set(chezmoi.ConfigStateBucket, configStateKey, configStateValue); err != nil {
+ return err
+ }
+ }
+
+ // Reload config if it was created.
+ if configTemplateRelPath != "" {
+ viper.SetConfigType(ext)
+ if err := viper.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
+ return err
+ }
+ if err := viper.Unmarshal(c, viperDecodeConfigOptions...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// createConfigFile creates a config file using a template and returns its
+// contents.
+func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte, error) {
+ funcMap := make(template.FuncMap)
+ chezmoi.RecursiveMerge(funcMap, c.templateFuncs)
+ chezmoi.RecursiveMerge(funcMap, map[string]interface{}{
+ "promptBool": c.promptBool,
+ "promptInt": c.promptInt,
+ "promptString": c.promptString,
+ "stdinIsATTY": c.stdinIsATTY,
+ "writeToStdout": c.writeToStdout,
+ })
+
+ t, err := template.New(string(filename)).Funcs(funcMap).Parse(string(data))
+ if err != nil {
+ return nil, err
+ }
+
+ sb := strings.Builder{}
+ templateData := c.defaultTemplateData()
+ if c.init.data {
+ chezmoi.RecursiveMerge(templateData, c.Data)
+ }
+ if err = t.Execute(&sb, templateData); err != nil {
+ return nil, err
+ }
+ return []byte(sb.String()), nil
+}
+
// defaultConfigFile returns the default config file according to the XDG Base
// Directory Specification.
func (c *Config) defaultConfigFile(fileSystem vfs.Stater, bds *xdg.BaseDirectorySpecification) (chezmoi.AbsPath, error) {
diff --git a/internal/cmd/initcmd.go b/internal/cmd/initcmd.go
index 67c94d1a8ec..e0eadbcaa0d 100644
--- a/internal/cmd/initcmd.go
+++ b/internal/cmd/initcmd.go
@@ -1,25 +1,18 @@
package cmd
import (
- "bytes"
- "encoding/json"
"errors"
"fmt"
"io/fs"
- "os"
"regexp"
"runtime"
"strconv"
- "strings"
- "text/template"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
- "golang.org/x/term"
"github.com/twpayne/chezmoi/v2/internal/chezmoi"
)
@@ -217,65 +210,9 @@ func (c *Config) runInitCmd(cmd *cobra.Command, args []string) error {
return err
}
- // Find config template, execute it, and create config file.
- configTemplateRelPath, ext, configTemplateContents, err := c.findConfigTemplate()
- if err != nil {
+ if err := c.createAndReloadConfigFile(); err != nil {
return err
}
- var configFileContents []byte
- if configTemplateRelPath == "" {
- if err := c.persistentState.Delete(chezmoi.ConfigStateBucket, configStateKey); err != nil {
- return err
- }
- } else {
- configFileContents, err = c.createConfigFile(configTemplateRelPath, configTemplateContents)
- if err != nil {
- return err
- }
-
- // Validate the config.
- v := viper.New()
- v.SetConfigType(ext)
- if err := v.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
- return err
- }
- if err := v.Unmarshal(&Config{}, viperDecodeConfigOptions...); err != nil {
- return err
- }
-
- // Write the config.
- configPath := c.init.configPath
- if c.init.configPath.Empty() {
- configPath = chezmoi.NewAbsPath(c.bds.ConfigHome).Join("chezmoi").Join(configTemplateRelPath)
- }
- if err := chezmoi.MkdirAll(c.baseSystem, configPath.Dir(), 0o777); err != nil {
- return err
- }
- if err := c.baseSystem.WriteFile(configPath, configFileContents, 0o600); err != nil {
- return err
- }
-
- configStateValue, err := json.Marshal(configState{
- ConfigTemplateContentsSHA256: chezmoi.HexBytes(chezmoi.SHA256Sum(configTemplateContents)),
- })
- if err != nil {
- return err
- }
- if err := c.persistentState.Set(chezmoi.ConfigStateBucket, configStateKey, configStateValue); err != nil {
- return err
- }
- }
-
- // Reload config if it was created.
- if configTemplateRelPath != "" {
- viper.SetConfigType(ext)
- if err := viper.ReadConfig(bytes.NewBuffer(configFileContents)); err != nil {
- return err
- }
- if err := viper.Unmarshal(c, viperDecodeConfigOptions...); err != nil {
- return err
- }
- }
// Apply.
if c.init.apply {
@@ -301,79 +238,6 @@ func (c *Config) runInitCmd(cmd *cobra.Command, args []string) error {
return nil
}
-// createConfigFile creates a config file using a template and returns its
-// contents.
-func (c *Config) createConfigFile(filename chezmoi.RelPath, data []byte) ([]byte, error) {
- funcMap := make(template.FuncMap)
- chezmoi.RecursiveMerge(funcMap, c.templateFuncs)
- chezmoi.RecursiveMerge(funcMap, map[string]interface{}{
- "promptBool": c.promptBool,
- "promptInt": c.promptInt,
- "promptString": c.promptString,
- "stdinIsATTY": c.stdinIsATTY,
- "writeToStdout": c.writeToStdout,
- })
-
- t, err := template.New(string(filename)).Funcs(funcMap).Parse(string(data))
- if err != nil {
- return nil, err
- }
-
- sb := strings.Builder{}
- templateData := c.defaultTemplateData()
- if c.init.data {
- chezmoi.RecursiveMerge(templateData, c.Data)
- }
- if err = t.Execute(&sb, templateData); err != nil {
- return nil, err
- }
- return []byte(sb.String()), nil
-}
-
-func (c *Config) promptBool(field string) bool {
- value, err := parseBool(c.promptString(field))
- if err != nil {
- returnTemplateError(err)
- return false
- }
- return value
-}
-
-func (c *Config) promptInt(field string) int64 {
- value, err := strconv.ParseInt(c.promptString(field), 10, 64)
- if err != nil {
- returnTemplateError(err)
- return 0
- }
- return value
-}
-
-func (c *Config) promptString(field string) string {
- value, err := c.readLine(fmt.Sprintf("%s? ", field))
- if err != nil {
- returnTemplateError(err)
- return ""
- }
- return strings.TrimSpace(value)
-}
-
-func (c *Config) stdinIsATTY() bool {
- file, ok := c.stdin.(*os.File)
- if !ok {
- return false
- }
- return term.IsTerminal(int(file.Fd()))
-}
-
-func (c *Config) writeToStdout(args ...string) string {
- for _, arg := range args {
- if _, err := c.stdout.Write([]byte(arg)); err != nil {
- panic(err)
- }
- }
- return ""
-}
-
// guessDotfilesRepoURL guesses the user's username and dotfile repo from arg.
func guessDotfilesRepoURL(arg string, ssh bool) (username, repo string) {
for _, dotfileRepoGuess := range dotfilesRepoGuesses {
diff --git a/internal/cmd/inittemplatefuncs.go b/internal/cmd/inittemplatefuncs.go
new file mode 100644
index 00000000000..295340dbe50
--- /dev/null
+++ b/internal/cmd/inittemplatefuncs.go
@@ -0,0 +1,54 @@
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+
+ "golang.org/x/term"
+)
+
+func (c *Config) promptBool(field string) bool {
+ value, err := parseBool(c.promptString(field))
+ if err != nil {
+ returnTemplateError(err)
+ return false
+ }
+ return value
+}
+
+func (c *Config) promptInt(field string) int64 {
+ value, err := strconv.ParseInt(c.promptString(field), 10, 64)
+ if err != nil {
+ returnTemplateError(err)
+ return 0
+ }
+ return value
+}
+
+func (c *Config) promptString(field string) string {
+ value, err := c.readLine(fmt.Sprintf("%s? ", field))
+ if err != nil {
+ returnTemplateError(err)
+ return ""
+ }
+ return strings.TrimSpace(value)
+}
+
+func (c *Config) stdinIsATTY() bool {
+ file, ok := c.stdin.(*os.File)
+ if !ok {
+ return false
+ }
+ return term.IsTerminal(int(file.Fd()))
+}
+
+func (c *Config) writeToStdout(args ...string) string {
+ for _, arg := range args {
+ if _, err := c.stdout.Write([]byte(arg)); err != nil {
+ panic(err)
+ }
+ }
+ return ""
+}
diff --git a/internal/cmd/testdata/scripts/update.txt b/internal/cmd/testdata/scripts/update.txt
index c126efcde9f..39adc5bc77a 100644
--- a/internal/cmd/testdata/scripts/update.txt
+++ b/internal/cmd/testdata/scripts/update.txt
@@ -50,3 +50,13 @@ chezmoi update --apply=false
grep -count=1 '# edited' $HOME/.file
chezmoi apply --force
grep -count=2 '# edited' $HOME/.file
+
+# test chezmoi update --init
+cp golden/.chezmoi.toml.tmpl $CHEZMOISOURCEDIR
+chezmoi update --init
+chezmoi execute-template '{{ .key }}'
+stdout value
+
+-- golden/.chezmoi.toml.tmpl --
+[data]
+ key = "value"
diff --git a/internal/cmd/updatecmd.go b/internal/cmd/updatecmd.go
index f881e45ab79..52dc9aa1306 100644
--- a/internal/cmd/updatecmd.go
+++ b/internal/cmd/updatecmd.go
@@ -13,6 +13,7 @@ type updateCmdConfig struct {
apply bool
exclude *chezmoi.EntryTypeSet
include *chezmoi.EntryTypeSet
+ init bool
recursive bool
}
@@ -37,6 +38,7 @@ func (c *Config) newUpdateCmd() *cobra.Command {
flags.BoolVarP(&c.update.apply, "apply", "a", c.update.apply, "Apply after pulling")
flags.VarP(c.update.exclude, "exclude", "x", "Exclude entry types")
flags.VarP(c.update.include, "include", "i", "Include entry types")
+ flags.BoolVar(&c.update.init, "init", c.update.init, "Recreate config file from template")
flags.BoolVarP(&c.update.recursive, "recursive", "r", c.update.recursive, "Recurse into subdirectories")
return updateCmd
@@ -72,14 +74,22 @@ func (c *Config) runUpdateCmd(cmd *cobra.Command, args []string) error {
}
}
- if !c.update.apply {
- return nil
+ if c.update.init {
+ if err := c.createAndReloadConfigFile(); err != nil {
+ return err
+ }
+ }
+
+ if c.update.apply {
+ if err := c.applyArgs(cmd.Context(), c.destSystem, c.DestDirAbsPath, args, applyArgsOptions{
+ include: c.update.include.Sub(c.update.exclude),
+ recursive: c.update.recursive,
+ umask: c.Umask,
+ preApplyFunc: c.defaultPreApplyFunc,
+ }); err != nil {
+ return err
+ }
}
- return c.applyArgs(cmd.Context(), c.destSystem, c.DestDirAbsPath, args, applyArgsOptions{
- include: c.update.include.Sub(c.update.exclude),
- recursive: c.update.recursive,
- umask: c.Umask,
- preApplyFunc: c.defaultPreApplyFunc,
- })
+ return nil
}
|
feat
|
Add --init option to update command
|
784bb58be6675efa6fae3e629483260c1a8f8251
|
2024-07-01 17:17:26
|
dependabot[bot]
|
chore(deps): bump the python group in /assets with 2 updates
| false
|
diff --git a/assets/chezmoi.io/requirements.txt b/assets/chezmoi.io/requirements.txt
index 64602a14128..d0e21ed2c95 100644
--- a/assets/chezmoi.io/requirements.txt
+++ b/assets/chezmoi.io/requirements.txt
@@ -1,3 +1,3 @@
mkdocs==1.6.0
-mkdocs-material==9.5.25
+mkdocs-material==9.5.27
mkdocs-mermaid2-plugin==1.1.1
diff --git a/assets/requirements.dev.txt b/assets/requirements.dev.txt
index 7bf99f16dcf..38ed49bd376 100644
--- a/assets/requirements.dev.txt
+++ b/assets/requirements.dev.txt
@@ -1 +1 @@
-ruff==0.4.7
+ruff==0.5.0
|
chore
|
bump the python group in /assets with 2 updates
|
547de5b86f0c0da185dd663ded727d246e5e6a91
|
2023-08-02 03:43:29
|
Tom Payne
|
chore: Build with Go 1.20.7
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index e0524423160..776953dc70b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ on:
env:
ACTIONLINT_VERSION: 1.6.25
AGE_VERSION: 1.1.1
- GO_VERSION: 1.20.6
+ GO_VERSION: 1.20.7
GOFUMPT_VERSION: 0.4.0
GOLANGCI_LINT_VERSION: 1.53.3
GOLINES_VERSION: 0.11.0
|
chore
|
Build with Go 1.20.7
|
4950fc33558737c62653d8ba6b950bd0d9816883
|
2022-09-03 00:48:13
|
Tom Payne
|
fix: Make includeTemplate function first search in .chezmoitemplates
| false
|
diff --git a/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md b/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md
index 0129a7ac983..79769d8b9c7 100644
--- a/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md
+++ b/assets/chezmoi.io/docs/reference/templates/functions/includeTemplate.md
@@ -1,5 +1,6 @@
# `includeTemplate` *filename* [*data*]
`includeTemplate` returns the result of executing the contents of *filename*
-with the optional *data*. Relative paths are interpreted relative to the source
+with the optional *data*. Relative paths are first searched for in
+`.chezmoitemplates` and, if not found, are interpreted relative to the source
directory.
diff --git a/pkg/chezmoi/chezmoi.go b/pkg/chezmoi/chezmoi.go
index fc0f7722860..5a34466a373 100644
--- a/pkg/chezmoi/chezmoi.go
+++ b/pkg/chezmoi/chezmoi.go
@@ -61,13 +61,13 @@ const (
Prefix = ".chezmoi"
RootName = Prefix + "root"
+ TemplatesDirName = Prefix + "templates"
VersionName = Prefix + "version"
dataName = Prefix + "data"
externalName = Prefix + "external"
ignoreName = Prefix + "ignore"
removeName = Prefix + "remove"
scriptsDirName = Prefix + "scripts"
- templatesDirName = Prefix + "templates"
)
var (
@@ -99,7 +99,7 @@ var knownPrefixedFiles = newSet(
// knownPrefixedDirs is a set of known dirnames with the .chezmoi prefix.
var knownPrefixedDirs = newSet(
scriptsDirName,
- templatesDirName,
+ TemplatesDirName,
)
// knownTargetFiles is a set of known target files that should not be managed
diff --git a/pkg/chezmoi/sourcestate.go b/pkg/chezmoi/sourcestate.go
index 7a5e34cfcea..e832d8401be 100644
--- a/pkg/chezmoi/sourcestate.go
+++ b/pkg/chezmoi/sourcestate.go
@@ -880,7 +880,7 @@ func (s *SourceState) Read(ctx context.Context, options *ReadOptions) error {
return nil
}
return s.addTemplateData(sourceAbsPath)
- case fileInfo.Name() == templatesDirName:
+ case fileInfo.Name() == TemplatesDirName:
if err := s.addTemplatesDir(ctx, sourceAbsPath); err != nil {
return err
}
@@ -1285,7 +1285,7 @@ func (s *SourceState) addTemplatesDir(ctx context.Context, templatesDirAbsPath A
case err != nil:
return err
case strings.HasPrefix(fileInfo.Name(), Prefix):
- return fmt.Errorf("%s: not allowed in %s directory", templatesDirName, templateAbsPath)
+ return fmt.Errorf("%s: not allowed in %s directory", TemplatesDirName, templateAbsPath)
case strings.HasPrefix(fileInfo.Name(), "."):
if fileInfo.IsDir() {
return vfs.SkipDir
diff --git a/pkg/chezmoi/system.go b/pkg/chezmoi/system.go
index 2fc2562b78f..d5ca680c5ff 100644
--- a/pkg/chezmoi/system.go
+++ b/pkg/chezmoi/system.go
@@ -184,7 +184,7 @@ var sourceDirEntryOrder = map[string]int{
dataName + ".json": -2,
dataName + ".toml": -2,
dataName + ".yaml": -2,
- templatesDirName: -1,
+ TemplatesDirName: -1,
}
// walkSourceDir is a helper function for WalkSourceDir.
diff --git a/pkg/cmd/templatefuncs.go b/pkg/cmd/templatefuncs.go
index bfd1f879bab..710b53da13f 100644
--- a/pkg/cmd/templatefuncs.go
+++ b/pkg/cmd/templatefuncs.go
@@ -93,7 +93,8 @@ func (c *Config) globTemplateFunc(pattern string) []string {
}
func (c *Config) includeTemplateFunc(filename string) string {
- contents, err := c.readFile(filename)
+ searchDirAbsPaths := []chezmoi.AbsPath{c.SourceDirAbsPath}
+ contents, err := c.readFile(filename, searchDirAbsPaths)
if err != nil {
panic(err)
}
@@ -111,7 +112,11 @@ func (c *Config) includeTemplateTemplateFunc(filename string, args ...any) strin
panic(fmt.Errorf("expected 0 or 1 arguments, got %d", len(args)))
}
- contents, err := c.readFile(filename)
+ searchDirAbsPaths := []chezmoi.AbsPath{
+ c.SourceDirAbsPath.JoinString(chezmoi.TemplatesDirName),
+ c.SourceDirAbsPath,
+ }
+ contents, err := c.readFile(filename, searchDirAbsPaths)
if err != nil {
panic(err)
}
@@ -212,18 +217,24 @@ func (c *Config) quoteListTemplateFunc(list []any) []string {
return result
}
-func (c *Config) readFile(filename string) ([]byte, error) {
- var absPath chezmoi.AbsPath
+func (c *Config) readFile(filename string, searchDirAbsPaths []chezmoi.AbsPath) ([]byte, error) {
if filepath.IsAbs(filename) {
- var err error
- absPath, err = chezmoi.NewAbsPathFromExtPath(filename, c.homeDirAbsPath)
+ absPath, err := chezmoi.NewAbsPathFromExtPath(filename, c.homeDirAbsPath)
if err != nil {
return nil, err
}
- } else {
- absPath = c.SourceDirAbsPath.JoinString(filename)
+ return c.fileSystem.ReadFile(absPath.String())
+ }
+
+ var data []byte
+ var err error
+ for _, searchDir := range searchDirAbsPaths {
+ data, err = c.fileSystem.ReadFile(searchDir.JoinString(filename).String())
+ if !errors.Is(err, fs.ErrNotExist) {
+ return data, err
+ }
}
- return c.fileSystem.ReadFile(absPath.String())
+ return data, err
}
func (c *Config) replaceAllRegexTemplateFunc(expr, repl, s string) string {
diff --git a/pkg/cmd/testdata/scripts/templatefuncs.txtar b/pkg/cmd/testdata/scripts/templatefuncs.txtar
index e84176036bc..44866d5a14c 100644
--- a/pkg/cmd/testdata/scripts/templatefuncs.txtar
+++ b/pkg/cmd/testdata/scripts/templatefuncs.txtar
@@ -28,6 +28,10 @@ cmp stdout golden/include-relpath
exec chezmoi execute-template '{{ includeTemplate ".template" "data" }}'
stdout ^data$
+# test includeTemplate template function searches .chezmoitemplates
+exec chezmoi execute-template '{{ includeTemplate "template" "data" }}'
+stdout ^data$
+
# test joinPath template function
exec chezmoi execute-template '{{ joinPath "a" "b" }}'
stdout a${/}b
@@ -162,7 +166,10 @@ subkey = subvalue
# contents of .include
-- home/user/.local/share/chezmoi/.include --
# contents of .local/share/chezmoi/.include
+-- home/user/.local/share/chezmoi/.chezmoitemplates/template --
+{{ . }}
-- home/user/.local/share/chezmoi/.template --
{{ . }}
+-- home/user/.local/share/chezmoi/template --
-- home/user/file1.txt --
-- home/user/file2.txt --
|
fix
|
Make includeTemplate function first search in .chezmoitemplates
|
f774874c5739a2db22046d3ec9ac5305caabd11b
|
2021-10-09 18:39:54
|
Tom Payne
|
chore: Improve type safety of run_ script ordering
| false
|
diff --git a/internal/chezmoi/attr.go b/internal/chezmoi/attr.go
index 8d04d203c90..59b8d0d4213 100644
--- a/internal/chezmoi/attr.go
+++ b/internal/chezmoi/attr.go
@@ -31,6 +31,16 @@ var sourceFileTypeStrs = map[SourceFileTargetType]string{
SourceFileTypeSymlink: "symlink",
}
+// A ScriptOrder defines when a script should be executed.
+type ScriptOrder int
+
+// Script orders.
+const (
+ ScriptOrderBefore ScriptOrder = -1
+ ScriptOrderDuring ScriptOrder = 0
+ ScriptOrderAfter ScriptOrder = 1
+)
+
// DirAttr holds attributes parsed from a source directory name.
type DirAttr struct {
TargetName string
@@ -47,7 +57,7 @@ type FileAttr struct {
Encrypted bool
Executable bool
Once bool
- Order int
+ Order ScriptOrder
Private bool
ReadOnly bool
Template bool
@@ -140,10 +150,10 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr {
encrypted = false
executable = false
once = false
+ order = ScriptOrderDuring
private = false
readOnly = false
template = false
- order = 0
)
switch {
case strings.HasPrefix(name, createPrefix):
@@ -178,10 +188,10 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr {
switch {
case strings.HasPrefix(name, beforePrefix):
name = mustTrimPrefix(name, beforePrefix)
- order = -1
+ order = ScriptOrderBefore
case strings.HasPrefix(name, afterPrefix):
name = mustTrimPrefix(name, afterPrefix)
- order = 1
+ order = ScriptOrderAfter
}
case strings.HasPrefix(name, symlinkPrefix):
sourceFileType = SourceFileTypeSymlink
@@ -253,10 +263,10 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr {
Encrypted: encrypted,
Executable: executable,
Once: once,
+ Order: order,
Private: private,
ReadOnly: readOnly,
Template: template,
- Order: order,
}
}
@@ -269,7 +279,7 @@ func (fa FileAttr) MarshalZerologObject(e *zerolog.Event) {
e.Bool("Encrypted", fa.Encrypted)
e.Bool("Executable", fa.Executable)
e.Bool("Once", fa.Once)
- e.Int("Order", fa.Order)
+ e.Int("Order", int(fa.Order))
e.Bool("Private", fa.Private)
e.Bool("ReadOnly", fa.ReadOnly)
e.Bool("Template", fa.Template)
@@ -328,9 +338,9 @@ func (fa FileAttr) SourceName(encryptedSuffix string) string {
sourceName += oncePrefix
}
switch fa.Order {
- case -1:
+ case ScriptOrderBefore:
sourceName += beforePrefix
- case 1:
+ case ScriptOrderAfter:
sourceName += afterPrefix
}
case SourceFileTypeSymlink:
diff --git a/internal/chezmoi/attr_test.go b/internal/chezmoi/attr_test.go
index c75a6435672..d41f0d00855 100644
--- a/internal/chezmoi/attr_test.go
+++ b/internal/chezmoi/attr_test.go
@@ -153,12 +153,12 @@ func TestFileAttr(t *testing.T) {
Type SourceFileTargetType
TargetName []string
Once []bool
- Order []int
+ Order []ScriptOrder
}{
Type: SourceFileTypeScript,
TargetName: targetNames,
Once: []bool{false, true},
- Order: []int{-1, 0, 1},
+ Order: []ScriptOrder{ScriptOrderBefore, ScriptOrderDuring, ScriptOrderAfter},
}))
require.NoError(t, combinator.Generate(&fileAttrs, struct {
Type SourceFileTargetType
diff --git a/internal/chezmoi/sourcestateentry.go b/internal/chezmoi/sourcestateentry.go
index bdb918dc395..957072a81d5 100644
--- a/internal/chezmoi/sourcestateentry.go
+++ b/internal/chezmoi/sourcestateentry.go
@@ -12,7 +12,7 @@ import (
type SourceStateEntry interface {
zerolog.LogObjectMarshaler
Evaluate() error
- Order() int
+ Order() ScriptOrder
SourceRelPath() SourceRelPath
TargetStateEntry(destSystem System, destDirAbsPath AbsPath) (TargetStateEntry, error)
}
@@ -59,8 +59,8 @@ func (s *SourceStateDir) MarshalZerologObject(e *zerolog.Event) {
}
// Order returns s's order.
-func (s *SourceStateDir) Order() int {
- return 0
+func (s *SourceStateDir) Order() ScriptOrder {
+ return ScriptOrderDuring
}
// SourceRelPath returns s's source relative path.
@@ -98,7 +98,7 @@ func (s *SourceStateFile) MarshalZerologObject(e *zerolog.Event) {
}
// Order returns s's order.
-func (s *SourceStateFile) Order() int {
+func (s *SourceStateFile) Order() ScriptOrder {
return s.Attr.Order
}
@@ -127,8 +127,8 @@ func (s *SourceStateRemove) MarshalZerologObject(e *zerolog.Event) {
}
// Order returns s's order.
-func (s *SourceStateRemove) Order() int {
- return 0
+func (s *SourceStateRemove) Order() ScriptOrder {
+ return ScriptOrderDuring
}
// SourceRelPath returns s's source relative path.
@@ -154,8 +154,8 @@ func (s *SourceStateRenameDir) MarshalZerologObject(e *zerolog.Event) {
}
// Order returns s's order.
-func (s *SourceStateRenameDir) Order() int {
- return -1
+func (s *SourceStateRenameDir) Order() ScriptOrder {
+ return ScriptOrderBefore
}
// SourceRelPath returns s's source relative path.
diff --git a/internal/cmd/chattrcmd.go b/internal/cmd/chattrcmd.go
index b7323f89b5d..6fcb5fdb6de 100644
--- a/internal/cmd/chattrcmd.go
+++ b/internal/cmd/chattrcmd.go
@@ -142,24 +142,24 @@ func (m boolModifier) modify(b bool) bool {
}
// modify returns the modified value of order.
-func (m orderModifier) modify(order int) int {
+func (m orderModifier) modify(order chezmoi.ScriptOrder) chezmoi.ScriptOrder {
switch m {
case orderModifierSetBefore:
- return -1
+ return chezmoi.ScriptOrderBefore
case orderModifierClearBefore:
- if order < 0 {
- return 0
+ if order == chezmoi.ScriptOrderBefore {
+ return chezmoi.ScriptOrderDuring
}
return order
case orderModifierLeaveUnchanged:
return order
case orderModifierClearAfter:
- if order > 0 {
- return 0
+ if order == chezmoi.ScriptOrderAfter {
+ return chezmoi.ScriptOrderDuring
}
return order
case orderModifierSetAfter:
- return 1
+ return chezmoi.ScriptOrderAfter
default:
panic(fmt.Sprintf("%d: unknown order modifier", m))
}
|
chore
|
Improve type safety of run_ script ordering
|
a68cd95480271593c5546000cd3e8b96e7156e60
|
2022-10-11 04:10:17
|
Tom Payne
|
chore: Refactor 1Password account map
| false
|
diff --git a/pkg/cmd/onepasswordtemplatefuncs.go b/pkg/cmd/onepasswordtemplatefuncs.go
index 11a64ea67e8..d9bf0b5a152 100644
--- a/pkg/cmd/onepasswordtemplatefuncs.go
+++ b/pkg/cmd/onepasswordtemplatefuncs.go
@@ -409,45 +409,7 @@ func (c *Config) onepasswordAccount(key string) string {
panic(fmt.Errorf("no 1Password account found matching %s", key))
}
-// Shorthand names have been removed from 1Password CLI v2 when biometric
-// authentication is used. Mostly, this does not matter. However, this function
-// builds a better set of aliases that can be used in the `"account" field`.
-// The following values returned from `op account list` will always be mapped
-// to the AccountUUID during the actual call.
-//
-// Given the following values:
-//
-// ```json
-// [
-//
-// {
-// "url": "account1.1password.ca",
-// "email": "[email protected]",
-// "user_uuid": "some-user-uuid",
-// "account_uuid": "some-account-uuid"
-// }
-//
-// ]
-// ```
-//
-// The following values can be used in the `account` parameter and the value
-// `some-account-uuid` will be passed as the `--account` parameter to `op`.
-//
-// - `some-account-uuid`
-// - `some-user-uuid`
-// - `account1.1password.ca`
-// - `account1`
-// - `[email protected]`
-// - `my`
-// - `[email protected]`
-// - `my@account1`
-//
-// If there are multiple accounts and *any* value exists more than once, that
-// value will be removed from the account mapping. That is, if you are signed
-// into `[email protected]` and `[email protected]` for `account1.1password.ca`, then
-// `account1.1password.ca` will not be a valid lookup value, but `my@account1`,
-// `[email protected]`, `your@account1`, and
-// `[email protected]` would all be valid lookups.
+// onepasswordAccounts returns a map of keys to unique account UUIDs.
func (c *Config) onepasswordAccounts() (map[string]string, error) {
if c.Onepassword.accountMap != nil || c.Onepassword.accountMapErr != nil {
return c.Onepassword.accountMap, c.Onepassword.accountMapErr
@@ -469,79 +431,13 @@ func (c *Config) onepasswordAccounts() (map[string]string, error) {
return nil, c.Onepassword.accountMapErr
}
- var data []onepasswordAccount
-
- if err := json.Unmarshal(output, &data); err != nil {
+ var accounts []onepasswordAccount
+ if err := json.Unmarshal(output, &accounts); err != nil {
c.Onepassword.accountMapErr = err
return nil, c.Onepassword.accountMapErr
}
- collisions := make(map[string]bool)
- result := make(map[string]string)
-
- for _, account := range data {
- result[account.UserUUID] = account.AccountUUID
- result[account.AccountUUID] = account.AccountUUID
-
- if _, exists := result[account.URL]; exists {
- collisions[account.URL] = true
- } else {
- result[account.URL] = account.AccountUUID
- }
-
- parts := strings.SplitN(account.URL, ".", 2)
- accountName := parts[0]
-
- parts = strings.SplitN(account.Email, "@", 2)
- emailName := parts[0]
-
- userAccountName := emailName + "@" + accountName
- userAccountURL := emailName + "@" + account.URL
-
- if _, exists := result[accountName]; exists {
- collisions[accountName] = true
- } else {
- result[accountName] = account.AccountUUID
- }
-
- if _, exists := result[account.Email]; exists {
- collisions[account.Email] = true
- } else {
- result[account.Email] = account.AccountUUID
- }
-
- if _, exists := result[emailName]; exists {
- collisions[emailName] = true
- } else {
- result[emailName] = account.AccountUUID
- }
-
- if _, exists := result[userAccountName]; exists {
- collisions[userAccountName] = true
- } else {
- result[userAccountName] = account.AccountUUID
- }
-
- if _, exists := result[userAccountURL]; exists {
- collisions[userAccountURL] = true
- } else {
- result[userAccountURL] = account.AccountUUID
- }
-
- if account.Shorthand != "" {
- if _, exists := result[account.Shorthand]; exists {
- collisions[account.Shorthand] = true
- } else {
- result[account.Shorthand] = account.AccountUUID
- }
- }
- }
-
- for k := range collisions {
- delete(result, k)
- }
-
- c.Onepassword.accountMap = result
+ c.Onepassword.accountMap = onepasswordAccountMap(accounts)
return c.Onepassword.accountMap, c.Onepassword.accountMapErr
}
@@ -604,6 +500,49 @@ func (c *Config) newOnepasswordArgs(baseArgs, userArgs []string) (*onepasswordAr
return a, nil
}
+// onepasswordAccountMap returns a map of unique IDs to account UUIDs.
+func onepasswordAccountMap(accounts []onepasswordAccount) map[string]string {
+ // Build a map of keys to account UUIDs.
+ accountsMap := make(map[string][]string)
+ for _, account := range accounts {
+ keys := []string{
+ account.URL,
+ account.Email,
+ account.UserUUID,
+ account.AccountUUID,
+ account.Shorthand,
+ }
+
+ accountName, _, accountNameOk := strings.Cut(account.URL, ".")
+ if accountNameOk {
+ keys = append(keys, accountName)
+ }
+
+ emailName, _, emailNameOk := strings.Cut(account.Email, "@")
+ if emailNameOk {
+ keys = append(keys, emailName, emailName+"@"+account.URL)
+ }
+
+ if accountNameOk && emailNameOk {
+ keys = append(keys, emailName+"@"+accountName)
+ }
+
+ for _, key := range keys {
+ accountsMap[key] = append(accountsMap[key], account.AccountUUID)
+ }
+ }
+
+ // Select unique, non-empty keys.
+ accountMap := make(map[string]string)
+ for key, values := range accountsMap {
+ if key != "" && len(values) == 1 {
+ accountMap[key] = values[0]
+ }
+ }
+
+ return accountMap
+}
+
// onepasswordUniqueSessionToken will look for any session tokens in the
// environment. If it finds exactly one then it will return it.
func onepasswordUniqueSessionToken(environ []string) string {
diff --git a/pkg/cmd/onepasswordtemplatefuncs_test.go b/pkg/cmd/onepasswordtemplatefuncs_test.go
new file mode 100644
index 00000000000..ce53ee2e5d9
--- /dev/null
+++ b/pkg/cmd/onepasswordtemplatefuncs_test.go
@@ -0,0 +1,139 @@
+package cmd
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestOnepasswordAccountMap(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ accounts []onepasswordAccount
+ expected map[string]string
+ }{
+ {
+ name: "single_account_without_shorthand",
+ accounts: []onepasswordAccount{
+ {
+ URL: "account1.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-user-uuid",
+ AccountUUID: "some-account-uuid",
+ },
+ },
+ expected: map[string]string{
+ "account1.1password.ca": "some-account-uuid",
+ "account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my@account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my": "some-account-uuid",
+ "some-account-uuid": "some-account-uuid",
+ "some-user-uuid": "some-account-uuid",
+ },
+ },
+ {
+ name: "single_account_with_shorthand",
+ accounts: []onepasswordAccount{
+ {
+ URL: "account1.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-user-uuid",
+ AccountUUID: "some-account-uuid",
+ Shorthand: "some-account-shorthand",
+ },
+ },
+ expected: map[string]string{
+ "account1.1password.ca": "some-account-uuid",
+ "account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my@account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my": "some-account-uuid",
+ "some-account-shorthand": "some-account-uuid",
+ "some-account-uuid": "some-account-uuid",
+ "some-user-uuid": "some-account-uuid",
+ },
+ },
+ {
+ name: "multiple_unambiguous_accounts",
+ accounts: []onepasswordAccount{
+ {
+ URL: "account1.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-user-uuid",
+ AccountUUID: "some-account-uuid",
+ Shorthand: "some-account-shorthand",
+ },
+ {
+ URL: "account2.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-other-user-uuid",
+ AccountUUID: "some-other-account-uuid",
+ Shorthand: "some-other-account-shorthand",
+ },
+ },
+ expected: map[string]string{
+ "account1.1password.ca": "some-account-uuid",
+ "account1": "some-account-uuid",
+ "account2.1password.ca": "some-other-account-uuid",
+ "account2": "some-other-account-uuid",
+ "[email protected]": "some-other-account-uuid",
+ "me@account2": "some-other-account-uuid",
+ "[email protected]": "some-other-account-uuid",
+ "me": "some-other-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my@account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my": "some-account-uuid",
+ "some-account-shorthand": "some-account-uuid",
+ "some-account-uuid": "some-account-uuid",
+ "some-other-account-shorthand": "some-other-account-uuid",
+ "some-other-account-uuid": "some-other-account-uuid",
+ "some-other-user-uuid": "some-other-account-uuid",
+ "some-user-uuid": "some-account-uuid",
+ },
+ },
+ {
+ name: "multiple_ambiguous_accounts",
+ accounts: []onepasswordAccount{
+ {
+ URL: "account1.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-user-uuid",
+ AccountUUID: "some-account-uuid",
+ Shorthand: "some-account-shorthand",
+ },
+ {
+ URL: "account1.1password.ca",
+ Email: "[email protected]",
+ UserUUID: "some-other-user-uuid",
+ AccountUUID: "some-other-account-uuid",
+ Shorthand: "some-other-account-shorthand",
+ },
+ },
+ expected: map[string]string{
+ "[email protected]": "some-account-uuid",
+ "my@account1": "some-account-uuid",
+ "[email protected]": "some-account-uuid",
+ "my": "some-account-uuid",
+ "some-account-shorthand": "some-account-uuid",
+ "some-account-uuid": "some-account-uuid",
+ "some-other-account-shorthand": "some-other-account-uuid",
+ "some-other-account-uuid": "some-other-account-uuid",
+ "some-other-user-uuid": "some-other-account-uuid",
+ "some-user-uuid": "some-account-uuid",
+ "[email protected]": "some-other-account-uuid",
+ "your@account1": "some-other-account-uuid",
+ "[email protected]": "some-other-account-uuid",
+ "your": "some-other-account-uuid",
+ },
+ },
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ actual := onepasswordAccountMap(tc.accounts)
+ assert.Equal(t, tc.expected, actual)
+ })
+ }
+}
|
chore
|
Refactor 1Password account map
|
984cab28ee048e44e7b8923d4c142896f9499e9a
|
2022-02-20 04:07:27
|
Tom Payne
|
chore: Propagate CHEZMOI_GITHUB_TOKEN to tests to avoid rate limits
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1c927c5195f..e194aad222f 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -84,6 +84,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh alpine )
test-archlinux:
@@ -94,6 +96,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh archlinux )
test-debian-i386:
@@ -123,6 +127,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh fedora )
test-freebsd:
@@ -175,6 +181,8 @@ jobs:
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -race ./...
- name: Test install.sh
@@ -254,10 +262,14 @@ jobs:
go run . --version
- name: Test (umask 022)
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o022" -race ./...
- name: Test (umask 002)
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/pkg/chezmoitest.umaskStr=0o002" -race ./...
- name: Test install.sh
@@ -358,6 +370,8 @@ jobs:
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test ./...
test-ubuntu-go1-18:
@@ -395,6 +409,8 @@ jobs:
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go1.18rc1 test ./...
test-windows:
@@ -422,6 +438,8 @@ jobs:
run: |
go run . --version
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -race ./...
- name: Test install.ps1
@@ -438,6 +456,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Test
+ env:
+ CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh voidlinux )
check:
|
chore
|
Propagate CHEZMOI_GITHUB_TOKEN to tests to avoid rate limits
|
46e13edd60e24af35d126ea4aa54c79b58877d79
|
2023-09-05 02:28:04
|
Tom Payne
|
fix: Ensure default template data when reading .chezmoidata in subdir
| false
|
diff --git a/internal/chezmoi/sourcestate.go b/internal/chezmoi/sourcestate.go
index 3a32c49d5e1..d95d56bea83 100644
--- a/internal/chezmoi/sourcestate.go
+++ b/internal/chezmoi/sourcestate.go
@@ -114,6 +114,7 @@ type SourceState struct {
defaultTemplateDataFunc func() map[string]any
templateDataOnly bool
readTemplateData bool
+ defaultTemplateData map[string]any
userTemplateData map[string]any
priorityTemplateData map[string]any
scriptEnv []string
@@ -1289,9 +1290,10 @@ func (s *SourceState) TemplateData() map[string]any {
if s.templateData == nil {
s.templateData = make(map[string]any)
if s.defaultTemplateDataFunc != nil {
- RecursiveMerge(s.templateData, s.defaultTemplateDataFunc())
+ s.defaultTemplateData = s.defaultTemplateDataFunc()
s.defaultTemplateDataFunc = nil
}
+ RecursiveMerge(s.templateData, s.defaultTemplateData)
RecursiveMerge(s.templateData, s.userTemplateData)
RecursiveMerge(s.templateData, s.priorityTemplateData)
}
diff --git a/internal/cmd/applycmd_test.go b/internal/cmd/applycmd_test.go
index bd247d73fcd..08a8b211852 100644
--- a/internal/cmd/applycmd_test.go
+++ b/internal/cmd/applycmd_test.go
@@ -230,3 +230,19 @@ func TestIssue3206(t *testing.T) {
assert.NoError(t, newTestConfig(t, fileSystem).execute([]string{"apply"}))
})
}
+
+func TestIssue3216(t *testing.T) {
+ chezmoitest.WithTestFS(t, map[string]any{
+ "/home/user": map[string]any{
+ ".local/share/chezmoi": map[string]any{
+ ".chezmoiignore": "",
+ "dot_config/private_expanso/match": map[string]any{
+ ".chezmoidata.yaml": "",
+ "greek.yml.tmpl": "{{ .chezmoi.os }}",
+ },
+ },
+ },
+ }, func(fileSystem vfs.FS) {
+ assert.NoError(t, newTestConfig(t, fileSystem).execute([]string{"apply"}))
+ })
+}
|
fix
|
Ensure default template data when reading .chezmoidata in subdir
|
791ab022c216925a0e04705d38861fc9316dff39
|
2025-02-25 06:14:22
|
Tom Payne
|
chore: Update dependencies
| false
|
diff --git a/go.mod b/go.mod
index e5a7f75f159..9a55ebc33c4 100644
--- a/go.mod
+++ b/go.mod
@@ -35,7 +35,7 @@ require (
github.com/muesli/combinator v0.3.0
github.com/muesli/termenv v0.16.0
github.com/pelletier/go-toml/v2 v2.2.3
- github.com/rogpeppe/go-internal v1.13.1
+ github.com/rogpeppe/go-internal v1.14.0
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
@@ -51,9 +51,9 @@ require (
github.com/zricethezav/gitleaks/v8 v8.24.0
go.etcd.io/bbolt v1.4.0
go.uber.org/automaxprocs v1.6.0
- golang.org/x/crypto v0.34.0
- golang.org/x/crypto/x509roots/fallback v0.0.0-20250222003138-f66f74b0a406
- golang.org/x/oauth2 v0.26.0
+ golang.org/x/crypto v0.35.0
+ golang.org/x/crypto/x509roots/fallback v0.0.0-20250224173925-7292932d45d5
+ golang.org/x/oauth2 v0.27.0
golang.org/x/sync v0.11.0
golang.org/x/sys v0.30.0
golang.org/x/term v0.29.0
@@ -171,7 +171,7 @@ require (
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yuin/goldmark v1.7.8 // indirect
- github.com/yuin/goldmark-emoji v1.0.4 // indirect
+ github.com/yuin/goldmark-emoji v1.0.5 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
diff --git a/go.sum b/go.sum
index 49dad7e3547..ba72d82f07f 100644
--- a/go.sum
+++ b/go.sum
@@ -474,8 +474,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
-github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
-github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
+github.com/rogpeppe/go-internal v1.14.0 h1:unbRd941gNa8SS77YznHXOYVBDgWcF9xhzECdm8juZc=
+github.com/rogpeppe/go-internal v1.14.0/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
@@ -575,8 +575,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
-github.com/yuin/goldmark-emoji v1.0.4 h1:vCwMkPZSNefSUnOW2ZKRUjBSD5Ok3W78IXhGxxAEF90=
-github.com/yuin/goldmark-emoji v1.0.4/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
+github.com/yuin/goldmark-emoji v1.0.5 h1:EMVWyCGPlXJfUXBXpuMu+ii3TIaxbVBnEX9uaDC4cIk=
+github.com/yuin/goldmark-emoji v1.0.5/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
@@ -632,10 +632,10 @@ go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.34.0 h1:+/C6tk6rf/+t5DhUketUbD1aNGqiSX3j15Z6xuIDlBA=
-golang.org/x/crypto v0.34.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
-golang.org/x/crypto/x509roots/fallback v0.0.0-20250222003138-f66f74b0a406 h1:d/w3+20viTqZ/22X96q+Fjb+/Ovnr40hnX8V3+Ry1Yg=
-golang.org/x/crypto/x509roots/fallback v0.0.0-20250222003138-f66f74b0a406/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU=
+golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
+golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
+golang.org/x/crypto/x509roots/fallback v0.0.0-20250224173925-7292932d45d5 h1:gsQ4vZn6BGiOSnBKNWbPlPLaUYpimGhxhUfx1QFf8g4=
+golang.org/x/crypto/x509roots/fallback v0.0.0-20250224173925-7292932d45d5/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -650,8 +650,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
-golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
-golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
+golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
+golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go
index 6000a4f0ab0..cd6941e0838 100644
--- a/internal/cmd/main_test.go
+++ b/internal/cmd/main_test.go
@@ -52,16 +52,16 @@ func TestMain(m *testing.M) {
flag.StringVar(&filterRegex, "filter", "", "regex to filter test scripts")
flag.Parse()
}
- os.Exit(testscript.RunMain(m, map[string]func() int{
- "chezmoi": func() int {
- return cmd.Main(cmd.VersionInfo{
+ testscript.Main(m, map[string]func(){
+ "chezmoi": func() {
+ os.Exit(cmd.Main(cmd.VersionInfo{
Version: "v2.0.0+test",
Commit: "HEAD",
Date: time.Now().UTC().Format(time.RFC3339),
BuiltBy: "testscript",
- }, os.Args[1:])
+ }, os.Args[1:]))
},
- }))
+ })
}
func TestScript(t *testing.T) {
|
chore
|
Update dependencies
|
fd690b402893edbbcad0a15f635c2895ce0f6eda
|
2021-12-11 19:16:22
|
Tom Payne
|
docs: Document that init --purge removes cache directory
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index df4fc07ebc0..dd0d22fa41a 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -1454,8 +1454,8 @@ configuration file is created using that file as a template.
Then, if the `--apply` flag is passed, `chezmoi apply` is run.
-Then, if the `--purge` flag is passed, chezmoi will remove the source directory
-and its config directory.
+Then, if the `--purge` flag is passed, chezmoi will remove its source, config,
+and cache directories.
Finally, if the `--purge-binary` is passed, chezmoi will attempt to remove its
own binary.
|
docs
|
Document that init --purge removes cache directory
|
10a07ca6d16ec13e456d1668a54918971a2921f8
|
2022-07-23 03:28:31
|
Tom Payne
|
chore: Switch to macOS 12 for tests requiring Vagrant
| false
|
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f08f25ca5b2..323d65374e8 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -75,7 +75,7 @@ jobs:
test-debian-i386:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- runs-on: macos-10.15
+ runs-on: macos-12
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d
@@ -101,7 +101,7 @@ jobs:
test-freebsd:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- runs-on: macos-10.15
+ runs-on: macos-12
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d
@@ -147,7 +147,7 @@ jobs:
test-openbsd:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- runs-on: macos-10.15
+ runs-on: macos-12
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d
|
chore
|
Switch to macOS 12 for tests requiring Vagrant
|
02a817ab24714403767d31c06d85cf9a42ba5125
|
2024-10-25 01:19:07
|
Tom Payne
|
chore: Update GitHub Actions
| false
|
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index feb81861067..fb89be2fc1f 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -16,7 +16,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: go-version
id: go-version
run: |
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml
index 55b575de46b..249610aeadf 100644
--- a/.github/workflows/installer.yml
+++ b/.github/workflows/installer.yml
@@ -17,7 +17,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
with:
@@ -36,7 +36,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: reviewdog/action-misspell@ef8b22c1cca06c8d306fc6be302c3dab0f6ca12f
with:
locale: US
@@ -54,7 +54,7 @@ jobs:
env:
BINARY: ${{ matrix.os == 'windows-2022' && 'bin/chezmoi.exe' || 'bin/chezmoi' }}
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: test-${{ matrix.os }}-local
shell: bash
run: |
@@ -80,7 +80,7 @@ jobs:
env:
BINARY: ${{ matrix.os == 'windows-2022' && 'bin/chezmoi.exe' || 'bin/chezmoi' }}
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: test-${{ matrix.os }}-local-pwsh
shell: pwsh
run: |
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 56498d48c22..e65a8eeac8a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -33,7 +33,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
with:
@@ -59,7 +59,7 @@ jobs:
permissions:
security-events: write
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 1
- uses: github/codeql-action/init@e2b3eafc8d227b0241d48be5f425d47c2d750a13
@@ -71,7 +71,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: reviewdog/action-misspell@ef8b22c1cca06c8d306fc6be302c3dab0f6ca12f
with:
locale: US
@@ -83,7 +83,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
@@ -96,7 +96,7 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
@@ -109,8 +109,8 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- name: build
@@ -144,8 +144,8 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: oldstable
- name: build
@@ -177,10 +177,10 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- name: install-release-dependencies
@@ -238,10 +238,10 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- name: install-age
@@ -280,8 +280,8 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d
@@ -302,8 +302,8 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
@@ -328,10 +328,10 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- name: generate
@@ -384,8 +384,8 @@ jobs:
permissions:
contents: read
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: stable
- uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
@@ -422,10 +422,10 @@ jobs:
run: snapcraft whoami
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da
@@ -450,10 +450,10 @@ jobs:
permissions:
contents: write
steps:
- - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
+ - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version: ${{ env.GO_VERSION }}
- uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d
|
chore
|
Update GitHub Actions
|
808ccb776de869cbc08c1c5ed8c2270d79a643a3
|
2021-11-06 22:31:48
|
Tom Payne
|
docs: Fix docs now that parent directories are created automatically
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index c056faf3bb8..665fb379eb2 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -736,9 +736,9 @@ externals to be included on different machines.
Entries are indexed by target name relative to the directory of the
`.chezmoiexternal.<format>` file, and must have a `type` and a `url` field.
-`type` can be either `file` or `archive`. All of the entries parent directories
-must be defined in the source state. chezmoi will not create parent directories
-automatically.
+`type` can be either `file` or `archive`. If the entry's parent directories do
+not already exist in the source state then chezmoi will create them as regular
+directories.
Entries may have the following fields:
|
docs
|
Fix docs now that parent directories are created automatically
|
dc991694c3e73c642f53b8233335eb9db7b17f76
|
2024-03-01 11:21:16
|
Braden Hilton
|
fix: Make splitList return []any
| false
|
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 606cf611c90..42dd1b5a775 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -398,6 +398,7 @@ func newConfig(options ...configOption) (*Config, error) {
// Override sprig template functions. Delete them from the template function
// map first to avoid a duplicate function panic.
delete(c.templateFuncs, "fromJson")
+ delete(c.templateFuncs, "splitList")
delete(c.templateFuncs, "toPrettyJson")
// The completion template function is added in persistentPreRunRootE as
@@ -477,6 +478,7 @@ func newConfig(options ...configOption) (*Config, error) {
"secret": c.secretTemplateFunc,
"secretJSON": c.secretJSONTemplateFunc,
"setValueAtPath": c.setValueAtPathTemplateFunc,
+ "splitList": c.splitListTemplateFunc,
"stat": c.statTemplateFunc,
"toIni": c.toIniTemplateFunc,
"toPrettyJson": c.toPrettyJsonTemplateFunc,
diff --git a/internal/cmd/templatefuncs.go b/internal/cmd/templatefuncs.go
index 0e930da5eba..f9628e32c33 100644
--- a/internal/cmd/templatefuncs.go
+++ b/internal/cmd/templatefuncs.go
@@ -482,6 +482,15 @@ func (c *Config) setValueAtPathTemplateFunc(path, value, dict any) any {
return result
}
+func (c *Config) splitListTemplateFunc(sep, s string) []any {
+ strSlice := strings.Split(s, sep)
+ result := make([]interface{}, len(strSlice))
+ for i, v := range strSlice {
+ result[i] = v
+ }
+ return result
+}
+
func (c *Config) statTemplateFunc(name string) any {
switch fileInfo, err := c.fileSystem.Stat(name); {
case err == nil:
diff --git a/internal/cmd/testdata/scripts/templatefuncs.txtar b/internal/cmd/testdata/scripts/templatefuncs.txtar
index d23e61febeb..bbfd45d00b5 100644
--- a/internal/cmd/testdata/scripts/templatefuncs.txtar
+++ b/internal/cmd/testdata/scripts/templatefuncs.txtar
@@ -191,6 +191,10 @@ stdout '^value2$'
exec chezmoi execute-template '{{ dict "key" "value" | toYaml }}'
stdout '^key: value$'
+# test that the overridden splitList function's output is compatible with quoteList
+exec chezmoi execute-template '{{ "a b" | splitList " " | quoteList }}'
+stdout '["a" "b"]'
+
-- bin/chezmoi-output-test --
#!/bin/sh
|
fix
|
Make splitList return []any
|
50d08d626479f16776234be4463c14e5362bf83f
|
2022-02-08 07:21:09
|
Tom Payne
|
chore: Remove raiseTemplateError function
| false
|
diff --git a/pkg/cmd/bitwardentemplatefuncs.go b/pkg/cmd/bitwardentemplatefuncs.go
index e71f75be0cb..d1052b76928 100644
--- a/pkg/cmd/bitwardentemplatefuncs.go
+++ b/pkg/cmd/bitwardentemplatefuncs.go
@@ -14,8 +14,7 @@ type bitwardenConfig struct {
func (c *Config) bitwardenAttachmentTemplateFunc(name, itemid string) string {
output, err := c.bitwardenOutput([]string{"attachment", name, "--itemid", itemid, "--raw"})
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(output)
}
@@ -23,15 +22,13 @@ func (c *Config) bitwardenAttachmentTemplateFunc(name, itemid string) string {
func (c *Config) bitwardenFieldsTemplateFunc(args ...string) map[string]interface{} {
output, err := c.bitwardenOutput(args)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
var data struct {
Fields []map[string]interface{} `json:"fields"`
}
if err := json.Unmarshal(output, &data); err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Bitwarden.Command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Bitwarden.Command, args, output, err))
}
result := make(map[string]interface{})
for _, field := range data.Fields {
@@ -45,13 +42,11 @@ func (c *Config) bitwardenFieldsTemplateFunc(args ...string) map[string]interfac
func (c *Config) bitwardenTemplateFunc(args ...string) map[string]interface{} {
output, err := c.bitwardenOutput(args)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
var data map[string]interface{}
if err := json.Unmarshal(output, &data); err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Bitwarden.Command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Bitwarden.Command, args, output, err))
}
return data
}
diff --git a/pkg/cmd/encryptiontemplatefuncs.go b/pkg/cmd/encryptiontemplatefuncs.go
index 77e205b89bb..5f7dc8cbe71 100644
--- a/pkg/cmd/encryptiontemplatefuncs.go
+++ b/pkg/cmd/encryptiontemplatefuncs.go
@@ -3,8 +3,7 @@ package cmd
func (c *Config) decryptTemplateFunc(ciphertext string) string {
plaintextBytes, err := c.encryption.Decrypt([]byte(ciphertext))
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(plaintextBytes)
}
@@ -12,8 +11,7 @@ func (c *Config) decryptTemplateFunc(ciphertext string) string {
func (c *Config) encryptTemplateFunc(plaintext string) string {
ciphertextBytes, err := c.encryption.Encrypt([]byte(plaintext))
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(ciphertextBytes)
}
diff --git a/pkg/cmd/executetemplatecmd.go b/pkg/cmd/executetemplatecmd.go
index fd7848b6429..30868ca8dbf 100644
--- a/pkg/cmd/executetemplatecmd.go
+++ b/pkg/cmd/executetemplatecmd.go
@@ -72,8 +72,7 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error
return args[0]
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return false
+ panic(err)
}
},
"promptInt": func(prompt string, args ...int) int {
@@ -87,8 +86,7 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error
return args[0]
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return 0
+ panic(err)
}
},
"promptString": func(prompt string, args ...string) string {
@@ -105,8 +103,7 @@ func (c *Config) runExecuteTemplateCmd(cmd *cobra.Command, args []string) error
return args[0]
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return ""
+ panic(err)
}
},
"stdinIsATTY": func() bool {
diff --git a/pkg/cmd/githubtemplatefuncs.go b/pkg/cmd/githubtemplatefuncs.go
index 6ea64084cd2..c6473cc7485 100644
--- a/pkg/cmd/githubtemplatefuncs.go
+++ b/pkg/cmd/githubtemplatefuncs.go
@@ -24,8 +24,7 @@ func (c *Config) gitHubKeysTemplateFunc(user string) []*github.Key {
httpClient, err := c.getHTTPClient()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
gitHubClient := chezmoi.NewGitHubClient(ctx, httpClient)
@@ -36,8 +35,7 @@ func (c *Config) gitHubKeysTemplateFunc(user string) []*github.Key {
for {
keys, resp, err := gitHubClient.Users.ListKeys(ctx, user, opts)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
allKeys = append(allKeys, keys...)
if resp.NextPage == 0 {
@@ -56,8 +54,7 @@ func (c *Config) gitHubKeysTemplateFunc(user string) []*github.Key {
func (c *Config) gitHubLatestReleaseTemplateFunc(userRepo string) *github.RepositoryRelease {
user, repo, ok := chezmoi.CutString(userRepo, "/")
if !ok {
- raiseTemplateError(fmt.Errorf("%s: not a user/repo", userRepo))
- return nil
+ panic(fmt.Errorf("%s: not a user/repo", userRepo))
}
if release := c.gitHub.latestReleaseCache[user][repo]; release != nil {
@@ -69,15 +66,13 @@ func (c *Config) gitHubLatestReleaseTemplateFunc(userRepo string) *github.Reposi
httpClient, err := c.getHTTPClient()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
gitHubClient := chezmoi.NewGitHubClient(ctx, httpClient)
release, _, err := gitHubClient.Repositories.GetLatestRelease(ctx, user, repo)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
if c.gitHub.latestReleaseCache == nil {
diff --git a/pkg/cmd/gopasstemplatefuncs.go b/pkg/cmd/gopasstemplatefuncs.go
index 468823d8e0f..62ef952bf8f 100644
--- a/pkg/cmd/gopasstemplatefuncs.go
+++ b/pkg/cmd/gopasstemplatefuncs.go
@@ -29,8 +29,7 @@ type gopassConfig struct {
func (c *Config) gopassTemplateFunc(id string) string {
if !c.Gopass.versionOK {
if err := c.gopassVersionCheck(); err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
c.Gopass.versionOK = true
}
@@ -42,8 +41,7 @@ func (c *Config) gopassTemplateFunc(id string) string {
args := []string{"show", "--password", id}
output, err := c.gopassOutput(args...)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
passwordBytes, _, _ := chezmoi.CutBytes(output, []byte{'\n'})
@@ -60,8 +58,7 @@ func (c *Config) gopassTemplateFunc(id string) string {
func (c *Config) gopassRawTemplateFunc(id string) string {
if !c.Gopass.versionOK {
if err := c.gopassVersionCheck(); err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
c.Gopass.versionOK = true
}
@@ -73,8 +70,7 @@ func (c *Config) gopassRawTemplateFunc(id string) string {
args := []string{"show", "--noparsing", id}
output, err := c.gopassOutput(args...)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
if c.Gopass.rawCache == nil {
diff --git a/pkg/cmd/inittemplatefuncs.go b/pkg/cmd/inittemplatefuncs.go
index a3715037bdf..f27346d11ef 100644
--- a/pkg/cmd/inittemplatefuncs.go
+++ b/pkg/cmd/inittemplatefuncs.go
@@ -12,8 +12,7 @@ import (
)
func (c *Config) exitInitTemplateFunc(code int) string {
- raiseTemplateError(chezmoi.ExitCodeError(code))
- return ""
+ panic(chezmoi.ExitCodeError(code))
}
func (c *Config) promptBoolInitTemplateFunc(field string, args ...bool) bool {
@@ -21,8 +20,7 @@ func (c *Config) promptBoolInitTemplateFunc(field string, args ...bool) bool {
case 0:
value, err := parseBool(c.promptStringInitTemplateFunc(field))
if err != nil {
- raiseTemplateError(err)
- return false
+ panic(err)
}
return value
case 1:
@@ -33,14 +31,12 @@ func (c *Config) promptBoolInitTemplateFunc(field string, args ...bool) bool {
}
value, err := parseBool(valueStr)
if err != nil {
- raiseTemplateError(err)
- return false
+ panic(err)
}
return value
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return false
+ panic(err)
}
}
@@ -49,8 +45,7 @@ func (c *Config) promptIntInitTemplateFunc(field string, args ...int64) int64 {
case 0:
value, err := strconv.ParseInt(c.promptStringInitTemplateFunc(field), 10, 64)
if err != nil {
- raiseTemplateError(err)
- return 0
+ panic(err)
}
return value
case 1:
@@ -61,14 +56,12 @@ func (c *Config) promptIntInitTemplateFunc(field string, args ...int64) int64 {
}
value, err := strconv.ParseInt(valueStr, 10, 64)
if err != nil {
- raiseTemplateError(err)
- return 0
+ panic(err)
}
return value
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return 0
+ panic(err)
}
}
@@ -77,8 +70,7 @@ func (c *Config) promptStringInitTemplateFunc(prompt string, args ...string) str
case 0:
value, err := c.readLine(prompt + "? ")
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return strings.TrimSpace(value)
case 1:
@@ -86,8 +78,7 @@ func (c *Config) promptStringInitTemplateFunc(prompt string, args ...string) str
promptStr := prompt + " (default " + strconv.Quote(defaultStr) + ")? "
switch value, err := c.readLine(promptStr); {
case err != nil:
- raiseTemplateError(err)
- return ""
+ panic(err)
case value == "":
return defaultStr
default:
@@ -95,8 +86,7 @@ func (c *Config) promptStringInitTemplateFunc(prompt string, args ...string) str
}
default:
err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
- raiseTemplateError(err)
- return ""
+ panic(err)
}
}
@@ -111,8 +101,7 @@ func (c *Config) stdinIsATTYInitTemplateFunc() bool {
func (c *Config) writeToStdout(args ...string) string {
for _, arg := range args {
if _, err := c.stdout.Write([]byte(arg)); err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
}
return ""
diff --git a/pkg/cmd/keepassxctemplatefuncs.go b/pkg/cmd/keepassxctemplatefuncs.go
index 9d249d10bc6..5921872c523 100644
--- a/pkg/cmd/keepassxctemplatefuncs.go
+++ b/pkg/cmd/keepassxctemplatefuncs.go
@@ -39,15 +39,13 @@ func (c *Config) keepassxcTemplateFunc(entry string) map[string]string {
}
if c.Keepassxc.Database.Empty() {
- raiseTemplateError(errors.New("keepassxc.database not set"))
- return nil
+ panic(errors.New("keepassxc.database not set"))
}
args := []string{"show"}
version, err := c.keepassxcVersion()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
if version.Compare(keepassxcNeedShowProtectedArgVersion) >= 0 {
args = append(args, "--show-protected")
@@ -56,14 +54,12 @@ func (c *Config) keepassxcTemplateFunc(entry string) map[string]string {
args = append(args, c.Keepassxc.Database.String(), entry)
output, err := c.keepassxcOutput(c.Keepassxc.Command, args)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
data, err := keypassxcParseOutput(output)
if err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Keepassxc.Command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Keepassxc.Command, args, output, err))
}
if c.Keepassxc.cache == nil {
@@ -84,15 +80,13 @@ func (c *Config) keepassxcAttributeTemplateFunc(entry, attribute string) string
}
if c.Keepassxc.Database.Empty() {
- raiseTemplateError(errors.New("keepassxc.database not set"))
- return ""
+ panic(errors.New("keepassxc.database not set"))
}
args := []string{"show", "--attributes", attribute, "--quiet"}
version, err := c.keepassxcVersion()
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
if version.Compare(keepassxcNeedShowProtectedArgVersion) >= 0 {
args = append(args, "--show-protected")
@@ -101,8 +95,7 @@ func (c *Config) keepassxcAttributeTemplateFunc(entry, attribute string) string
args = append(args, c.Keepassxc.Database.String(), entry)
output, err := c.keepassxcOutput(c.Keepassxc.Command, args)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
outputStr := string(bytes.TrimSpace(output))
diff --git a/pkg/cmd/keyringtemplatefuncs.go b/pkg/cmd/keyringtemplatefuncs.go
index 95d6f4b276d..2836af28e2c 100644
--- a/pkg/cmd/keyringtemplatefuncs.go
+++ b/pkg/cmd/keyringtemplatefuncs.go
@@ -25,8 +25,7 @@ func (c *Config) keyringTemplateFunc(service, user string) string {
}
password, err := keyring.Get(service, user)
if err != nil {
- raiseTemplateError(fmt.Errorf("%s %s: %w", service, user, err))
- return ""
+ panic(fmt.Errorf("%s %s: %w", service, user, err))
}
if c.keyring.cache == nil {
diff --git a/pkg/cmd/lastpasstemplatefuncs.go b/pkg/cmd/lastpasstemplatefuncs.go
index 06e6128c8f8..9efa669e3f7 100644
--- a/pkg/cmd/lastpasstemplatefuncs.go
+++ b/pkg/cmd/lastpasstemplatefuncs.go
@@ -32,15 +32,13 @@ type lastpassConfig struct {
func (c *Config) lastpassTemplateFunc(id string) []map[string]interface{} {
data, err := c.lastpassData(id)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
for _, d := range data {
if note, ok := d["note"].(string); ok {
d["note"], err = lastpassParseNote(note)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
}
}
@@ -50,8 +48,7 @@ func (c *Config) lastpassTemplateFunc(id string) []map[string]interface{} {
func (c *Config) lastpassRawTemplateFunc(id string) []map[string]interface{} {
data, err := c.lastpassData(id)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
return data
}
diff --git a/pkg/cmd/onepasswordtemplatefuncs.go b/pkg/cmd/onepasswordtemplatefuncs.go
index bafdad1f167..2e849007ed3 100644
--- a/pkg/cmd/onepasswordtemplatefuncs.go
+++ b/pkg/cmd/onepasswordtemplatefuncs.go
@@ -64,8 +64,7 @@ type onepasswordItemV2 struct {
func (c *Config) onepasswordTemplateFunc(userArgs ...string) map[string]interface{} {
version, err := c.onepasswordVersion()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
var baseArgs []string
@@ -75,28 +74,24 @@ func (c *Config) onepasswordTemplateFunc(userArgs ...string) map[string]interfac
case version.Major >= 2:
baseArgs = []string{"item", "get", "--format", "json"}
default:
- raiseTemplateError(unsupportedVersionError{
+ panic(unsupportedVersionError{
version: version,
})
- return nil
}
args, err := newOnepasswordArgs(baseArgs, userArgs)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
output, err := c.onepasswordOutput(args, withSessionToken)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
var data map[string]interface{}
if err := json.Unmarshal(output, &data); err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Onepassword.Command, args.args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Onepassword.Command, args.args, output, err))
}
return data
}
@@ -104,16 +99,14 @@ func (c *Config) onepasswordTemplateFunc(userArgs ...string) map[string]interfac
func (c *Config) onepasswordDetailsFieldsTemplateFunc(userArgs ...string) map[string]interface{} {
version, err := c.onepasswordVersion()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
switch {
case version.Major == 1:
item, err := c.onepasswordItemV1(userArgs)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
result := make(map[string]interface{})
@@ -127,8 +120,7 @@ func (c *Config) onepasswordDetailsFieldsTemplateFunc(userArgs ...string) map[st
case version.Major >= 2:
item, err := c.onepasswordItemV2(userArgs)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
result := make(map[string]interface{})
@@ -143,18 +135,16 @@ func (c *Config) onepasswordDetailsFieldsTemplateFunc(userArgs ...string) map[st
return result
default:
- raiseTemplateError(unsupportedVersionError{
+ panic(unsupportedVersionError{
version: version,
})
- return nil
}
}
func (c *Config) onepasswordDocumentTemplateFunc(userArgs ...string) string {
version, err := c.onepasswordVersion()
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
var baseArgs []string
@@ -164,22 +154,19 @@ func (c *Config) onepasswordDocumentTemplateFunc(userArgs ...string) string {
case version.Major >= 2:
baseArgs = []string{"document", "get"}
default:
- raiseTemplateError(unsupportedVersionError{
+ panic(unsupportedVersionError{
version: version,
})
- return ""
}
args, err := newOnepasswordArgs(baseArgs, userArgs)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
output, err := c.onepasswordOutput(args, withSessionToken)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(output)
}
@@ -187,16 +174,14 @@ func (c *Config) onepasswordDocumentTemplateFunc(userArgs ...string) string {
func (c *Config) onepasswordItemFieldsTemplateFunc(userArgs ...string) map[string]interface{} {
version, err := c.onepasswordVersion()
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
switch {
case version.Major == 1:
item, err := c.onepasswordItemV1(userArgs)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
result := make(map[string]interface{})
@@ -212,8 +197,7 @@ func (c *Config) onepasswordItemFieldsTemplateFunc(userArgs ...string) map[strin
case version.Major >= 2:
item, err := c.onepasswordItemV2(userArgs)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
result := make(map[string]interface{})
@@ -228,10 +212,9 @@ func (c *Config) onepasswordItemFieldsTemplateFunc(userArgs ...string) map[strin
return result
default:
- raiseTemplateError(unsupportedVersionError{
+ panic(unsupportedVersionError{
version: version,
})
- return nil
}
}
diff --git a/pkg/cmd/passtemplatefuncs.go b/pkg/cmd/passtemplatefuncs.go
index 573f36c997c..d267ec96f48 100644
--- a/pkg/cmd/passtemplatefuncs.go
+++ b/pkg/cmd/passtemplatefuncs.go
@@ -15,8 +15,7 @@ type passConfig struct {
func (c *Config) passTemplateFunc(id string) string {
output, err := c.passOutput(id)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
firstLine, _, _ := chezmoi.CutBytes(output, []byte{'\n'})
return string(bytes.TrimSpace(firstLine))
@@ -25,8 +24,7 @@ func (c *Config) passTemplateFunc(id string) string {
func (c *Config) passFieldsTemplateFunc(id string) map[string]string {
output, err := c.passOutput(id)
if err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
result := make(map[string]string)
@@ -41,8 +39,7 @@ func (c *Config) passFieldsTemplateFunc(id string) map[string]string {
func (c *Config) passRawTemplateFunc(id string) string {
output, err := c.passOutput(id)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(output)
}
diff --git a/pkg/cmd/secrettemplatefuncs.go b/pkg/cmd/secrettemplatefuncs.go
index 09b992e78d8..3cec6de7b13 100644
--- a/pkg/cmd/secrettemplatefuncs.go
+++ b/pkg/cmd/secrettemplatefuncs.go
@@ -25,8 +25,7 @@ func (c *Config) secretTemplateFunc(args ...string) string {
cmd.Stderr = c.stderr
output, err := c.baseSystem.IdempotentCmdOutput(cmd)
if err != nil {
- raiseTemplateError(newCmdOutputError(cmd, output, err))
- return ""
+ panic(newCmdOutputError(cmd, output, err))
}
value := string(bytes.TrimSpace(output))
@@ -50,14 +49,12 @@ func (c *Config) secretJSONTemplateFunc(args ...string) interface{} {
cmd.Stderr = c.stderr
output, err := c.baseSystem.IdempotentCmdOutput(cmd)
if err != nil {
- raiseTemplateError(newCmdOutputError(cmd, output, err))
- return nil
+ panic(newCmdOutputError(cmd, output, err))
}
var value interface{}
if err := json.Unmarshal(output, &value); err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Secret.Command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Secret.Command, args, output, err))
}
if c.Secret.jsonCache == nil {
diff --git a/pkg/cmd/templatefuncs.go b/pkg/cmd/templatefuncs.go
index 6e344aa429a..c0a20b43388 100644
--- a/pkg/cmd/templatefuncs.go
+++ b/pkg/cmd/templatefuncs.go
@@ -20,8 +20,7 @@ type ioregData struct {
func (c *Config) fromYamlTemplateFunc(s string) interface{} {
var data interface{}
if err := chezmoi.FormatYAML.Unmarshal([]byte(s), &data); err != nil {
- raiseTemplateError(err)
- return nil
+ panic(err)
}
return data
}
@@ -32,15 +31,14 @@ func (c *Config) includeTemplateFunc(filename string) string {
var err error
absPath, err = chezmoi.NewAbsPathFromExtPath(filename, c.homeDirAbsPath)
if err != nil {
- raiseTemplateError(err)
+ panic(err)
}
} else {
absPath = c.SourceDirAbsPath.JoinString(filename)
}
contents, err := c.fileSystem.ReadFile(absPath.String())
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(contents)
}
@@ -59,14 +57,12 @@ func (c *Config) ioregTemplateFunc() map[string]interface{} {
cmd := exec.Command(command, args...)
output, err := c.baseSystem.IdempotentCmdOutput(cmd)
if err != nil {
- raiseTemplateError(newCmdOutputError(cmd, output, err))
- return nil
+ panic(newCmdOutputError(cmd, output, err))
}
var value map[string]interface{}
if _, err := plist.Unmarshal(output, &value); err != nil {
- raiseTemplateError(newParseCmdOutputError(command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(command, args, output, err))
}
c.ioregData.value = value
return value
@@ -85,16 +81,14 @@ func (c *Config) lookPathTemplateFunc(file string) string {
case errors.Is(err, fs.ErrNotExist):
return ""
default:
- raiseTemplateError(err)
- return ""
+ panic(err)
}
}
func (c *Config) mozillaInstallHashTemplateFunc(path string) string {
mozillaInstallHash, err := mozillainstallhash.MozillaInstallHash(path)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return mozillaInstallHash
}
@@ -103,8 +97,7 @@ func (c *Config) outputTemplateFunc(name string, args ...string) string {
cmd := exec.Command(name, args...)
output, err := c.baseSystem.IdempotentCmdOutput(cmd)
if err != nil {
- raiseTemplateError(newCmdOutputError(cmd, output, err))
- return ""
+ panic(newCmdOutputError(cmd, output, err))
}
// FIXME we should be able to return output directly, but
// github.com/Masterminds/sprig's trim function only accepts strings
@@ -125,20 +118,14 @@ func (c *Config) statTemplateFunc(name string) interface{} {
case errors.Is(err, fs.ErrNotExist):
return nil
default:
- raiseTemplateError(err)
- return nil
+ panic(err)
}
}
func (c *Config) toYamlTemplateFunc(data interface{}) string {
yaml, err := chezmoi.FormatYAML.Marshal(data)
if err != nil {
- raiseTemplateError(err)
- return ""
+ panic(err)
}
return string(yaml)
}
-
-func raiseTemplateError(err error) {
- panic(err)
-}
diff --git a/pkg/cmd/vaulttemplatefuncs.go b/pkg/cmd/vaulttemplatefuncs.go
index 155653fc169..74a983d6bfd 100644
--- a/pkg/cmd/vaulttemplatefuncs.go
+++ b/pkg/cmd/vaulttemplatefuncs.go
@@ -22,14 +22,12 @@ func (c *Config) vaultTemplateFunc(key string) interface{} {
cmd.Stderr = c.stderr
output, err := c.baseSystem.IdempotentCmdOutput(cmd)
if err != nil {
- raiseTemplateError(newCmdOutputError(cmd, output, err))
- return nil
+ panic(newCmdOutputError(cmd, output, err))
}
var data interface{}
if err := json.Unmarshal(output, &data); err != nil {
- raiseTemplateError(newParseCmdOutputError(c.Vault.Command, args, output, err))
- return nil
+ panic(newParseCmdOutputError(c.Vault.Command, args, output, err))
}
if c.Vault.cache == nil {
|
chore
|
Remove raiseTemplateError function
|
d730991105b82c9d240fcb7e9338dfb10de7225c
|
2023-06-04 02:08:00
|
Tom Payne
|
fix: Fix init --debug flag
| false
|
diff --git a/pkg/chezmoi/archivereadersystem.go b/pkg/chezmoi/archivereadersystem.go
index c4ffe604872..5b11e6834ab 100644
--- a/pkg/chezmoi/archivereadersystem.go
+++ b/pkg/chezmoi/archivereadersystem.go
@@ -109,3 +109,8 @@ func (s *ArchiveReaderSystem) Readlink(name AbsPath) (string, error) {
}
return "", fs.ErrNotExist
}
+
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *ArchiveReaderSystem) UnderlyingSystem() System {
+ return s
+}
diff --git a/pkg/chezmoi/debugsystem.go b/pkg/chezmoi/debugsystem.go
index 9d7f63aa339..9cb661aebf1 100644
--- a/pkg/chezmoi/debugsystem.go
+++ b/pkg/chezmoi/debugsystem.go
@@ -186,6 +186,11 @@ func (s *DebugSystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *DebugSystem) UnderlyingSystem() System {
+ return s.system
+}
+
// WriteFile implements System.WriteFile.
func (s *DebugSystem) WriteFile(name AbsPath, data []byte, perm fs.FileMode) error {
err := s.system.WriteFile(name, data, perm)
diff --git a/pkg/chezmoi/dryrunsystem.go b/pkg/chezmoi/dryrunsystem.go
index 5b3b9279506..51cf6ba36b7 100644
--- a/pkg/chezmoi/dryrunsystem.go
+++ b/pkg/chezmoi/dryrunsystem.go
@@ -122,6 +122,11 @@ func (s *DryRunSystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *DryRunSystem) UnderlyingSystem() System {
+ return s.system
+}
+
// WriteFile implements System.WriteFile.
func (s *DryRunSystem) WriteFile(AbsPath, []byte, fs.FileMode) error {
s.setModified()
diff --git a/pkg/chezmoi/dumpsystem.go b/pkg/chezmoi/dumpsystem.go
index 6770e9f101c..3e316d6ed3e 100644
--- a/pkg/chezmoi/dumpsystem.go
+++ b/pkg/chezmoi/dumpsystem.go
@@ -119,6 +119,11 @@ func (s *DumpSystem) UnderlyingFS() vfs.FS {
return nil
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *DumpSystem) UnderlyingSystem() System {
+ return s
+}
+
// WriteFile implements System.WriteFile.
func (s *DumpSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error {
return s.setData(filename.String(), &fileData{
diff --git a/pkg/chezmoi/erroronwritesystem.go b/pkg/chezmoi/erroronwritesystem.go
index b7e952bdbe3..59ba2cf45ff 100644
--- a/pkg/chezmoi/erroronwritesystem.go
+++ b/pkg/chezmoi/erroronwritesystem.go
@@ -109,6 +109,11 @@ func (s *ErrorOnWriteSystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *ErrorOnWriteSystem) UnderlyingSystem() System {
+ return s.system
+}
+
// WriteFile implements System.WriteFile.
func (s *ErrorOnWriteSystem) WriteFile(AbsPath, []byte, fs.FileMode) error {
return s.err
diff --git a/pkg/chezmoi/externaldiffsystem.go b/pkg/chezmoi/externaldiffsystem.go
index e915602de0c..b2d53077613 100644
--- a/pkg/chezmoi/externaldiffsystem.go
+++ b/pkg/chezmoi/externaldiffsystem.go
@@ -215,6 +215,11 @@ func (s *ExternalDiffSystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *ExternalDiffSystem) UnderlyingSystem() System {
+ return s.system
+}
+
// WriteFile implements System.WriteFile.
func (s *ExternalDiffSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error {
if s.filter.IncludeEntryTypeBits(EntryTypeFiles) {
diff --git a/pkg/chezmoi/gitdiffsystem.go b/pkg/chezmoi/gitdiffsystem.go
index fd5068d0df6..81e5c68b1e2 100644
--- a/pkg/chezmoi/gitdiffsystem.go
+++ b/pkg/chezmoi/gitdiffsystem.go
@@ -237,6 +237,11 @@ func (s *GitDiffSystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *GitDiffSystem) UnderlyingSystem() System {
+ return s.system
+}
+
// WriteFile implements System.WriteFile.
func (s *GitDiffSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error {
if s.filter.IncludeEntryTypeBits(EntryTypeFiles) {
diff --git a/pkg/chezmoi/nullsystem.go b/pkg/chezmoi/nullsystem.go
index ddb7033b370..3197f6ab0bc 100644
--- a/pkg/chezmoi/nullsystem.go
+++ b/pkg/chezmoi/nullsystem.go
@@ -4,3 +4,8 @@ type NullSystem struct {
emptySystemMixin
noUpdateSystemMixin
}
+
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *NullSystem) UnderlyingSystem() System {
+ return s
+}
diff --git a/pkg/chezmoi/readonlysystem.go b/pkg/chezmoi/readonlysystem.go
index 46e8c42f898..6a57482c2f0 100644
--- a/pkg/chezmoi/readonlysystem.go
+++ b/pkg/chezmoi/readonlysystem.go
@@ -58,3 +58,8 @@ func (s *ReadOnlySystem) Stat(name AbsPath) (fs.FileInfo, error) {
func (s *ReadOnlySystem) UnderlyingFS() vfs.FS {
return s.system.UnderlyingFS()
}
+
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *ReadOnlySystem) UnderlyingSystem() System {
+ return s.system
+}
diff --git a/pkg/chezmoi/realsystem.go b/pkg/chezmoi/realsystem.go
index ef6c1d291fd..b1cc6630251 100644
--- a/pkg/chezmoi/realsystem.go
+++ b/pkg/chezmoi/realsystem.go
@@ -146,6 +146,11 @@ func (s *RealSystem) UnderlyingFS() vfs.FS {
return s.fileSystem
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *RealSystem) UnderlyingSystem() System {
+ return s
+}
+
// getScriptWorkingDir returns the script's working directory.
//
// If this is a before_ script then the requested working directory may not
diff --git a/pkg/chezmoi/system.go b/pkg/chezmoi/system.go
index d3abe876d19..08f43ae1ee2 100644
--- a/pkg/chezmoi/system.go
+++ b/pkg/chezmoi/system.go
@@ -38,6 +38,7 @@ type System interface { //nolint:interfacebloat
RunScript(scriptname RelPath, dir AbsPath, data []byte, options RunScriptOptions) error
Stat(name AbsPath) (fs.FileInfo, error)
UnderlyingFS() vfs.FS
+ UnderlyingSystem() System
WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error
WriteSymlink(oldname string, newname AbsPath) error
}
diff --git a/pkg/chezmoi/tarwritersystem.go b/pkg/chezmoi/tarwritersystem.go
index 65a5d1f0d5b..daf14ac9bdb 100644
--- a/pkg/chezmoi/tarwritersystem.go
+++ b/pkg/chezmoi/tarwritersystem.go
@@ -47,6 +47,11 @@ func (s *TarWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte
return s.WriteFile(NewAbsPath(scriptname.String()), data, 0o700)
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *TarWriterSystem) UnderlyingSystem() System {
+ return s
+}
+
// WriteFile implements System.WriteFile.
func (s *TarWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error {
header := s.headerTemplate
diff --git a/pkg/chezmoi/zipwritersystem.go b/pkg/chezmoi/zipwritersystem.go
index 609952781ad..789f78fa9be 100644
--- a/pkg/chezmoi/zipwritersystem.go
+++ b/pkg/chezmoi/zipwritersystem.go
@@ -52,6 +52,11 @@ func (s *ZIPWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte
return s.WriteFile(NewAbsPath(scriptname.String()), data, 0o700)
}
+// UnderlyingSystem implements System.UnderlyingSystem.
+func (s *ZIPWriterSystem) UnderlyingSystem() System {
+ return s
+}
+
// WriteFile implements System.WriteFile.
func (s *ZIPWriterSystem) WriteFile(filename AbsPath, data []byte, perm fs.FileMode) error {
fileHeader := zip.FileHeader{
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index af385e2077c..4787e82ca86 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -675,7 +675,7 @@ func (c *Config) createAndReloadConfigFile(cmd *cobra.Command) error {
}
c.templateData.sourceDir = sourceDirAbsPath
c.runEnv = append(c.runEnv, "CHEZMOI_SOURCE_DIR="+sourceDirAbsPath.String())
- realSystem := c.baseSystem.(*chezmoi.RealSystem) //nolint:forcetypeassert
+ realSystem := c.baseSystem.UnderlyingSystem().(*chezmoi.RealSystem) //nolint:forcetypeassert
realSystem.SetScriptEnv(c.runEnv)
// Find config template, execute it, and create config file.
diff --git a/pkg/cmd/testdata/scripts/issue3005.txtar b/pkg/cmd/testdata/scripts/issue3005.txtar
new file mode 100644
index 00000000000..cd58bba0dca
--- /dev/null
+++ b/pkg/cmd/testdata/scripts/issue3005.txtar
@@ -0,0 +1,2 @@
+# test that chezmoi --debug init does not fail
+exec chezmoi --debug init
|
fix
|
Fix init --debug flag
|
5a143268e7f623b8d93dd47d0055d5b6d708e5fe
|
2022-03-09 01:49:54
|
Tom Payne
|
feat: Release raw binaries
| false
|
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 84c78ccc2d7..5ad5d1716a7 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -110,6 +110,17 @@ changelog:
- Merge branch
checksum:
+ extra_files:
+ - glob: ./dist/chezmoi-nocgo_darwin_amd64/chezmoi
+ name_template: chezmoi-darwin-amd64
+ - glob: ./dist/chezmoi-nocgo_darwin_arm64/chezmoi
+ name_template: chezmoi-darwin-arm64
+ - glob: ./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi
+ name_template: chezmoi-linux-amd64
+ - glob: ./dist/chezmoi-cgo-musl_linux_amd64/chezmoi
+ name_template: chezmoi-linux-amd64-musl
+ - glob: ./dist/chezmoi-nocgo_windows_amd64/chezmoi.exe
+ name_template: chezmoi-windows-amd64.exe
nfpms:
- builds:
@@ -167,6 +178,17 @@ nfpms:
bindir: /usr/bin
release:
+ extra_files:
+ - glob: ./dist/chezmoi-nocgo_darwin_amd64/chezmoi
+ name_template: chezmoi-darwin-amd64
+ - glob: ./dist/chezmoi-nocgo_darwin_arm64/chezmoi
+ name_template: chezmoi-darwin-arm64
+ - glob: ./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi
+ name_template: chezmoi-linux-amd64
+ - glob: ./dist/chezmoi-cgo-musl_linux_amd64/chezmoi
+ name_template: chezmoi-linux-amd64-musl
+ - glob: ./dist/chezmoi-nocgo_windows_amd64/chezmoi.exe
+ name_template: chezmoi-windows-amd64.exe
scoop:
bucket:
|
feat
|
Release raw binaries
|
f86d7b557b96c775becd24b0395ee5094f520bba
|
2021-09-24 21:18:39
|
Tom Payne
|
feat: Make chezmoi edit with no args open working tree (#1455)
| false
|
diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md
index eb7e3e6f493..435656dc34a 100644
--- a/docs/REFERENCE.md
+++ b/docs/REFERENCE.md
@@ -1138,7 +1138,7 @@ $ chezmoi dump --format=yaml
### `edit` [*target*...]
Edit the source state of *target*s, which must be files or symlinks. If no
-targets are given the the source directory itself is opened.
+targets are given then the working tree of the source directory is opened.
The editor used is the first non-empty string of the `edit.command`
configuration variable, the `$VISUAL` environment variable, the `$EDITOR`
diff --git a/internal/cmd/config.go b/internal/cmd/config.go
index 1bebc0f926b..19786379264 100644
--- a/internal/cmd/config.go
+++ b/internal/cmd/config.go
@@ -1634,6 +1634,21 @@ func (c *Config) validateData() error {
return validateKeys(c.Data, identifierRx)
}
+// workingTree searches upwards to find the git working tree.
+func (c *Config) workingTree() chezmoi.AbsPath {
+ workingTreeDirAbsPath := c.SourceDirAbsPath
+ for {
+ if info, err := c.baseSystem.Stat(workingTreeDirAbsPath.Join(".git")); err == nil && info.IsDir() {
+ return workingTreeDirAbsPath
+ }
+ prevWorkingTreeDirAbsPath := workingTreeDirAbsPath
+ workingTreeDirAbsPath = workingTreeDirAbsPath.Dir()
+ if len(workingTreeDirAbsPath) >= len(prevWorkingTreeDirAbsPath) {
+ return ""
+ }
+ }
+}
+
func (c *Config) writeOutput(data []byte) error {
if c.outputAbsPath == "" || c.outputAbsPath == "-" {
_, err := c.stdout.Write(data)
diff --git a/internal/cmd/editcmd.go b/internal/cmd/editcmd.go
index f9b876b1302..e0c3bfb8dc9 100644
--- a/internal/cmd/editcmd.go
+++ b/internal/cmd/editcmd.go
@@ -43,7 +43,11 @@ func (c *Config) newEditCmd() *cobra.Command {
func (c *Config) runEditCmd(cmd *cobra.Command, args []string, sourceState *chezmoi.SourceState) error {
if len(args) == 0 {
- if err := c.runEditor([]string{string(c.SourceDirAbsPath)}); err != nil {
+ dirAbsPath := c.workingTree()
+ if dirAbsPath == "" {
+ dirAbsPath = c.SourceDirAbsPath
+ }
+ if err := c.runEditor([]string{string(dirAbsPath)}); err != nil {
return err
}
if c.Edit.apply {
diff --git a/internal/cmd/initcmd.go b/internal/cmd/initcmd.go
index c1e65b61490..f7208680036 100644
--- a/internal/cmd/initcmd.go
+++ b/internal/cmd/initcmd.go
@@ -132,24 +132,8 @@ func (c *Config) runInitCmd(cmd *cobra.Command, args []string) error {
c.init.purgeBinary = true
}
- // Search upwards to find out if we're already in a git repository.
- inWorkingCopy := false
- workingCopyDirAbsPath := c.SourceDirAbsPath
-FOR:
- for {
- if info, err := c.baseSystem.Stat(workingCopyDirAbsPath.Join(".git")); err == nil && info.IsDir() {
- inWorkingCopy = true
- break FOR
- }
- prevWorkingCopyDirAbsPath := workingCopyDirAbsPath
- workingCopyDirAbsPath = workingCopyDirAbsPath.Dir()
- if len(workingCopyDirAbsPath) >= len(prevWorkingCopyDirAbsPath) {
- break FOR
- }
- }
-
- // If the working copy does not exist then init it or clone it.
- if !inWorkingCopy {
+ // If we're not in a working tree then init it or clone it.
+ if c.workingTree() == "" {
rawSourceDir, err := c.baseSystem.RawPath(c.SourceDirAbsPath)
if err != nil {
return err
diff --git a/internal/cmd/testdata/scripts/edit.txt b/internal/cmd/testdata/scripts/edit.txt
index 66ec652e726..9c0812de62f 100644
--- a/internal/cmd/testdata/scripts/edit.txt
+++ b/internal/cmd/testdata/scripts/edit.txt
@@ -1,31 +1,51 @@
mkhomedir
mksourcedir
+# test that chezmoi edit edits a single file
chezmoi edit $HOME${/}.file
grep -count=1 '# edited' $CHEZMOISOURCEDIR/dot_file
! grep '# edited' $HOME/.file
+# test that chezmoi edit --apply applies the edit.
chezmoi edit --apply --force $HOME${/}.file
grep -count=2 '# edited' $CHEZMOISOURCEDIR/dot_file
grep -count=2 '# edited' $HOME/.file
+# test that chezmoi edit edits a symlink
chezmoi edit $HOME${/}.symlink
grep -count=1 '# edited' $CHEZMOISOURCEDIR/symlink_dot_symlink
-chezmoi edit -v $HOME${/}script
+# test that chezmoi edit edits a script
+chezmoi edit $HOME${/}script
grep -count=1 '# edited' $CHEZMOISOURCEDIR/run_script
+# test that chezmoi edit edits a file and a symlink
chezmoi edit $HOME${/}.file $HOME${/}.symlink
grep -count=3 '# edited' $CHEZMOISOURCEDIR/dot_file
grep -count=2 '# edited' $CHEZMOISOURCEDIR/symlink_dot_symlink
+# test that chezmoi edit edits the working tree
chezmoi edit
exists $CHEZMOISOURCEDIR/.edited
-[windows] stop 'remaining tests use file modes'
+# test that chezmoi edit edits a directory
+[!windows] chezmoi edit $HOME${/}.dir
+[!windows] exists $CHEZMOISOURCEDIR/dot_dir/.edited
-chezmoi edit $HOME${/}.dir
-exists $CHEZMOISOURCEDIR/dot_dir/.edited
+# test that chezmoi edit edits a file when the working tree and the source dir are different
+chhome home2/user
+chezmoi edit $HOME${/}.file
+grep -count=1 '# edited' $CHEZMOISOURCEDIR/home/dot_file
+
+# test that chezmoi edit edits the working tree when working tree and the source dir are different
+chezmoi edit
+exists $CHEZMOISOURCEDIR/.edited
+! exists $CHEZMOISOURCEDIR/home/.edited
-- home/user/.local/share/chezmoi/run_script --
#!/bin/sh
+-- home2/user/.config/chezmoi/chezmoi.toml --
+sourceDir = "~/.local/share/chezmoi/home"
+-- home2/user/.local/share/chezmoi/.git/.keep --
+-- home2/user/.local/share/chezmoi/home/dot_file --
+# contents of .file
|
feat
|
Make chezmoi edit with no args open working tree (#1455)
|
e649df250a8484556243436a3c8adc0aefe0f3cf
|
2023-07-30 05:15:51
|
Tom Payne
|
fix: Ensure that templates cannot modify each other's data
| false
|
diff --git a/go.mod b/go.mod
index d07deffb66b..364f5499dd3 100644
--- a/go.mod
+++ b/go.mod
@@ -25,6 +25,7 @@ require (
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
github.com/itchyny/gojq v0.12.13
github.com/klauspost/compress v1.16.7
+ github.com/mitchellh/copystructure v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/muesli/combinator v0.3.0
github.com/muesli/termenv v0.15.2
@@ -115,7 +116,6 @@ require (
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
- github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
diff --git a/pkg/chezmoi/template.go b/pkg/chezmoi/template.go
index 10b9eb32ca8..04f24f033ec 100644
--- a/pkg/chezmoi/template.go
+++ b/pkg/chezmoi/template.go
@@ -4,6 +4,8 @@ import (
"bytes"
"strings"
"text/template"
+
+ "github.com/mitchellh/copystructure"
)
// A Template extends text/template.Template with support for directives.
@@ -54,6 +56,15 @@ func (t *Template) AddParseTree(tmpl *Template) (*Template, error) {
// Execute executes t with data.
func (t *Template) Execute(data any) ([]byte, error) {
+ if data != nil {
+ // Make a deep copy of data, in case any template functions modify it.
+ var err error
+ data, err = copystructure.Copy(data)
+ if err != nil {
+ return nil, err
+ }
+ }
+
var builder strings.Builder
if err := t.template.ExecuteTemplate(&builder, t.name, data); err != nil {
return nil, err
diff --git a/pkg/cmd/testdata/scripts/issue3126.txtar b/pkg/cmd/testdata/scripts/issue3126.txtar
new file mode 100644
index 00000000000..4936973af8b
--- /dev/null
+++ b/pkg/cmd/testdata/scripts/issue3126.txtar
@@ -0,0 +1,9 @@
+# test that template executions are independent
+exec chezmoi apply
+! grep bar $HOME/file1
+! grep foo $HOME/file2
+
+-- home/user/.local/share/chezmoi/file1.tmpl --
+{{ merge . (dict "key1" "foo") }}
+-- home/user/.local/share/chezmoi/file2.tmpl --
+{{ merge . (dict "key2" "bar") }}
|
fix
|
Ensure that templates cannot modify each other's data
|
0a9a64fc5029c837692e4f331a50b56a82ceefd9
|
2024-07-12 15:20:11
|
Tom Payne
|
chore: Update Github Actions
| false
|
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml
index 06b9b2d9d9b..fd21539a1d0 100644
--- a/.github/workflows/installer.yml
+++ b/.github/workflows/installer.yml
@@ -37,7 +37,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: reviewdog/action-misspell@30433ca7be17888deb78a32521706fb65defbf3f
+ - uses: reviewdog/action-misspell@278e1b3c7dd09d2827fa080919a40db73ccafe24
with:
locale: US
ignore: ackward
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 3f8ee779ae9..fb155d69e7b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -70,7 +70,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: reviewdog/action-misspell@30433ca7be17888deb78a32521706fb65defbf3f
+ - uses: reviewdog/action-misspell@278e1b3c7dd09d2827fa080919a40db73ccafe24
with:
locale: US
ignore: ackward
@@ -108,7 +108,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: build
@@ -143,7 +143,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: oldstable
- name: build
@@ -178,7 +178,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: install-release-dependencies
@@ -206,31 +206,31 @@ jobs:
args: release --skip=sign --snapshot --timeout=1h
- name: upload-artifact-chezmoi-darwin-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
+ uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: chezmoi-darwin-amd64
path: dist/chezmoi-nocgo_darwin_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-darwin-arm64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
+ uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: chezmoi-darwin-arm64
path: dist/chezmoi-nocgo_darwin_arm64/chezmoi
- name: upload-artifact-chezmoi-linux-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
+ uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: chezmoi-linux-amd64
path: dist/chezmoi-cgo-glibc_linux_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-linux-musl-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
+ uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: chezmoi-linux-amd64-musl
path: dist/chezmoi-cgo-musl_linux_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-windows-amd64.exe
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
+ uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: chezmoi-windows-amd64
path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
@@ -243,7 +243,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: install-age
@@ -283,7 +283,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: install-website-dependencies
@@ -301,7 +301,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
@@ -329,7 +329,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: generate
@@ -383,7 +383,7 @@ jobs:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: stable
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64
@@ -427,7 +427,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20
@@ -455,7 +455,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
- - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
+ - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ env.GO_VERSION }}
- name: prepare-chezmoi.io
|
chore
|
Update Github Actions
|
ebfd5b2864428b98db57383b542c7bcafed03b0c
|
2022-03-07 06:00:23
|
Tom Payne
|
feat: Add license command
| false
|
diff --git a/assets/chezmoi.io/docs/docs.go b/assets/chezmoi.io/docs/docs.go
new file mode 100644
index 00000000000..4eef73247a5
--- /dev/null
+++ b/assets/chezmoi.io/docs/docs.go
@@ -0,0 +1,7 @@
+package docs
+
+import _ "embed"
+
+// License is the license.
+//go:embed license.md
+var License []byte
diff --git a/assets/chezmoi.io/docs/docs_test.go b/assets/chezmoi.io/docs/docs_test.go
new file mode 100644
index 00000000000..5604656f553
--- /dev/null
+++ b/assets/chezmoi.io/docs/docs_test.go
@@ -0,0 +1 @@
+package docs
diff --git a/assets/chezmoi.io/docs/reference/commands/license.md b/assets/chezmoi.io/docs/reference/commands/license.md
new file mode 100644
index 00000000000..03fccf3126f
--- /dev/null
+++ b/assets/chezmoi.io/docs/reference/commands/license.md
@@ -0,0 +1,9 @@
+# `license`
+
+Print chezmoi's license.
+
+!!! example
+
+ ```console
+ $ chezmoi license
+ ```
diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go
index 65f2f4fac56..b380ddd8edb 100644
--- a/pkg/cmd/config.go
+++ b/pkg/cmd/config.go
@@ -1335,6 +1335,7 @@ func (c *Config) newRootCmd() (*cobra.Command, error) {
c.newImportCmd(),
c.newInitCmd(),
c.newInternalTestCmd(),
+ c.newLicenseCmd(),
c.newManagedCmd(),
c.newMergeCmd(),
c.newMergeAllCmd(),
diff --git a/pkg/cmd/licensecmd.go b/pkg/cmd/licensecmd.go
new file mode 100644
index 00000000000..3a319cc6672
--- /dev/null
+++ b/pkg/cmd/licensecmd.go
@@ -0,0 +1,24 @@
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+
+ "github.com/twpayne/chezmoi/v2/assets/chezmoi.io/docs"
+)
+
+func (c *Config) newLicenseCmd() *cobra.Command {
+ licenseCmd := &cobra.Command{
+ Use: "license",
+ Short: "Print license",
+ Long: mustLongHelp("license"),
+ Example: example("license"),
+ Args: cobra.NoArgs,
+ RunE: c.runLicenseCmd,
+ }
+
+ return licenseCmd
+}
+
+func (c *Config) runLicenseCmd(cmd *cobra.Command, args []string) error {
+ return c.writeOutput(docs.License)
+}
diff --git a/pkg/cmd/testdata/scripts/license.txt b/pkg/cmd/testdata/scripts/license.txt
new file mode 100644
index 00000000000..e2d69872787
--- /dev/null
+++ b/pkg/cmd/testdata/scripts/license.txt
@@ -0,0 +1,3 @@
+# test that chezmoi license prints chezmoi's license
+chezmoi license
+stdout 'The MIT License'
|
feat
|
Add license command
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.