Skip to content

Commit

Permalink
Fix: fix the usage of http client and run crd (#93)
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>

Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong committed Jan 3, 2023
1 parent dd7a3c0 commit bca032d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ type WorkflowRunStatus struct {

// WorkflowSpec defines workflow steps and other attributes
type WorkflowSpec struct {
Mode *WorkflowExecuteMode `json:"mode,omitempty"`
Steps []WorkflowStep `json:"steps,omitempty"`
Steps []WorkflowStep `json:"steps,omitempty"`
}

// WorkflowExecuteMode defines the mode of workflow execution
Expand Down Expand Up @@ -144,6 +143,7 @@ type Workflow struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Mode *WorkflowExecuteMode `json:"mode,omitempty"`
WorkflowSpec `json:",inline"`
}

Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions charts/vela-workflow/crds/core.oam.dev_workflowruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ spec:
workflowSpec:
description: WorkflowSpec defines workflow steps and other attributes
properties:
mode:
description: WorkflowExecuteMode defines the mode of workflow
execution
properties:
steps:
description: Steps is the mode of workflow steps execution
type: string
subSteps:
description: SubSteps is the mode of workflow sub steps execution
type: string
type: object
steps:
items:
description: WorkflowStep defines how to execute a workflow
Expand Down
6 changes: 3 additions & 3 deletions controllers/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ var _ = Describe("Test Workflow", func() {
Name: "workflow",
Namespace: namespace,
},
Mode: &v1alpha1.WorkflowExecuteMode{
Steps: v1alpha1.WorkflowModeDAG,
},
WorkflowSpec: v1alpha1.WorkflowSpec{
Mode: &v1alpha1.WorkflowExecuteMode{
Steps: v1alpha1.WorkflowModeDAG,
},
Steps: []v1alpha1.WorkflowStep{
{
WorkflowStepBase: v1alpha1.WorkflowStepBase{
Expand Down
17 changes: 5 additions & 12 deletions pkg/providers/http/do.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,11 @@ const (
)

var (
defaultClient *http.Client
rateLimiter *ratelimiter.RateLimiter
rateLimiter *ratelimiter.RateLimiter
)

func init() {
rateLimiter = ratelimiter.NewRateLimiter(128)
defaultClient = &http.Client{
Transport: http.DefaultTransport,
Timeout: time.Second * 3,
}
}

type provider struct {
Expand All @@ -79,7 +74,10 @@ func (h *provider) runHTTP(ctx monitorContext.Context, v *value.Value) (interfac
header, trailer http.Header
r io.Reader
)
initDefaultClient(defaultClient)
defaultClient := &http.Client{
Transport: http.DefaultTransport,
Timeout: time.Second * 3,
}
if timeout, err := v.GetString("request", "timeout"); err == nil && timeout != "" {
duration, err := time.ParseDuration(timeout)
if err != nil {
Expand Down Expand Up @@ -212,11 +210,6 @@ func (h *provider) getTransport(ctx monitorContext.Context, v *value.Value) (htt
return tr, nil
}

func initDefaultClient(c *http.Client) {
c.Transport = http.DefaultTransport
c.Timeout = time.Second * 3
}

func parseHeaders(obj cue.Value, label string) (http.Header, error) {
m := obj.LookupPath(value.FieldPath("request", label))
if !m.Exists() {
Expand Down

0 comments on commit bca032d

Please sign in to comment.