feat(go-sdk): expose user data (#1107)

This commit is contained in:
abelanger5
2024-12-12 20:41:37 -05:00
committed by GitHub
parent 279f68c3a4
commit 3d616c42b1
4 changed files with 27 additions and 5 deletions
+7
View File
@@ -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,
+9 -5
View File
@@ -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"`
+7
View File
@@ -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
}
+4
View File
@@ -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
}