From 2b3b2f1755fdacfbf0c81793e97d3f7611da0389 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 27 May 2020 13:54:10 +0200 Subject: [PATCH] Refactor sink command, add --signature-in-path --- system/commands/sink.go | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/system/commands/sink.go b/system/commands/sink.go index 4a2d836ef..a9db288c1 100644 --- a/system/commands/sink.go +++ b/system/commands/sink.go @@ -9,11 +9,8 @@ import ( // Will perform OpenID connect auto-configuration func Sink() *cobra.Command { var ( - expires string - origin string - contentType string - method string - maxBodySize int64 + expires string + srup = service.SinkRequestUrlParams{} ) cmd := &cobra.Command{ @@ -25,15 +22,6 @@ func Sink() *cobra.Command { Use: "signature", Short: "Creates signature for sink HTTP endpoint", RunE: func(cmd *cobra.Command, args []string) error { - var ( - srup = service.SinkRequestUrlParams{ - Method: method, - Origin: origin, - ContentType: contentType, - MaxBodySize: maxBodySize, - } - ) - if expires != "" { // validate expiration date if set if exp, err := time.Parse("2006-01-02", expires); err != nil { @@ -56,13 +44,13 @@ func Sink() *cobra.Command { } signatureCmd.Flags().StringVar( - &origin, + &srup.Origin, "origin", "", "Origin of the request (arbitrary string, optional)") signatureCmd.Flags().StringVar( - &contentType, + &srup.ContentType, "content-type", "", "Content type (optional)") @@ -74,17 +62,23 @@ func Sink() *cobra.Command { "Date of expiration (YYYY-MM-DD, optional)") signatureCmd.Flags().StringVar( - &method, + &srup.Method, "method", "GET", - "HTTP method that will be used") + "HTTP method that will be used (optional)") signatureCmd.Flags().Int64Var( - &maxBodySize, + &srup.MaxBodySize, "max-body-size", 0, "Max allowed body size") + signatureCmd.Flags().BoolVar( + &srup.SignatureInPath, + "signature-in-path", + false, + "Include signature in a path instead of query string") + cmd.AddCommand( signatureCmd, )