Skip to content

Commit

Permalink
refactor: replace error-ignored cobra output functions (#1454)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored Jul 23, 2024
1 parent 5067a9a commit 92bf5e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ func (opts *Remote) Parse(cmd *cobra.Command) error {
// optional cmd prompt.
func (opts *Remote) readSecret(cmd *cobra.Command) (err error) {
if cmd.Flags().Changed(identityTokenFlag) {
cmd.PrintErrln("WARNING! Using --identity-token via the CLI is insecure. Use --identity-token-stdin.")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "WARNING! Using --identity-token via the CLI is insecure. Use --identity-token-stdin.")
} else if cmd.Flags().Changed(passwordFlag) {
cmd.PrintErrln("WARNING! Using --password via the CLI is insecure. Use --password-stdin.")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "WARNING! Using --password via the CLI is insecure. Use --password-stdin.")
} else if opts.secretFromStdin {
// Prompt for credential
secret, err := io.ReadAll(os.Stdin)
Expand Down
3 changes: 2 additions & 1 deletion cmd/oras/root/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package root
import (
"context"
"errors"
"fmt"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -84,7 +85,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout
if cmd.Flags().Changed("output") {
switch opts.Format.Type {
case "tree", "json", "table":
cmd.PrintErrf("[DEPRECATED] --output is deprecated, try `--format %s` instead\n", opts.Template)
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "[DEPRECATED] --output is deprecated, try `--format %s` instead\n", opts.Template)
default:
return errors.New("output type can only be tree, table or json")
}
Expand Down

0 comments on commit 92bf5e3

Please sign in to comment.