Skip to content

Commit

Permalink
fix: resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Mar 1, 2023
1 parent 120d114 commit a123b9f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
3 changes: 1 addition & 2 deletions cmd/notation-azure-kv/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (
)

func runDescribeKey(ctx context.Context) error {
r := os.Stdin
var req proto.DescribeKeyRequest
err := json.NewDecoder(r).Decode(&req)
err := json.NewDecoder(os.Stdin).Decode(&req)
if err != nil {
return proto.RequestError{
Code: proto.ErrorCodeValidation,
Expand Down
32 changes: 17 additions & 15 deletions cmd/notation-azure-kv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func main() {
}
ctx := context.Background()
var err error
switch os.Args[1] {
case string(proto.CommandGetMetadata):
runGetMetadata()
case string(proto.CommandDescribeKey):
switch proto.Command(os.Args[1]) {
case proto.CommandGetMetadata:
err = runGetMetadata()
case proto.CommandDescribeKey:
err = runDescribeKey(ctx)
case string(proto.CommandGenerateSignature):
case proto.CommandGenerateSignature:
err = runSign(ctx)
default:
err = fmt.Errorf("invalid command: %s", os.Args[1])
Expand All @@ -44,18 +44,20 @@ func main() {
}

func help() {
fmt.Printf(`NAME:
notation-azure-kv - Notation - Notary V2 Azure KV plugin
fmt.Printf(`notation-azure-kv - Notation - Notary V2 Azure KV plugin
USAGE:
notation-azure-kv [global options] command [command options] [arguments...]
Usage:
notation-azure-kv <command>
VERSION:
%s
Version:
%s
COMMANDS:
get-plugin-metadata Get plugin metadata
generate-signature Sign artifacts with keys in Azure Key Vault
describe-key Azure key description
Commands:
get-plugin-metadata Get plugin metadata
generate-signature Sign artifacts with keys in Azure Key Vault
describe-key Azure key description
Documentation:
https://github.com/notaryproject/notaryproject/blob/main/specs/plugin-extensibility.md#plugin-contract
`, version.GetVersion())
}
5 changes: 3 additions & 2 deletions cmd/notation-azure-kv/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func init() {
}
}

func runGetMetadata() {
func runGetMetadata() error {
// write response
os.Stdout.Write(metadata)
_, err := os.Stdout.Write(metadata)
return err
}
3 changes: 1 addition & 2 deletions cmd/notation-azure-kv/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (
)

func runSign(ctx context.Context) error {
r := os.Stdin
var req proto.GenerateSignatureRequest
err := json.NewDecoder(r).Decode(&req)
err := json.NewDecoder(os.Stdin).Decode(&req)
if err != nil {
return proto.RequestError{
Code: proto.ErrorCodeValidation,
Expand Down

0 comments on commit a123b9f

Please sign in to comment.