mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-02 07:29:59 -05:00
feat(go-sdk): expose user data (#1107)
This commit is contained in:
@@ -506,11 +506,18 @@ func (a *adminClientImpl) getJobOpts(jobName string, job *types.WorkflowJob) (*a
|
||||
return nil, fmt.Errorf("could not marshal step inputs: %w", err)
|
||||
}
|
||||
|
||||
userDataBytes, err := json.Marshal(step.UserData)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not marshal step user data: %w", err)
|
||||
}
|
||||
|
||||
stepOpt := &admincontracts.CreateWorkflowStepOpts{
|
||||
ReadableId: step.ID,
|
||||
Action: step.ActionID,
|
||||
Timeout: step.Timeout,
|
||||
Inputs: string(inputBytes),
|
||||
UserData: string(userDataBytes),
|
||||
Parents: step.Parents,
|
||||
Retries: int32(step.Retries), // nolint: gosec
|
||||
BackoffFactor: step.RetryBackoffFactor,
|
||||
|
||||
@@ -108,11 +108,15 @@ type DesiredWorkerLabel struct {
|
||||
}
|
||||
|
||||
type WorkflowStep struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
ID string `yaml:"id,omitempty"`
|
||||
ActionID string `yaml:"action"`
|
||||
Timeout string `yaml:"timeout,omitempty"`
|
||||
With map[string]interface{} `yaml:"with,omitempty"`
|
||||
Name string `yaml:"name,omitempty"`
|
||||
ID string `yaml:"id,omitempty"`
|
||||
ActionID string `yaml:"action"`
|
||||
Timeout string `yaml:"timeout,omitempty"`
|
||||
|
||||
// Deprecated: this field has no effect and will be removed in a future release.
|
||||
With map[string]interface{} `yaml:"with,omitempty"`
|
||||
|
||||
UserData map[string]interface{} `yaml:"userData,omitempty"`
|
||||
Parents []string `yaml:"parents,omitempty"`
|
||||
Retries int `yaml:"retries"`
|
||||
RateLimits []RateLimit `yaml:"rateLimits,omitempty"`
|
||||
|
||||
@@ -41,6 +41,8 @@ type HatchetContext interface {
|
||||
|
||||
WorkflowInput(target interface{}) error
|
||||
|
||||
UserData(target interface{}) error
|
||||
|
||||
AdditionalMetadata() map[string]string
|
||||
|
||||
StepName() string
|
||||
@@ -91,6 +93,7 @@ type StepRunData struct {
|
||||
TriggeredBy TriggeredBy `json:"triggered_by"`
|
||||
Parents map[string]StepData `json:"parents"`
|
||||
AdditionalMetadata map[string]string `json:"additional_metadata"`
|
||||
UserData map[string]interface{} `json:"user_data"`
|
||||
}
|
||||
|
||||
type StepData map[string]interface{}
|
||||
@@ -189,6 +192,10 @@ func (h *hatchetContext) WorkflowInput(target interface{}) error {
|
||||
return toTarget(h.stepData.Input, target)
|
||||
}
|
||||
|
||||
func (h *hatchetContext) UserData(target interface{}) error {
|
||||
return toTarget(h.stepData.UserData, target)
|
||||
}
|
||||
|
||||
func (h *hatchetContext) AdditionalMetadata() map[string]string {
|
||||
return h.stepData.AdditionalMetadata
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ func (c *testHatchetContext) WorkflowInput(target interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *testHatchetContext) UserData(target interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *testHatchetContext) AdditionalMetadata() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user