Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions cmd/dbc/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/dbc/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading