diff --git a/cmd/dbc/sync.go b/cmd/dbc/sync.go index 6e2648d0..d6f71674 100644 --- a/cmd/dbc/sync.go +++ b/cmd/dbc/sync.go @@ -26,25 +26,25 @@ var ( ) type SyncCmd struct { - Path string `arg:"-p" placeholder:"FILE" default:"./dbc.toml" help:"Driver list to sync from"` - Level config.ConfigLevel `arg:"-l" help:"Config level to install to (user, system)"` - AllowMissing bool `arg:"--allow-missing-signature" help:"Allow installation of drivers without a signature file"` + Path string `arg:"-p" placeholder:"FILE" default:"./dbc.toml" help:"Driver list to sync from"` + Level config.ConfigLevel `arg:"-l" help:"Config level to install to (user, system)"` + NoVerify bool `arg:"--no-verify" help:"Allow installation of drivers without a signature file"` } func (c SyncCmd) GetModelCustom(baseModel baseModel) tea.Model { return syncModel{ - baseModel: baseModel, - Path: c.Path, - cfg: getConfig(c.Level), - AllowMissing: c.AllowMissing, + baseModel: baseModel, + Path: c.Path, + cfg: getConfig(c.Level), + NoVerify: c.NoVerify, } } func (c SyncCmd) GetModel() tea.Model { return syncModel{ - Path: c.Path, - cfg: getConfig(c.Level), - AllowMissing: c.AllowMissing, + Path: c.Path, + cfg: getConfig(c.Level), + NoVerify: c.NoVerify, baseModel: baseModel{ getDriverList: getDriverList, downloadPkg: downloadPkg, @@ -57,7 +57,7 @@ type syncModel struct { // path to driver list Path string - AllowMissing bool + NoVerify bool LockFilePath string // information to write the new lockfile locked LockFile @@ -258,7 +258,7 @@ func (s syncModel) installDriver(cfg config.Config, item installItem) tea.Cmd { manifest.DriverInfo.Source = "dbc" manifest.DriverInfo.Driver.Shared.Set(config.PlatformTuple(), driverPath) - if err := verifySignature(manifest, s.AllowMissing); err != nil { + if err := verifySignature(manifest, s.NoVerify); err != nil { _ = os.RemoveAll(finalDir) return fmt.Errorf("failed to verify signature: %w", err) } diff --git a/cmd/dbc/sync_test.go b/cmd/dbc/sync_test.go index 8748a31d..96ff5fde 100644 --- a/cmd/dbc/sync_test.go +++ b/cmd/dbc/sync_test.go @@ -130,3 +130,18 @@ func (suite *SubcommandTestSuite) TestSyncInstallFailSig() { "", suite.runCmdErr(m)) suite.Equal([]string{"dbc.toml"}, suite.getFilesInTempDir()) } + +func (suite *SubcommandTestSuite) TestSyncInstallNoVerify() { + m := InitCmd{Path: filepath.Join(suite.tempdir, "dbc.toml")}.GetModel() + suite.runCmd(m) + + m = AddCmd{Path: filepath.Join(suite.tempdir, "dbc.toml"), Driver: "test-driver-no-sig"}.GetModel() + suite.runCmd(m) + + m = SyncCmd{ + Path: filepath.Join(suite.tempdir, "dbc.toml"), + NoVerify: true, + }.GetModelCustom( + baseModel{getDriverList: getTestDriverList, downloadPkg: downloadTestPkg}) + suite.validateOutput("✓ test-driver-no-sig-1.1.0\r\n\rDone!\r\n", "", suite.runCmd(m)) +} diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 7efb8c54..0134b819 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -191,6 +191,6 @@ dbc sync --file dbc.toml : The configuration level to install drivers to (`user`, or `system`). See [Config Level](config_level.md). -`--allow-missing-signature` +`--no-verify` : Allow installation of drivers without a signature file