Compare commits
14
Commits
v0.3.0
..
6bdc5a3c49
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bdc5a3c49
|
||
|
|
32c655fb99 | ||
|
|
84b2761d80
|
||
|
|
99e6b7bcd8 | ||
|
|
677bba4c4a | ||
|
|
81a24dcee2
|
||
|
|
831031bb48 | ||
|
|
dfe6c9ce7a | ||
|
|
d30e75bd26 | ||
|
|
bce28be7a1
|
||
|
|
6a7f53e236 | ||
|
|
d0a8b1390d | ||
|
|
a7db795cbe | ||
|
|
59c1222f4d
|
No files matched your search
@@ -78,7 +78,7 @@ jobs:
|
||||
uses: goreleaser/goreleaser-action@v7
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: v2.18.3
|
||||
version: v2.19.0
|
||||
args: release --clean --release-notes ${{ runner.temp }}/notes.md
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -2,6 +2,29 @@
|
||||
|
||||
Every release of lazysecrets, newest first.
|
||||
|
||||
## v0.4.2 – 2026-10-28
|
||||
|
||||
### Added
|
||||
|
||||
- A link brings back the lazysecrets nvim hid; Azure shows its account ([#95](https://git.kebcloud.no/keb/lazysecrets/pulls/95)) ([99e6b7b](https://git.kebcloud.no/keb/lazysecrets/commit/99e6b7bcd84dab670427f38fa58e36c6dd5cd02a))
|
||||
|
||||
## v0.4.1 – 2026-10-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- An opened link ends on the secret's details, also when its lists were loaded ([#93](https://git.kebcloud.no/keb/lazysecrets/pulls/93)) ([831031b](https://git.kebcloud.no/keb/lazysecrets/commit/831031bb4863805abc7e272f40d5a1d576364a77))
|
||||
|
||||
## v0.4.0 – 2026-10-19
|
||||
|
||||
### Added
|
||||
|
||||
- .NET appsettings files in repos ([#88](https://git.kebcloud.no/keb/lazysecrets/pulls/88)) ([a7db795](https://git.kebcloud.no/keb/lazysecrets/commit/a7db795cbec9425c743153a618dfe04741ac273e))
|
||||
- A running lazysecrets says when a newer one was installed over it ([#90](https://git.kebcloud.no/keb/lazysecrets/pulls/90)) ([6a7f53e](https://git.kebcloud.no/keb/lazysecrets/commit/6a7f53e2364695e71db8107a21feffe2ddf1a7b9))
|
||||
|
||||
### Fixed
|
||||
|
||||
- --dry-run in release script ([59c1222](https://git.kebcloud.no/keb/lazysecrets/commit/59c1222f4df04613fb6e945100151568550e70c0))
|
||||
|
||||
## v0.3.0 – 2026-10-15
|
||||
|
||||
### Added
|
||||
|
||||
@@ -23,7 +23,7 @@ A terminal UI for finding, reading and sharing secrets. Inspired by the fantasti
|
||||
- **Your way**: rebind any key, pick a theme, and add custom commands to run
|
||||
on a secret.
|
||||
- **Try it first**: `lazysecrets --demo` runs on built-in sample data.
|
||||
- **Sources**: Azure Key Vault, Databricks secret scopes, and SOPS, `.env`, Spring Boot and Docker Compose files in your git repos.
|
||||
- **Sources**: Azure Key Vault, Databricks secret scopes, and SOPS, `.env`, Spring Boot, Docker Compose and .NET appsettings files in your git repos.
|
||||
|
||||
> **Early development:** expect rough edges. See [CHANGELOG.md](CHANGELOG.md) for what's new.
|
||||
|
||||
@@ -87,7 +87,7 @@ pickers and scripts: see [Integration](docs/integration.md#an-fzf-picker).
|
||||
- [Keys](docs/keys.md): every key, Go to, the layout, and rebinding keys
|
||||
- [Azure Key Vault](docs/azure.md): accounts, permissions, pinned vaults
|
||||
- [Databricks](docs/databricks.md): profiles and Key Vault-backed scopes
|
||||
- [SOPS, .env, Spring and compose files](docs/repos.md): which repos and files, decrypting
|
||||
- [SOPS, .env, Spring, compose and .NET files](docs/repos.md): which repos and files, decrypting
|
||||
- [Sharing](docs/sharing.md): links to secrets, encrypted env files, and
|
||||
opening links, also from the browser and chat
|
||||
- [Integration](docs/integration.md): how lazysecrets can integrate into other systems
|
||||
|
||||
+5
-3
@@ -1,8 +1,9 @@
|
||||
# git-cliff (https://git-cliff.org) builds CHANGELOG.md and the release
|
||||
# notes from the commits on main. Pull requests are squash-merged, so each
|
||||
# one is a single commit whose message is the PR title: a conventional one
|
||||
# (feat: …, fix: …, perf: …) puts it in the changelog, anything else
|
||||
# (chore, ci, docs, refactor, test, …) leaves it out.
|
||||
# (feat: …, fix: …, perf: …) puts it in the changelog, and so does a
|
||||
# dependency update Renovate marks [security]; anything else (chore, ci,
|
||||
# docs, refactor, test, …) leaves it out.
|
||||
#
|
||||
# git cliff --unreleased # what the next release would say
|
||||
|
||||
@@ -24,7 +25,7 @@ Hello world 👋
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | striptags | trim }}
|
||||
{% for commit in commits %}
|
||||
- {% if commit.breaking %}**Breaking:** {% endif %}{{ commit.message | split(pat="\n") | first | upper_first | trim }} \
|
||||
- {% if commit.breaking %}**Breaking:** {% endif %}{{ commit.message | split(pat="\n") | first | replace(from=" [security]", to="") | upper_first | trim }} \
|
||||
([{{ commit.id | truncate(length=7, end="") }}](https://git.kebcloud.no/keb/lazysecrets/commit/{{ commit.id }}))\
|
||||
{% endfor %}
|
||||
{% endfor %}\n
|
||||
@@ -65,5 +66,6 @@ commit_parsers = [
|
||||
{ message = "^feat", group = "<!-- 0 -->Added" },
|
||||
{ message = "^perf", group = "<!-- 1 -->Changed" },
|
||||
{ message = "^fix", group = "<!-- 2 -->Fixed" },
|
||||
{ message = "\\[security\\]", group = "<!-- 3 -->Security" },
|
||||
{ message = ".*", skip = true },
|
||||
]
|
||||
@@ -57,7 +57,7 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t
|
||||
expiry := fs.Bool("expiry", true, "mark and say which have expired (✗ expired) or expire within ui.expiryWarningDays (⚠ expires in 12d) (text)")
|
||||
kinds := fs.String("kind", "", "only these kinds, comma-separated: "+strings.Join(listing.Kinds, ", ")+" (vault: also scopes and repo files)")
|
||||
showErrors := fs.Bool("errors", true, "list the lists that can't be read, with why (text: ✗ lines; json: \"error\")")
|
||||
hidden := fs.Bool("hidden", false, "list what's hidden too, as H does in the TUI: Spring and compose keys that don't look secret, example files, and files and repos with only those (json: \"hidden\")")
|
||||
hidden := fs.Bool("hidden", false, "list what's hidden too, as H does in the TUI: config file keys (Spring, compose, .NET) that don't look secret, example files, and files and repos with only those (json: \"hidden\")")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ Flags:
|
||||
repos := repo.New(repo.Settings{
|
||||
Dir: startDir, Paths: pc.Repos.Paths, Roots: valueOr(pc.Repos.Roots, repo.DefaultRoots),
|
||||
Starred: starredRepos(st), Include: pc.Repos.Include, Exclude: pc.Repos.Exclude,
|
||||
SecretPatterns: pc.Repos.SecretPatterns, Types: map[string]repo.FileType{"spring": pc.Repos.Spring, "compose": pc.Repos.Compose},
|
||||
SecretPatterns: pc.Repos.SecretPatterns, Types: map[string]repo.FileType{"spring": pc.Repos.Spring, "compose": pc.Repos.Compose, "dotnet": pc.Repos.Dotnet},
|
||||
})
|
||||
// The repo it started in (shown on top as Repo) and the
|
||||
// others, checked for secret files in the background like
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// default ones.
|
||||
func updater(servers []string) *app.Updater {
|
||||
c := &update.Client{Servers: servers}
|
||||
return &app.Updater{
|
||||
u := &app.Updater{
|
||||
Latest: c.Latest,
|
||||
Install: func(ctx context.Context, r update.Release) error {
|
||||
exe, err := update.Executable()
|
||||
@@ -28,6 +28,10 @@ func updater(servers []string) *app.Updater {
|
||||
return c.Install(ctx, r, exe)
|
||||
},
|
||||
}
|
||||
if b, err := update.Running(); err == nil {
|
||||
u.Replaced = b.Replaced
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// updateCmd is lazysecrets update [--check]: the newer release's
|
||||
|
||||
+3
-2
@@ -5,8 +5,9 @@ it reuses it.
|
||||
|
||||
## Accounts
|
||||
|
||||
Every account signed in to az gets its own group in the Sources pane
|
||||
(`az login` again with another account to add one), and each account's
|
||||
Every account signed in to az gets its own group in the Sources pane,
|
||||
named for it, `Azure · alice` (`az login` again with another account to
|
||||
add one), and each account's
|
||||
vaults are read with that account. A subscription several accounts can see
|
||||
is listed under each, since their permissions can differ.
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ theme:
|
||||
repoColor: ["#c099ff"]
|
||||
springColor: ["#c3e88d"] # Spring Boot config files
|
||||
composeColor: ["#82aaff"] # Docker Compose files
|
||||
dotnetColor: ["#c099ff"] # .NET appsettings files
|
||||
```
|
||||
|
||||
A role lazysecrets doesn't know, a typo or one from a newer version, is
|
||||
@@ -153,3 +154,8 @@ lazysecrets that's running keeps working, and the next start is the new
|
||||
version. A binary a package manager owns (Homebrew, Nix, a distro
|
||||
package) is left to it. Development builds (`dev-…`) aren't offered
|
||||
releases.
|
||||
|
||||
A lazysecrets that keeps running, like the one lazysecrets.nvim hides,
|
||||
looks every minute whether a newer one was installed over it, from
|
||||
anywhere (`install.sh`, `go install`, another lazysecrets), and says so
|
||||
in the status pane, `→ v0.3.1 (restart)`, until you restart it.
|
||||
@@ -35,6 +35,9 @@ subject, checked by `pr-title.yml`:
|
||||
| `fix` | a bug fix | Fixed |
|
||||
| `refactor`, `docs`, `test`, `ci`, `chore`, `build`, `style`, `revert` | everything users don't need to hear about | no |
|
||||
|
||||
Renovate's dependency updates for a vulnerability (`[security]` in the
|
||||
title) are listed under Security.
|
||||
|
||||
`feat!:` marks a breaking change, `feat(scope):` names a part.
|
||||
`[skip changelog]` in the description leaves a pull request out.
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ The rule: a letter in the lists, ctrl+ that letter where you type a filter
|
||||
| `[` / `]` | previous / next tab of the focused pane: Sources and Favourites in Sources; Secrets, Keys, Certs in Secrets |
|
||||
| `/` | filter the focused list by name or note ([how it matches](#searching)); `enter` keeps it, `esc` clears it. While typing: `ctrl+j`/`ctrl+k` move, `ctrl+y` copies, `ctrl+r` reveals, `ctrl+f` stars |
|
||||
| `` ` `` | switch the Sources pane between grouped by provider and a flat list; `enter`/`space` on a provider folds it |
|
||||
| `H` | show / hide what's hidden: [Spring and compose keys](repos.md#spring-boot-config) that don't look secret, example files, and files and repos with only those; shown dimmed |
|
||||
| `H` | show / hide what's hidden: [config file keys](repos.md#spring-boot-config) (Spring, compose, .NET) that don't look secret, example files, and files and repos with only those; shown dimmed |
|
||||
| `r` | refresh the focused pane |
|
||||
| `q`, `ctrl+c` | quit |
|
||||
|
||||
@@ -54,7 +54,7 @@ match case exactly.
|
||||
| `Y` | copy the reference (`@Microsoft.KeyVault(...)`, key/certificate URL, `{{secrets/scope/key}}`) |
|
||||
| `v` | versions of the selected item (Azure); `space`/`y`/`Y` then act on that version; `esc`, `⌫` or `v` to go back |
|
||||
| `o` | open the selected item in the browser (over SSH: copy the link) |
|
||||
| `e` | open the selected SOPS, `.env`, Spring or compose file, or a secret's file at its line ([how](repos.md#opening-files)) |
|
||||
| `e` | open the selected SOPS, `.env`, Spring, compose or .NET file, or a secret's file at its line ([how](repos.md#opening-files)) |
|
||||
| `s` / `S` | copy a [link](sharing.md) to the selected item / share menu (also env files, [encrypted](sharing.md#sharing-env-files)) |
|
||||
| `ctrl+o` | open a link or reference (or just paste one) |
|
||||
| `x` | [custom commands](custom-commands.md) |
|
||||
|
||||
+18
-6
@@ -1,9 +1,10 @@
|
||||
# SOPS, .env, Spring and compose files in git repos
|
||||
# SOPS, .env, Spring, compose and .NET files in git repos
|
||||
|
||||
lazysecrets shows git repositories under **Repos**: their
|
||||
[SOPS](https://github.com/getsops/sops)-encrypted files (YAML, JSON,
|
||||
`.env`, INI), plain env files, [Spring Boot config](#spring-boot-config)
|
||||
and [Docker Compose files](#docker-compose) as vaults, and the keys in them (`db.password`, `list[0]`) as secrets. A dot or bracket inside a key is
|
||||
[Docker Compose files](#docker-compose) and [.NET appsettings](#net-appsettings)
|
||||
as vaults, and the keys in them (`db.password`, `list[0]`) as secrets. A dot or bracket inside a key is
|
||||
escaped, `app\.name`, so it doesn't read as nesting.
|
||||
|
||||
## Which repos
|
||||
@@ -47,7 +48,7 @@ Folders of dependencies and caches are never looked in, tracked or not:
|
||||
3. where the repo's `.sops.yaml` `creation_rules` say SOPS files go,
|
||||
4. the whole repo.
|
||||
|
||||
`include`/`exclude` apply to env, Spring and compose files too.
|
||||
`include`/`exclude` apply to env, Spring, compose and .NET files too.
|
||||
|
||||
```yaml
|
||||
providers:
|
||||
@@ -106,8 +107,8 @@ providers:
|
||||
```
|
||||
|
||||
A repo's `.lazysecrets.yaml` can set them too, the same way
|
||||
(`secretPatterns:`, `spring: secretPatterns:`, `compose:
|
||||
secretPatterns:`), for everyone. Each list
|
||||
(`secretPatterns:`, `spring:`, `compose:` or `dotnet: secretPatterns:`),
|
||||
for everyone. Each list
|
||||
comes from the first that sets it: the repo's for the type, the repo's,
|
||||
the config's for the type, the config's, the defaults.
|
||||
|
||||
@@ -133,6 +134,17 @@ without a value (`DB_PASSWORD:`, `- DB_PASSWORD`), taken from where
|
||||
compose runs, are marked as references; `${DB_PASSWORD:-x}` has its
|
||||
default in the file.
|
||||
|
||||
## .NET appsettings
|
||||
|
||||
`appsettings.json` and `appsettings.<Environment>.json`, tracked by git.
|
||||
Keys are named as .NET's configuration names them, sections joined by
|
||||
colons: `ConnectionStrings:Default`, `Servers:0:Name`. The same
|
||||
[secret patterns](#spring-boot-config) pick them, the rest hidden, with
|
||||
`dotnet: secretPatterns:` for .NET files' own; a connection string with
|
||||
`Password=` is listed by its value. An App Service Key Vault reference,
|
||||
`@Microsoft.KeyVault(…)`, is marked as a reference. Jasypt values decrypt
|
||||
with `$JASYPT_ENCRYPTOR_PASSWORD` only.
|
||||
|
||||
## Decrypting
|
||||
|
||||
Listing never decrypts: SOPS and Jasypt encrypt values only, so keys and
|
||||
@@ -151,7 +163,7 @@ repo's history, or easily could be.
|
||||
|
||||
### Jasypt
|
||||
|
||||
A value like `ENC(...)` in a plain `.env`, Spring or compose file is
|
||||
A value like `ENC(...)` in a plain `.env`, Spring, compose or .NET file is
|
||||
[Jasypt](http://www.jasypt.org)'s, decrypted when it's revealed or copied
|
||||
with jasypt-spring-boot's default algorithm (3.0+:
|
||||
`PBEWITHHMACSHA512ANDAES_256`). The password is, as in Spring:
|
||||
|
||||
@@ -177,6 +177,11 @@ linkHandler:
|
||||
a hidden dropdown terminal (kitty's quick access terminal) is shown.
|
||||
With none running, a new window opens.
|
||||
|
||||
- **Hidden in nvim** ([lazysecrets.nvim](https://github.com/karleinarb/lazysecrets.nvim)
|
||||
hides it when you leave its window): it's brought back, unless nvim is
|
||||
in the middle of something a window popping up would break (typing, a
|
||||
command, a picker); then it counts as not running.
|
||||
|
||||
The link is then offered as if pasted. `linkHandler.reuse: false` always
|
||||
opens a new window.
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
module git.kebcloud.no/keb/lazysecrets
|
||||
|
||||
go 1.27.2
|
||||
go 1.27.3
|
||||
|
||||
require (
|
||||
charm.land/bubbles/v2 v2.2.1
|
||||
charm.land/bubbletea/v2 v2.1.0
|
||||
charm.land/bubbletea/v2 v2.1.1
|
||||
charm.land/lipgloss/v2 v2.0.6
|
||||
filippo.io/age v1.3.2
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.1
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.15.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault/v2 v2.1.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.10.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 v2.0.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates v1.5.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.1
|
||||
github.com/atotto/clipboard v0.1.4
|
||||
github.com/charmbracelet/x/ansi v0.11.9
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20251109135125-8916d276318f
|
||||
github.com/databricks/databricks-sdk-go v0.188.0
|
||||
github.com/databricks/databricks-sdk-go v0.191.1
|
||||
github.com/junegunn/fzf v0.74.5
|
||||
go.yaml.in/yaml/v3 v3.0.5
|
||||
golang.org/x/mod v0.42.0
|
||||
@@ -33,7 +33,7 @@ require (
|
||||
filippo.io/hpke v0.4.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.8.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1 // indirect
|
||||
github.com/aymanbagabas/go-udiff v0.4.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||
@@ -66,13 +66,13 @@ require (
|
||||
go.opentelemetry.io/otel v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/crypto v0.58.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
||||
golang.org/x/net v0.60.0 // indirect
|
||||
golang.org/x/net v0.62.0 // indirect
|
||||
golang.org/x/oauth2 v0.36.0 // indirect
|
||||
golang.org/x/sync v0.23.0 // indirect
|
||||
golang.org/x/sync v0.24.0 // indirect
|
||||
golang.org/x/sys v0.49.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
golang.org/x/text v0.43.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
google.golang.org/api v0.264.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
||||
|
||||
@@ -2,8 +2,8 @@ c2sp.org/CCTV/age v0.0.0-20260829155415-4448f2097b2d h1:Blprhc2SbChNZtWcU+BLTM4Y
|
||||
c2sp.org/CCTV/age v0.0.0-20260829155415-4448f2097b2d/go.mod h1:SrHC2C7r5GkDk8R+NFVzYy/sdj0Ypg9htaPXQq5Cqeo=
|
||||
charm.land/bubbles/v2 v2.2.1 h1:Fq1+qm5hV6GkvzLQDhCBpXXE5tLgvh1PRriCLwSvIQU=
|
||||
charm.land/bubbles/v2 v2.2.1/go.mod h1:wdMgn+sje1KNXdwFizIWjbf328fIUBxqEmJ/vYPo8yc=
|
||||
charm.land/bubbletea/v2 v2.1.0 h1:A9fj9h5LFrvQhQHFNggp8K8rvY6CUfgn9dMbb6p2HIw=
|
||||
charm.land/bubbletea/v2 v2.1.0/go.mod h1:xWHeyxIX9/wiFU2kgPW04ojOZyTzrWf+8lGjUCaftiU=
|
||||
charm.land/bubbletea/v2 v2.1.1 h1:S1S9l37pCZGrj1JexBcr9x4Nr3MVeM42InqCYM/tDpU=
|
||||
charm.land/bubbletea/v2 v2.1.1/go.mod h1:xWHeyxIX9/wiFU2kgPW04ojOZyTzrWf+8lGjUCaftiU=
|
||||
charm.land/lipgloss/v2 v2.0.6 h1:EaGKeuA8FvF+v2BT5VmZd2LoYLaMZJXA5n34th8nCIQ=
|
||||
charm.land/lipgloss/v2 v2.0.6/go.mod h1:ipDDJNSGa1hlwDtSfW1s2/xR8Vdhbut4PXh2zEKZd0Q=
|
||||
cloud.google.com/go/auth v0.18.2 h1:+Nbt5Ev0xEqxlNjd6c+yYUeosQ5TtEUaNcN/3FozlaM=
|
||||
@@ -18,8 +18,8 @@ filippo.io/hpke v0.4.0 h1:p575VVQ6ted4pL+it6M00V/f2qTZITO0zgmdKCkd5+A=
|
||||
filippo.io/hpke v0.4.0/go.mod h1:EmAN849/P3qdeK+PCMkDpDm83vRHM5cDipBJ8xbQLVY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3 h1:qgnWTiWs1G7AqcKZegFvkJD1bmXJcaDU3uC0ELSgZ5U=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.23.3/go.mod h1:XtxD48QPInqoj+GMlcRlXHEYsoOxFnP6w2JgIZ9rDS4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.1 h1:u93s+zU2JD62im61Bm5CZIc1ZrOJaIAWEg0WOrMVkEo=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.14.1/go.mod h1:oXtinPO4OLj9d1DOTrqrL1oRwGhcqadvAmrl6wTeGlk=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.15.0 h1:w3gDUJlJ0BfBsHH02DCBDwbkmMSXJqBj6nBOCo9iocY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.15.0/go.mod h1:7scl8mG/IFLVjJ9ef/ltdND2T1z0CkgVSaQoUxLvmeU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.4.0 h1:xFaZZ+IubdftrDHnGGwZ6QvQ3KHTtWl2MCK+GMt2vxs=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.4.0/go.mod h1:mCBhUhlMjLLJKr5aqw2TNS/VqJOie8MzWq3DAMJeKso=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0 h1:Terj1CMW4+NY5CpWjSRkqLoxh2DkYDdv/FH2z0897Uc=
|
||||
@@ -40,14 +40,14 @@ github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates v1.5.0 h1
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates v1.5.0/go.mod h1:0AAf/fHAqhIsvD6XGKlCsDO8u+cCiYBBuro+lWS6os4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0 h1:MaKvxE6D0KkjOg6Wd9M00iqP5PR0kUxCfiezes4JweM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0/go.mod h1:i2h9fsTFKZorh8RdV2IcSUf/Qj98GlTkrTvUbX/s8as=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.0 h1:aMFOzch6ZJo4Ct9hI4A9Y2fPen5YNRTPmkSBhe5m0ZQ=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.0/go.mod h1:Oct8bx+g+DXKngU7i/LzFzYt44rmLdMu4uoofIpooVo=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.1 h1:f4X/okTwHAfzJamPo8hyStXinb4sCTK36gMZj+KLQdw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.5.1/go.mod h1:sEd11NnHY3lizFx/zf5u7x5qNjhF0t5VZM0irRHKXVU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 h1:nCYfgcSyHZXJI8J0IWE5MsCGlb2xp9fJiXyxWgmOFg4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0/go.mod h1:ucUjca2JtSZboY8IoUqyQyuuXvwbMBVwFOm0vdQPNhA=
|
||||
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM=
|
||||
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.8.0 h1:Nljr4q1GRA/5vCrMONS+g4u4LRHNgOXVSh3O43J2CnI=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.8.0/go.mod h1:Y33QHnf0FfdVewFFISOGe20mkZbxX4H839o955/PoeI=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1 h1:0O6j18nQDoIff6/mtosT5LNU2WehEwp+LqfX6699oqY=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1/go.mod h1:xdYAf5bjkOpsd3auA8riiJW4vneBubt9caavL7626jQ=
|
||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
||||
@@ -72,8 +72,8 @@ github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSE
|
||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/databricks/databricks-sdk-go v0.188.0 h1:1nxBqlctGnPzlReyziG199abHs9cR/KNjsCnSM+oDGA=
|
||||
github.com/databricks/databricks-sdk-go v0.188.0/go.mod h1:udBw6nxkaqa0fgPQ7ZW1kGFkltQncYx+qFJeVFmxtz8=
|
||||
github.com/databricks/databricks-sdk-go v0.191.1 h1:t7aE9PTQEwuPS1CRoVwpDW0jDuDuX9GD53gpRWRmJEE=
|
||||
github.com/databricks/databricks-sdk-go v0.191.1/go.mod h1:udBw6nxkaqa0fgPQ7ZW1kGFkltQncYx+qFJeVFmxtz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
@@ -151,25 +151,25 @@ go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/
|
||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
||||
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
||||
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||
golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
|
||||
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
|
||||
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
|
||||
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -154,11 +154,12 @@ type Repos struct {
|
||||
// a repo's .sops.yaml creation_rules say where to look.
|
||||
Include []string `yaml:"include"`
|
||||
Exclude []string `yaml:"exclude"`
|
||||
// SecretPatterns say which keys of config files are secrets; Spring
|
||||
// and Compose override them for their files, list by list.
|
||||
// SecretPatterns say which keys of config files are secrets; Spring,
|
||||
// Compose and Dotnet override them for their files, list by list.
|
||||
SecretPatterns repo.SecretPatterns `yaml:"secretPatterns"`
|
||||
Spring repo.FileType `yaml:"spring"`
|
||||
Compose repo.FileType `yaml:"compose"`
|
||||
Dotnet repo.FileType `yaml:"dotnet"`
|
||||
}
|
||||
|
||||
type Azure struct {
|
||||
@@ -300,7 +301,8 @@ func (c Config) validate(path string) error {
|
||||
}
|
||||
if err := errors.Join(c.Providers.Repos.SecretPatterns.Check("providers.repos.secretPatterns"),
|
||||
c.Providers.Repos.Spring.SecretPatterns.Check("providers.repos.spring.secretPatterns"),
|
||||
c.Providers.Repos.Compose.SecretPatterns.Check("providers.repos.compose.secretPatterns")); err != nil {
|
||||
c.Providers.Repos.Compose.SecretPatterns.Check("providers.repos.compose.secretPatterns"),
|
||||
c.Providers.Repos.Dotnet.SecretPatterns.Check("providers.repos.dotnet.secretPatterns")); err != nil {
|
||||
return fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
for i, v := range c.Providers.Azure.Vaults {
|
||||
|
||||
@@ -123,6 +123,9 @@ func (s *Server) handle(c net.Conn) {
|
||||
switch req.Op {
|
||||
case "status":
|
||||
_, app, reach := place(req.Front)
|
||||
if nvimState(context.Background()) == "busy" {
|
||||
reach = unreachable // a link would interrupt you: it opens elsewhere
|
||||
}
|
||||
s.mu.Lock()
|
||||
resp.Status = Status{PID: os.Getpid(), LastActive: s.active, Reach: reach, App: app}
|
||||
s.mu.Unlock()
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// In nvim (lazysecrets.nvim), the tmux pane can be in view while
|
||||
// lazysecrets isn't: the plugin hides its window when you leave it. The
|
||||
// plugin says (state) and brings it back (reveal), when nvim isn't in the
|
||||
// middle of something a window popping up would break.
|
||||
|
||||
// nvimState is what lazysecrets.nvim says of this lazysecrets: "shown",
|
||||
// "hidden" (and can be brought back), "busy", or "" outside nvim, or with
|
||||
// no answer (an older plugin, a plain :terminal): reach as before.
|
||||
func nvimState(ctx context.Context) string {
|
||||
switch s := nvim(ctx, "state"); s {
|
||||
case "shown", "hidden", "busy":
|
||||
return s
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// nvimReveal brings this lazysecrets' window back, if the plugin hid it.
|
||||
func nvimReveal(ctx context.Context) { nvim(ctx, "reveal") }
|
||||
|
||||
// nvim calls the plugin's fn with this process' pid, in the nvim that
|
||||
// started it ($NVIM), and returns what it says.
|
||||
func nvim(ctx context.Context, fn string) string {
|
||||
addr := os.Getenv("NVIM")
|
||||
if addr == "" {
|
||||
return ""
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 500*time.Millisecond) // within the link handler's second; a stuck nvim is skipped
|
||||
defer cancel()
|
||||
expr := fmt.Sprintf(`luaeval("require('lazysecrets').%s(%d)")`, fn, os.Getpid())
|
||||
out, err := exec.CommandContext(ctx, "nvim", "--server", addr, "--remote-expr", expr).Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// With a stand-in lazysecrets.nvim in a headless nvim: what it says comes
|
||||
// back, for this process' pid, and an older plugin's error is "".
|
||||
func TestNvim(t *testing.T) {
|
||||
if _, err := exec.LookPath("nvim"); err != nil {
|
||||
t.Skip("needs nvim")
|
||||
}
|
||||
dir := t.TempDir()
|
||||
lua := filepath.Join(dir, "lua")
|
||||
os.MkdirAll(lua, 0o755)
|
||||
pid := strconv.Itoa(os.Getpid())
|
||||
os.WriteFile(filepath.Join(lua, "lazysecrets.lua"), []byte(`
|
||||
local M = {}
|
||||
function M.state(pid) return pid == `+pid+` and vim.g.state or "none" end
|
||||
function M.reveal(pid) vim.g.revealed = pid; return true end
|
||||
return M
|
||||
`), 0o644)
|
||||
sock := filepath.Join(dir, "nvim.sock")
|
||||
nv := exec.Command("nvim", "--headless", "--clean", "--listen", sock, "--cmd", "set rtp^="+dir, "--cmd", "let g:state = 'hidden'")
|
||||
if err := nv.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { nv.Process.Kill(); nv.Wait() })
|
||||
for i := 0; i < 50; i++ {
|
||||
if _, err := os.Stat(sock); err == nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
t.Setenv("NVIM", sock)
|
||||
ctx := context.Background()
|
||||
|
||||
if s := nvimState(ctx); s != "hidden" {
|
||||
t.Errorf("state %q", s)
|
||||
}
|
||||
nvimReveal(ctx)
|
||||
if got := nvim(ctx, "state"); got != "hidden" {
|
||||
t.Errorf("after reveal: %q", got)
|
||||
}
|
||||
out, _ := exec.Command("nvim", "--server", sock, "--remote-expr", "g:revealed").Output()
|
||||
if string(out) != pid {
|
||||
t.Errorf("revealed %q, want this pid %s", out, pid)
|
||||
}
|
||||
|
||||
if got := nvim(ctx, "missing"); got != "" { // an older plugin
|
||||
t.Errorf("a function the plugin lacks: %q", got)
|
||||
}
|
||||
|
||||
t.Setenv("NVIM", "")
|
||||
if s := nvimState(ctx); s != "" {
|
||||
t.Errorf("outside nvim: %q", s)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package instance
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"slices"
|
||||
@@ -101,6 +102,7 @@ func Raise(front string) {
|
||||
if reach == unreachable {
|
||||
return
|
||||
}
|
||||
nvimReveal(context.Background())
|
||||
if inTmux() {
|
||||
pane := os.Getenv("TMUX_PANE")
|
||||
_, _ = tmux("select-window", "-t", pane)
|
||||
|
||||
@@ -181,10 +181,9 @@ func NewAccounts(s Settings) ([]*Provider, error) {
|
||||
if i > 0 {
|
||||
settings.Vaults = nil
|
||||
}
|
||||
label := ""
|
||||
if len(accounts) > 1 {
|
||||
label = string(provider.KindAzure) + " · " + labels[i]
|
||||
}
|
||||
// Named for its account, also when it's the only one: which
|
||||
// account lazysecrets sees Azure through is worth seeing.
|
||||
label := string(provider.KindAzure) + " · " + labels[i]
|
||||
cred := authCredential{
|
||||
cred: newCLICredential(a.user, a.tenant, func() ([]account, error) { return readAccounts(path) }),
|
||||
login: []string{"az", "login", "--tenant", a.tenant},
|
||||
@@ -195,9 +194,9 @@ func NewAccounts(s Settings) ([]*Provider, error) {
|
||||
return nil, err
|
||||
}
|
||||
p.account = &accountDetails{account: a, claims: cred.cred.(*cliCredential).claims}
|
||||
if label != "" {
|
||||
p.label = label
|
||||
if len(accounts) > 1 { // one keeps the plain ID its stars and cache are under
|
||||
p.id = string(provider.KindAzure) + ":" + a.user + "/" + a.tenant
|
||||
p.label = label
|
||||
}
|
||||
out = append(out, p)
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ type configType struct {
|
||||
format func(file string) string // yaml, properties
|
||||
parse func(file string, b []byte) ([]configKey, error)
|
||||
// jasyptSetting is the key that holds the Jasypt password for the
|
||||
// key named name.
|
||||
// key named name; nil when only $JASYPT_ENCRYPTOR_PASSWORD can.
|
||||
jasyptSetting func(name string) string
|
||||
// placeholder reads a value that only refers to another,
|
||||
// ${DB_PASSWORD}: what it names, and its default if it has one.
|
||||
placeholder func(v string) (name, def string, hasDef, ok bool)
|
||||
}
|
||||
|
||||
var configTypes = []configType{springType, composeType}
|
||||
var configTypes = []configType{springType, composeType, dotnetType}
|
||||
|
||||
func isConfig(f string) bool {
|
||||
_, ok := configTypeOf(f)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"go.yaml.in/yaml/v3"
|
||||
)
|
||||
|
||||
// .NET config files: appsettings.json and appsettings.<Environment>.json.
|
||||
// Keys are named as .NET's configuration names them, sections joined by
|
||||
// colons: ConnectionStrings:Default, Servers:0:Name.
|
||||
|
||||
var dotnetType = configType{
|
||||
name: "dotnet", is: IsDotnet, format: func(string) string { return "json" }, parse: parseDotnet,
|
||||
placeholder: dotnetPlaceholder,
|
||||
}
|
||||
|
||||
var dotnetName = regexp.MustCompile(`^appsettings(\.[^/]+)?\.json$`)
|
||||
|
||||
// IsDotnet reports whether f is named like a .NET appsettings file.
|
||||
func IsDotnet(f string) bool {
|
||||
return dotnetName.MatchString(strings.ToLower(path.Base(f)))
|
||||
}
|
||||
|
||||
// dotnetPlaceholder reads an App Service Key Vault reference,
|
||||
// @Microsoft.KeyVault(SecretUri=…): the secret is in the vault.
|
||||
func dotnetPlaceholder(v string) (name, def string, hasDef, ok bool) {
|
||||
if strings.HasPrefix(v, "@Microsoft.KeyVault(") && strings.HasSuffix(v, ")") {
|
||||
return v, "", false, true
|
||||
}
|
||||
return "", "", false, false
|
||||
}
|
||||
|
||||
func parseDotnet(_ string, b []byte) ([]configKey, error) {
|
||||
var doc yaml.Node // JSON is YAML, and the YAML parser says where each key is
|
||||
if err := yaml.Unmarshal(b, &doc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []configKey
|
||||
if len(doc.Content) > 0 {
|
||||
dotnetWalk(doc.Content[0], "", &out)
|
||||
}
|
||||
for i := range out {
|
||||
out[i].name = out[i].key
|
||||
out[i].ref = reference(dotnetPlaceholder, out[i].value)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func dotnetWalk(n *yaml.Node, name string, out *[]configKey) {
|
||||
join := func(child string) string {
|
||||
if name == "" {
|
||||
return child
|
||||
}
|
||||
return name + ":" + child
|
||||
}
|
||||
switch n.Kind {
|
||||
case yaml.MappingNode:
|
||||
for i := 0; i+1 < len(n.Content); i += 2 {
|
||||
dotnetWalk(n.Content[i+1], join(n.Content[i].Value), out)
|
||||
}
|
||||
case yaml.SequenceNode:
|
||||
for i, c := range n.Content {
|
||||
dotnetWalk(c, join(fmt.Sprint(i)), out)
|
||||
}
|
||||
case yaml.ScalarNode:
|
||||
if name != "" {
|
||||
*out = append(*out, configKey{key: name, value: n.Value, line: n.Line})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"maps"
|
||||
"testing"
|
||||
|
||||
"git.kebcloud.no/keb/lazysecrets/internal/provider"
|
||||
)
|
||||
|
||||
func TestIsDotnet(t *testing.T) {
|
||||
for f, want := range map[string]bool{
|
||||
"appsettings.json": true,
|
||||
"src/Api/appsettings.Production.json": true,
|
||||
"appsettings.Example.json": true, // listed hidden
|
||||
"appsettings.json.bak": false,
|
||||
"settings.json": false,
|
||||
"package.json": false,
|
||||
} {
|
||||
if IsDotnet(f) != want {
|
||||
t.Errorf("%s: %t", f, !want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDotnet(t *testing.T) {
|
||||
keys, err := parseDotnet("", []byte("\xef\xbb\xbf"+`{
|
||||
"ConnectionStrings": { "Default": "Server=db;Password=hunter2" },
|
||||
"AzureAd": { "ClientId": "abc", "ClientSecret": "@Microsoft.KeyVault(SecretUri=https://kv.vault.azure.net/secrets/ad)" },
|
||||
"Servers": [ { "Name": "a", "ApiKey": "k" } ],
|
||||
"Logging": { "LogLevel": { "Default": "Information" } }
|
||||
}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := map[string]string{}
|
||||
for _, k := range keys {
|
||||
ref := ""
|
||||
if k.ref {
|
||||
ref = " (ref)"
|
||||
}
|
||||
got[k.name] = k.value + ref
|
||||
}
|
||||
want := map[string]string{
|
||||
"ConnectionStrings:Default": "Server=db;Password=hunter2",
|
||||
"AzureAd:ClientId": "abc",
|
||||
"AzureAd:ClientSecret": "@Microsoft.KeyVault(SecretUri=https://kv.vault.azure.net/secrets/ad) (ref)",
|
||||
"Servers:0:Name": "a",
|
||||
"Servers:0:ApiKey": "k",
|
||||
"Logging:LogLevel:Default": "Information",
|
||||
}
|
||||
if !maps.Equal(got, want) {
|
||||
t.Errorf("got %v\nwant %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDotnetFiles(t *testing.T) {
|
||||
root := gitRepo(t, map[string]string{
|
||||
"src/Api/appsettings.json": `{
|
||||
"Logging": { "LogLevel": { "Default": "Information" } },
|
||||
"ConnectionStrings": { "Default": "Server=db;User Id=app;Password=hunter2" },
|
||||
"AzureAd": { "ClientSecret": "@Microsoft.KeyVault(VaultName=kv;SecretName=ad)" }
|
||||
}`,
|
||||
"src/Api/appsettings.Development.json": `{ "Logging": { "LogLevel": { "Default": "Debug" } } }`,
|
||||
})
|
||||
t.Setenv("JASYPT_ENCRYPTOR_PASSWORD", "")
|
||||
ctx := context.Background()
|
||||
p := New(Settings{Dir: root})
|
||||
srcs, _ := p.Sources(ctx)
|
||||
cs, err := p.Containers(ctx, srcs[0])
|
||||
if err != nil || len(cs) != 2 {
|
||||
t.Fatalf("files: %+v %v", cs, err)
|
||||
}
|
||||
for _, c := range cs {
|
||||
if c.Detail != "dotnet · json" || c.Hidden != (c.Name == "src/Api/appsettings.Development.json") {
|
||||
t.Errorf("%s: %q hidden %t", c.Name, c.Detail, c.Hidden)
|
||||
}
|
||||
}
|
||||
settings := cs[1]
|
||||
|
||||
keys, _ := p.Objects(ctx, settings, provider.TypeSecret)
|
||||
got := map[string]string{}
|
||||
for _, k := range shown(keys) {
|
||||
got[k.Name] = k.Detail
|
||||
}
|
||||
// The connection string by its value, the client secret by its name.
|
||||
if want := map[string]string{"ConnectionStrings:Default": "", "AzureAd:ClientSecret": "reference"}; !maps.Equal(got, want) {
|
||||
t.Errorf("keys %v, want %v", got, want)
|
||||
}
|
||||
link := provider.Object{Container: provider.Container{Source: srcs[0], Name: "src/Api/appsettings.json"}, Name: "ConnectionStrings:Default"}
|
||||
if v, err := p.Value(ctx, link); err != nil || v.Reveal() != "Server=db;User Id=app;Password=hunter2" {
|
||||
t.Errorf("value: %q %v", v.Reveal(), err)
|
||||
}
|
||||
if f, _ := p.File(settings, &link); f.Line != 3 {
|
||||
t.Errorf("line %d", f.Line)
|
||||
}
|
||||
if d, plain := p.configDetails(dotnetType, settings); !plain || d[1].Value != "1, not matched by the secret patterns" {
|
||||
t.Errorf("details: %+v %t", d, plain)
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,9 @@ func jasyptPassword(file, name string) (password, from string, err error) {
|
||||
}
|
||||
setting, read, placeholder := jasyptEnv, plainValue, composePlaceholder // env files interpolate like compose
|
||||
if t, ok := configTypeOf(file); ok {
|
||||
if t.jasyptSetting == nil {
|
||||
return "", "", fmt.Errorf("jasypt: no password: set $%s", jasyptEnv)
|
||||
}
|
||||
setting, read, placeholder = t.jasyptSetting(name), t.value, t.placeholder
|
||||
}
|
||||
v, err := read(file, setting)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package repo browses the encrypted secret files in git repositories:
|
||||
// a repo is a source, its secret files the containers (vault level), and
|
||||
// their keys the secrets. Secret files are SOPS files, plain env files and
|
||||
// config files: Spring Boot's and Docker Compose's (configfile.go).
|
||||
// config files: Spring Boot's, Docker Compose's and .NET's (configfile.go).
|
||||
//
|
||||
// Listing never decrypts: SOPS encrypts values only, so a file's keys and
|
||||
// metadata are read directly. A value is decrypted when it's revealed or
|
||||
@@ -640,6 +640,7 @@ type lazysecretsFile struct {
|
||||
SecretPatterns SecretPatterns `yaml:"secretPatterns"`
|
||||
Spring FileType `yaml:"spring"`
|
||||
Compose FileType `yaml:"compose"`
|
||||
Dotnet FileType `yaml:"dotnet"`
|
||||
Sharing struct {
|
||||
// Key is the link to the secret that encrypts the repo's
|
||||
// shared env files (package share).
|
||||
@@ -648,7 +649,7 @@ type lazysecretsFile struct {
|
||||
}
|
||||
|
||||
func (f lazysecretsFile) types() map[string]FileType {
|
||||
return map[string]FileType{"spring": f.Spring, "compose": f.Compose}
|
||||
return map[string]FileType{"spring": f.Spring, "compose": f.Compose, "dotnet": f.Dotnet}
|
||||
}
|
||||
|
||||
// ShareKey is the sharing.key of the repo's .lazysecrets.yaml, if any.
|
||||
|
||||
@@ -536,6 +536,7 @@ func (m Model) Init() tea.Cmd {
|
||||
if m.fetchOnStart {
|
||||
cmds = append(cmds, m.fetchLatest(false))
|
||||
}
|
||||
cmds = append(cmds, m.watchBinary())
|
||||
if m.open != nil {
|
||||
msg := openRefMsg{ref: *m.open, action: m.openAction}
|
||||
cmds = append(cmds, func() tea.Msg { return msg })
|
||||
@@ -600,6 +601,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case installedMsg:
|
||||
m.handleInstalled(msg)
|
||||
|
||||
case binaryTickMsg:
|
||||
cmds = append(cmds, m.lookAtBinary())
|
||||
|
||||
case replacedMsg:
|
||||
cmds = append(cmds, m.handleReplaced(msg))
|
||||
|
||||
case currentMsg:
|
||||
if msg.gen == m.sourcesGen {
|
||||
m.current = &msg.source
|
||||
|
||||
@@ -145,8 +145,8 @@ func (m Model) objectRender() func(styles.Styles, provider.Object, int) string {
|
||||
}
|
||||
|
||||
// fileIcon is a repo file's icon, in its colour: a lock for an encrypted
|
||||
// one, a leaf for Spring config, a whale for compose, a file in the
|
||||
// warning colour for plain text; "" for other vaults, or without icons.
|
||||
// one, a leaf for Spring config, a whale for compose, .NET's for
|
||||
// appsettings, a file in the warning colour for plain text; "" for other vaults, or without icons.
|
||||
func (m Model) fileIcon(sty styles.Styles, c provider.Container) string {
|
||||
if c.Source.Kind != provider.KindRepo {
|
||||
return ""
|
||||
@@ -157,6 +157,8 @@ func (m Model) fileIcon(sty styles.Styles, c provider.Container) string {
|
||||
icon, style = m.icons.Spring, sty.Spring
|
||||
case strings.HasPrefix(c.Detail, "compose"):
|
||||
icon, style = m.icons.Compose, sty.Compose
|
||||
case strings.HasPrefix(c.Detail, "dotnet"):
|
||||
icon, style = m.icons.Dotnet, sty.Dotnet
|
||||
case !strings.HasPrefix(c.Detail, "sops"):
|
||||
icon, style = m.icons.PlainFile, sty.Warning
|
||||
}
|
||||
|
||||
@@ -643,7 +643,11 @@ func (m *Model) advanceNav() bool {
|
||||
}
|
||||
}
|
||||
if n.link {
|
||||
m.focus = paneDetail // after: copying acts on the focused pane
|
||||
// After: copying acts on the focused pane. The details describe
|
||||
// the secret: when its lists were loaded already, the open got
|
||||
// here in one update, and the Secrets pane was never the last
|
||||
// left pane in focus.
|
||||
m.lastLeft, m.focus = paneSecrets, paneDetail
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -626,3 +626,17 @@ func TestShareWebPages(t *testing.T) {
|
||||
t.Errorf("secret web page %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// A link whose lists are there already (a repo's files, or cached) gets
|
||||
// to the secret in one update: the details describe it all the same, not
|
||||
// the repo, with no need to press 3.
|
||||
func TestOpenLinkToRepoSecret(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, _ := ref.Parse("lazysecrets://repo/github.com%2Facme%2Forders-service/docker-compose.yml/api.DB_PASSWORD")
|
||||
d := newDriverOpts(t, Options{Open: &r}, fake.Repos())
|
||||
d.keys("o")
|
||||
o, ok := d.m.detail.Secret()
|
||||
if _, _, s := d.selected(); s != "api.DB_PASSWORD" || d.m.focus != paneDetail || d.m.detailOf() != paneSecrets || !ok || o.Name != "api.DB_PASSWORD" {
|
||||
t.Errorf("selected %q, focus %v describing %v, detail %q", s, d.m.focus, d.m.detailOf(), o.Name)
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,44 @@ import (
|
||||
type Updater struct {
|
||||
Latest func(context.Context) (update.Release, error)
|
||||
Install func(context.Context, update.Release) error
|
||||
// Replaced says the version of a lazysecrets installed over the
|
||||
// running one since it last looked; nil doesn't look.
|
||||
Replaced func(context.Context) (version string, ok bool)
|
||||
}
|
||||
|
||||
// binaryEvery is how often lazysecrets looks whether a newer binary was
|
||||
// installed over it: a stat.
|
||||
const binaryEvery = time.Minute
|
||||
|
||||
type binaryTickMsg struct{}
|
||||
|
||||
type replacedMsg struct{ version string }
|
||||
|
||||
func (m Model) watchBinary() tea.Cmd {
|
||||
if m.updater == nil || m.updater.Replaced == nil {
|
||||
return nil
|
||||
}
|
||||
return tea.Tick(binaryEvery, func(time.Time) tea.Msg { return binaryTickMsg{} })
|
||||
}
|
||||
|
||||
func (m Model) lookAtBinary() tea.Cmd {
|
||||
replaced := m.updater.Replaced
|
||||
return func() tea.Msg {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
v, _ := replaced(ctx)
|
||||
return replacedMsg{version: v}
|
||||
}
|
||||
}
|
||||
|
||||
// handleReplaced says a newer lazysecrets was installed over this one,
|
||||
// as an update from U does, and looks again later.
|
||||
func (m *Model) handleReplaced(msg replacedMsg) tea.Cmd {
|
||||
if msg.version != "" && msg.version != m.version && msg.version != m.updated {
|
||||
m.updated = msg.version
|
||||
m.flash = done("lazysecrets " + msg.version + " was installed · restart lazysecrets to use it")
|
||||
}
|
||||
return m.watchBinary()
|
||||
}
|
||||
|
||||
// updateEvery is how often lazysecrets looks for a newer release on its
|
||||
|
||||
@@ -130,3 +130,25 @@ func TestStartupWarning(t *testing.T) {
|
||||
t.Errorf("no warning:\n%s", d.screen())
|
||||
}
|
||||
}
|
||||
|
||||
// A newer lazysecrets installed over the running one, from anywhere, is
|
||||
// said as an update from U is.
|
||||
func TestBinaryReplaced(t *testing.T) {
|
||||
t.Parallel()
|
||||
installed := ""
|
||||
u := &Updater{
|
||||
Latest: func(context.Context) (update.Release, error) { return update.Release{}, errors.New("offline") },
|
||||
Install: func(context.Context, update.Release) error { return nil },
|
||||
Replaced: func(context.Context) (string, bool) { return installed, installed != "" },
|
||||
}
|
||||
d := newDriverOpts(t, Options{Version: "v0.3.0", Updater: u})
|
||||
d.send(binaryTickMsg{})
|
||||
if strings.Contains(d.screen(), "restart") {
|
||||
t.Fatalf("nothing installed, yet:\n%s", d.screen())
|
||||
}
|
||||
installed = "v0.3.1"
|
||||
d.send(binaryTickMsg{})
|
||||
if scr := d.screen(); !strings.Contains(scr, "lazysecrets v0.3.1 was installed · restart lazysecrets to use it") || !strings.Contains(scr, "→ v0.3.1 (restart)") {
|
||||
t.Errorf("after an install:\n%s", scr)
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ type Set struct {
|
||||
PlainFile string // a plain text secrets file (.env)
|
||||
Spring string // a Spring Boot config file
|
||||
Compose string // a Docker Compose file
|
||||
Dotnet string // a .NET appsettings file
|
||||
Note string // has a note (lazysecrets list)
|
||||
}
|
||||
|
||||
@@ -29,6 +30,7 @@ var NerdFont = Set{
|
||||
PlainFile: "\U000F0214", // md-file
|
||||
Spring: "\U000F032A", // md-leaf
|
||||
Compose: "\U000F0868", // md-docker
|
||||
Dotnet: "\U000F0AAE", // md-dot_net
|
||||
Note: "\U000F09ED",
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func (m *Map) Actions() []Action {
|
||||
a(Lists, "prevTab", &m.PrevTab, "prev tab", "lists", "Previous tab of the focused pane: Sources and Favourites in Sources; Secrets, Keys, Certs in Secrets."),
|
||||
a(Lists, "nextTab", &m.NextTab, "next tab", "lists", "Next tab of the focused pane."),
|
||||
a(Lists, "sourcesView", &m.SourcesView, "grouped/flat sources", "lists", "Switch the Sources pane between grouped by provider and a flat list."),
|
||||
a(Lists, "toggleHidden", &m.ToggleHidden, "show/hide hidden", "lists", "Show or hide what's hidden: Spring and compose keys that don't look like secrets, example files (.env.example), and files and repos with only those. Shown, they're dimmed; Go to finds them too."),
|
||||
a(Lists, "toggleHidden", &m.ToggleHidden, "show/hide hidden", "lists", "Show or hide what's hidden: config file keys (Spring, compose, .NET) that don't look like secrets, example files (.env.example), and files and repos with only those. Shown, they're dimmed; Go to finds them too."),
|
||||
a(Lists, "star", &m.Favourite, "star", "lists", "Star or unstar the selected subscription, vault or secret, for the account showing it. Starred items get a ★ and sort first."),
|
||||
a(Lists, "goTo", &m.Search, "search", "lists", "Go to anything: search every vault and secret loaded and jump to one. Again in Go to: only the source or group you're in, and back to all. On the left, the scope: All, an account (or Databricks, or Repos), or one source (○ ◐ ● for how much of it is loaded)."),
|
||||
a(Lists, "favourites", &m.Favourites, "favourites", "lists", "Go to, on Favourites: everything you've starred, to search and jump to."),
|
||||
|
||||
@@ -36,6 +36,7 @@ type Styles struct {
|
||||
KindRepo lipgloss.Style
|
||||
Spring lipgloss.Style // Spring Boot config files
|
||||
Compose lipgloss.Style // Docker Compose files
|
||||
Dotnet lipgloss.Style // .NET appsettings files
|
||||
|
||||
// themed marks the selection colours as set by the theme, so
|
||||
// OnBackground leaves them.
|
||||
@@ -74,6 +75,7 @@ func Default() Styles {
|
||||
KindRepo: lipgloss.NewStyle().Foreground(lipgloss.Magenta),
|
||||
Spring: lipgloss.NewStyle().Foreground(lipgloss.Green),
|
||||
Compose: lipgloss.NewStyle().Foreground(lipgloss.Blue),
|
||||
Dotnet: lipgloss.NewStyle().Foreground(lipgloss.BrightMagenta),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ var Roles = map[string]string{
|
||||
"repoColor": "repos and their secret files (SOPS)",
|
||||
"springColor": "Spring Boot config files",
|
||||
"composeColor": "Docker Compose files",
|
||||
"dotnetColor": ".NET appsettings files",
|
||||
}
|
||||
|
||||
// FromTheme returns the default styles with the theme's roles applied, and
|
||||
@@ -105,6 +106,8 @@ func FromTheme(theme map[string][]string) (Styles, color.Color, error) {
|
||||
st.Spring = v.fg(lipgloss.NewStyle())
|
||||
case "composeColor":
|
||||
st.Compose = v.fg(lipgloss.NewStyle())
|
||||
case "dotnetColor":
|
||||
st.Dotnet = v.fg(lipgloss.NewStyle())
|
||||
}
|
||||
}
|
||||
return st, fg, nil
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package update
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Binary is the binary a running lazysecrets started from, to notice a
|
||||
// newer one installed over it (by install.sh, go install, a package
|
||||
// manager or another lazysecrets): the running one keeps its old code
|
||||
// until it restarts.
|
||||
type Binary struct {
|
||||
path string // as started, not resolved: a symlink a package manager moves is followed
|
||||
info os.FileInfo
|
||||
}
|
||||
|
||||
// Running is the binary this process runs, as it is now.
|
||||
func Running() (*Binary, error) {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info, err := os.Stat(exe)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Binary{path: exe, info: info}, nil
|
||||
}
|
||||
|
||||
// Replaced is the version of a binary installed over b since it was last
|
||||
// looked at, as its --version says; ok is false while it's the same
|
||||
// file. A look costs a stat; --version runs only when it changed.
|
||||
func (b *Binary) Replaced(ctx context.Context) (version string, ok bool) {
|
||||
info, err := os.Stat(b.path)
|
||||
if err != nil || (os.SameFile(b.info, info) && info.ModTime().Equal(b.info.ModTime())) {
|
||||
return "", false
|
||||
}
|
||||
out, err := exec.CommandContext(ctx, b.path, "--version").Output()
|
||||
if err != nil {
|
||||
return "", false // mid-install, or broken: look again later
|
||||
}
|
||||
b.info = info
|
||||
v, ok := strings.CutPrefix(strings.TrimSpace(string(out)), "lazysecrets ")
|
||||
return v, ok
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package update
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBinaryReplaced(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
exe := filepath.Join(dir, "lazysecrets")
|
||||
write := func(version string) {
|
||||
t.Helper()
|
||||
tmp := filepath.Join(dir, ".new")
|
||||
if err := os.WriteFile(tmp, []byte("#!/bin/sh\necho lazysecrets "+version+"\n"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Rename(tmp, exe); err != nil { // as Install and install.sh do
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
write("v0.3.0")
|
||||
info, _ := os.Stat(exe)
|
||||
b := &Binary{path: exe, info: info}
|
||||
ctx := context.Background()
|
||||
|
||||
if v, ok := b.Replaced(ctx); ok {
|
||||
t.Errorf("the same file: replaced by %q", v)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
write("v0.3.1")
|
||||
if v, ok := b.Replaced(ctx); !ok || v != "v0.3.1" {
|
||||
t.Errorf("installed over: %q %t", v, ok)
|
||||
}
|
||||
if v, ok := b.Replaced(ctx); ok {
|
||||
t.Errorf("said again: %q", v)
|
||||
}
|
||||
}
|
||||
+15
-7
@@ -11,12 +11,20 @@
|
||||
# listed under the release that follows.
|
||||
set -euo pipefail
|
||||
|
||||
dry=false
|
||||
if [ "${1:-}" = "--dry-run" ]; then
|
||||
dry=true
|
||||
shift
|
||||
fi
|
||||
tag="${1:?usage: $0 [--dry-run] <patch|minor|major, or a tag like v0.2.0>}"
|
||||
usage="usage: $0 [--dry-run] <patch|minor|major, or a tag like v0.2.0>"
|
||||
# Options anywhere: minor --dry-run must not release.
|
||||
dry=false tag=""
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run | -n) dry=true ;;
|
||||
-*) echo "$arg: unknown option. $usage" >&2; exit 1 ;;
|
||||
*)
|
||||
[ -z "$tag" ] || { echo "$arg: one version only. $usage" >&2; exit 1; }
|
||||
tag=$arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
[ -n "$tag" ] || { echo "$usage" >&2; exit 1; }
|
||||
command -v git-cliff >/dev/null || { echo "git-cliff is needed: brew install git-cliff" >&2; exit 1; }
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
@@ -47,7 +55,7 @@ echo "$tag$bumped"
|
||||
|
||||
notes=$(git cliff --unreleased --tag "$tag" --strip all)
|
||||
if ! grep -q '^- ' <<<"$notes"; then
|
||||
echo "Nothing for the changelog since the last release (no feat/fix/perf pull requests)." >&2
|
||||
echo "Nothing for the changelog since the last release (no feat/fix/perf or [security] pull requests)." >&2
|
||||
$dry || exit 1
|
||||
fi
|
||||
echo "$notes"
|
||||
|
||||
Reference in new issue
Block a user