Skip to content

Commit

Permalink
Fix: fix context in provider (#194)
Browse files Browse the repository at this point in the history
fix: fix context in provider

Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong authored Aug 16, 2024
1 parent 94c9275 commit 76db4ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/providers/http/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// +usgae=The tls config of the request
tls_config?: {
secret: string
namespace: context.namespace
namespace?: string
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/legacy/http/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
6 changes: 5 additions & 1 deletion pkg/providers/legacy/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 76db4ac

Please sign in to comment.