From 7203cbf8469e751e7f36e938176673332767bfc3 Mon Sep 17 00:00:00 2001 From: elastic17 <44340390+elastic17@users.noreply.github.com> Date: Wed, 14 Aug 2024 20:30:22 +0800 Subject: [PATCH] Remove redundant code and simplify input parsing during HTTPTrigger creation (#2990) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 去除environment创建操作中的注释及更新过程中存在的冗余代码 * Remove redundant code and simplify input parsing during HTTPTrigger creation --------- Co-authored-by: yufu huang --- pkg/fission-cli/cmd/httptrigger/create.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pkg/fission-cli/cmd/httptrigger/create.go b/pkg/fission-cli/cmd/httptrigger/create.go index 909fa13e..d61c8f9e 100644 --- a/pkg/fission-cli/cmd/httptrigger/create.go +++ b/pkg/fission-cli/cmd/httptrigger/create.go @@ -107,9 +107,6 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { } methods := input.StringSlice(flagkey.HtMethod) - if len(methods) == 0 { - return errors.New("HTTP methods not mentioned") - } for _, method := range methods { _, err := GetMethod(method) @@ -166,7 +163,6 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { } } - createIngress := input.Bool(flagkey.HtIngress) ingressConfig, err := GetIngressConfig( input.StringSlice(flagkey.HtIngressAnnotation), input.String(flagkey.HtIngressRule), input.String(flagkey.HtIngressTLS), fallbackURL, nil) @@ -174,26 +170,20 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { return errors.Wrap(err, "error parsing ingress configuration") } - host := input.String(flagkey.HtHost) - opts.trigger = &fv1.HTTPTrigger{ ObjectMeta: m, Spec: fv1.HTTPTriggerSpec{ - Host: host, + Host: input.String(flagkey.HtHost), RelativeURL: triggerUrl, Methods: methods, FunctionReference: *functionRef, - CreateIngress: createIngress, + CreateIngress: input.Bool(flagkey.HtIngress), IngressConfig: *ingressConfig, Prefix: &prefix, KeepPrefix: input.Bool(flagkey.HtKeepPrefix), }, } - if input.IsSet(flagkey.HtKeepPrefix) { - opts.trigger.Spec.KeepPrefix = input.Bool(flagkey.HtKeepPrefix) - } - return nil }