Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fix context in provider #194

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 @@
req.Trailer = trailer

if params.Params.TLSConfig != nil {
if params.Params.TLSConfig.Namespace == "" {
params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace))

Check warning on line 150 in pkg/providers/http/http.go

View check run for this annotation

Codecov / codecov/patch

pkg/providers/http/http.go#L150

Added line #L150 was not covered by tests
}
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 @@

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 @@
// 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 @@
req.Trailer = trailer

if params.Params.TLSConfig != nil {
if params.Params.TLSConfig.Namespace == "" {
params.Params.TLSConfig.Namespace = fmt.Sprint(params.ProcessContext.GetData(model.ContextNamespace))

Check warning on line 147 in pkg/providers/legacy/http/http.go

View check run for this annotation

Codecov / codecov/patch

pkg/providers/legacy/http/http.go#L147

Added line #L147 was not covered by tests
}
if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil {
defaultClient.Transport = tr
}
Expand Down
Loading