Skip to content

Commit

Permalink
Merge branch 'notaryproject:main' into cert
Browse files Browse the repository at this point in the history
  • Loading branch information
Two-Hearts authored Oct 10, 2023
2 parents 457a019 + b352d1e commit dcbf1c0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cmd/notation/policy/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ Example - Import trust policy configuration from a file:
}

func runImport(command *cobra.Command, opts importOpts) error {
// optional confirmation
if !opts.force {
if _, err := trustpolicy.LoadDocument(); err == nil {
confirmed, err := cmdutil.AskForConfirmation(os.Stdin, "Existing trust policy configuration found, do you want to overwrite it?", opts.force)
if err != nil {
return err
}
if !confirmed {
return nil
}
}
} else {
fmt.Fprintln(os.Stderr, "Warning: existing trust policy configuration file will be overwritten")
}

// read configuration
policyJSON, err := os.ReadFile(opts.filePath)
if err != nil {
Expand All @@ -83,6 +68,21 @@ func runImport(command *cobra.Command, opts importOpts) error {
return fmt.Errorf("failed to validate trust policy: %w", err)
}

// optional confirmation
if !opts.force {
if _, err := trustpolicy.LoadDocument(); err == nil {
confirmed, err := cmdutil.AskForConfirmation(os.Stdin, "Existing trust policy configuration found, do you want to overwrite it?", opts.force)
if err != nil {
return err
}
if !confirmed {
return nil
}
}
} else {
fmt.Fprintln(os.Stderr, "Warning: existing trust policy configuration file will be overwritten")
}

// write
policyPath, err := dir.ConfigFS().SysPath(dir.PathTrustPolicy)
if err != nil {
Expand Down

0 comments on commit dcbf1c0

Please sign in to comment.