From 6785893de61c0253fb6053937e01c1835c928955 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 19 Dec 2022 09:33:25 +0800 Subject: [PATCH] fix: add stdin password Signed-off-by: Billy Zha --- cmd/oras/discover.go | 3 +++ cmd/oras/repository/ls.go | 3 +++ cmd/oras/repository/tags.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/cmd/oras/discover.go b/cmd/oras/discover.go index 9d5da4d93..ca8c95ad6 100644 --- a/cmd/oras/discover.go +++ b/cmd/oras/discover.go @@ -62,6 +62,9 @@ Example - Discover referrers with type 'test-artifact' of manifest 'hello:latest oras discover --artifact-type test-artifact localhost:5000/hello `, Args: cobra.ExactArgs(1), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.ReadPassword() + }, RunE: func(cmd *cobra.Command, args []string) error { opts.targetRef = args[0] return runDiscover(opts) diff --git a/cmd/oras/repository/ls.go b/cmd/oras/repository/ls.go index ae56e0363..40963b404 100644 --- a/cmd/oras/repository/ls.go +++ b/cmd/oras/repository/ls.go @@ -46,6 +46,9 @@ Example - List the repositories under the registry that include values lexically `, Args: cobra.ExactArgs(1), Aliases: []string{"list"}, + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.ReadPassword() + }, RunE: func(cmd *cobra.Command, args []string) error { opts.hostname = args[0] return listRepository(opts) diff --git a/cmd/oras/repository/tags.go b/cmd/oras/repository/tags.go index c297d3897..abc6cc202 100644 --- a/cmd/oras/repository/tags.go +++ b/cmd/oras/repository/tags.go @@ -52,6 +52,9 @@ Example - Show tags of the target repository that include values lexically after `, Args: cobra.ExactArgs(1), Aliases: []string{"show-tags"}, + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.ReadPassword() + }, RunE: func(cmd *cobra.Command, args []string) error { opts.targetRef = args[0] return showTags(opts)