Skip to content

Commit 76db4ac

Browse files
authored
Fix: fix context in provider (#194)
fix: fix context in provider Signed-off-by: FogDong <[email protected]>
1 parent 94c9275 commit 76db4ac

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

pkg/providers/http/http.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// +usgae=The tls config of the request
3030
tls_config?: {
3131
secret: string
32-
namespace: context.namespace
32+
namespace?: string
3333
}
3434
}
3535

pkg/providers/http/http.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime"
3636

37+
"github.com/kubevela/workflow/pkg/cue/model"
3738
"github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter"
3839
providertypes "github.com/kubevela/workflow/pkg/providers/types"
3940
)
@@ -145,6 +146,9 @@ func runHTTP(ctx context.Context, params *DoParams) (*DoReturns, error) {
145146
req.Trailer = trailer
146147

147148
if params.Params.TLSConfig != nil {
149+
if params.Params.TLSConfig.Namespace == "" {
150+
params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace))
151+
}
148152
if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil {
149153
defaultClient.Transport = tr
150154
}

pkg/providers/legacy/http/http.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// +usgae=The tls config of the request
2929
tls_config?: {
3030
secret: string
31-
namespace: context.namespace
31+
namespace?: string
3232
}
3333
// +usage=The response of the request will be filled in this field after the action is executed
3434
response: {

pkg/providers/legacy/http/http.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434

3535
cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime"
3636

37+
"github.com/kubevela/workflow/pkg/cue/model"
3738
"github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter"
3839
providertypes "github.com/kubevela/workflow/pkg/providers/types"
3940
)
@@ -69,7 +70,7 @@ type RateLimiter struct {
6970
// TLSConfig .
7071
type TLSConfig struct {
7172
Secret string `json:"secret"`
72-
Namespace string `json:"namespace"`
73+
Namespace string `json:"namespace,omitempty"`
7374
}
7475

7576
// RequestVars is the vars for http request
@@ -142,6 +143,9 @@ func runHTTP(ctx context.Context, params *DoParams) (*ResponseVars, error) {
142143
req.Trailer = trailer
143144

144145
if params.Params.TLSConfig != nil {
146+
if params.Params.TLSConfig.Namespace == "" {
147+
params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace))
148+
}
145149
if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil {
146150
defaultClient.Transport = tr
147151
}

0 commit comments

Comments
 (0)