diff --git a/pkg/providers/http/http.cue b/pkg/providers/http/http.cue index c570ac8..403dc44 100644 --- a/pkg/providers/http/http.cue +++ b/pkg/providers/http/http.cue @@ -29,7 +29,7 @@ // +usgae=The tls config of the request tls_config?: { secret: string - namespace: context.namespace + namespace?: string } } diff --git a/pkg/providers/http/http.go b/pkg/providers/http/http.go index f6069f0..d0a3f77 100644 --- a/pkg/providers/http/http.go +++ b/pkg/providers/http/http.go @@ -34,6 +34,7 @@ import ( cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" providertypes "github.com/kubevela/workflow/pkg/providers/types" ) @@ -145,6 +146,9 @@ func runHTTP(ctx context.Context, params *DoParams) (*DoReturns, error) { req.Trailer = trailer if params.Params.TLSConfig != nil { + if params.Params.TLSConfig.Namespace == "" { + params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace)) + } if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil { defaultClient.Transport = tr } diff --git a/pkg/providers/legacy/http/http.cue b/pkg/providers/legacy/http/http.cue index 566674e..98ceaad 100644 --- a/pkg/providers/legacy/http/http.cue +++ b/pkg/providers/legacy/http/http.cue @@ -28,7 +28,7 @@ // +usgae=The tls config of the request tls_config?: { secret: string - namespace: context.namespace + namespace?: string } // +usage=The response of the request will be filled in this field after the action is executed response: { diff --git a/pkg/providers/legacy/http/http.go b/pkg/providers/legacy/http/http.go index db59f2b..77688f4 100644 --- a/pkg/providers/legacy/http/http.go +++ b/pkg/providers/legacy/http/http.go @@ -34,6 +34,7 @@ import ( cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" providertypes "github.com/kubevela/workflow/pkg/providers/types" ) @@ -69,7 +70,7 @@ type RateLimiter struct { // TLSConfig . type TLSConfig struct { Secret string `json:"secret"` - Namespace string `json:"namespace"` + Namespace string `json:"namespace,omitempty"` } // RequestVars is the vars for http request @@ -142,6 +143,9 @@ func runHTTP(ctx context.Context, params *DoParams) (*ResponseVars, error) { req.Trailer = trailer if params.Params.TLSConfig != nil { + if params.Params.TLSConfig.Namespace == "" { + params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace)) + } if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil { defaultClient.Transport = tr }