Skip to content

Commit

Permalink
Merge pull request #15793 from DrFaust92/r/glue_trigger_added_params
Browse files Browse the repository at this point in the history
r/glue_trigger - add support for `security_configuration` and `notification_property` for `actions` + refactor tests and waiters
  • Loading branch information
breathingdust authored Nov 4, 2020
2 parents a795eca + 1a2c717 commit 6585b98
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 149 deletions.
24 changes: 23 additions & 1 deletion aws/internal/service/glue/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

const (
MLTransformStatusUnknown = "Unknown"
TriggerStatusUnknown = "Unknown"
)

// MLTransformStatus fetches the Operation and its Status
// MLTransformStatus fetches the MLTransform and its Status
func MLTransformStatus(conn *glue.Glue, transformId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &glue.GetMLTransformInput{
Expand All @@ -30,3 +31,24 @@ func MLTransformStatus(conn *glue.Glue, transformId string) resource.StateRefres
return output, aws.StringValue(output.Status), nil
}
}

// TriggerStatus fetches the Trigger and its Status
func TriggerStatus(conn *glue.Glue, triggerName string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &glue.GetTriggerInput{
Name: aws.String(triggerName),
}

output, err := conn.GetTrigger(input)

if err != nil {
return nil, TriggerStatusUnknown, err
}

if output == nil {
return output, TriggerStatusUnknown, nil
}

return output, aws.StringValue(output.Trigger.State), nil
}
}
48 changes: 46 additions & 2 deletions aws/internal/service/glue/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
)

const (
// Maximum amount of time to wait for an Operation to return Success
// Maximum amount of time to wait for an Operation to return Deleted
MLTransformDeleteTimeout = 2 * time.Minute
TriggerCreateTimeout = 2 * time.Minute
TriggerDeleteTimeout = 2 * time.Minute
)

// MLTransformDeleted waits for an Operation to return Success
// MLTransformDeleted waits for an MLTransform to return Deleted
func MLTransformDeleted(conn *glue.Glue, transformId string) (*glue.GetMLTransformOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{glue.TransformStatusTypeNotReady, glue.TransformStatusTypeReady, glue.TransformStatusTypeDeleting},
Expand All @@ -29,3 +31,45 @@ func MLTransformDeleted(conn *glue.Glue, transformId string) (*glue.GetMLTransfo

return nil, err
}

// TriggerCreated waits for a Trigger to return Created
func TriggerCreated(conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
glue.TriggerStateActivating,
glue.TriggerStateCreating,
},
Target: []string{
glue.TriggerStateActivated,
glue.TriggerStateCreated,
},
Refresh: TriggerStatus(conn, triggerName),
Timeout: TriggerCreateTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*glue.GetTriggerOutput); ok {
return output, err
}

return nil, err
}

// TriggerDeleted waits for a Trigger to return Deleted
func TriggerDeleted(conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{glue.TriggerStateDeleting},
Target: []string{},
Refresh: TriggerStatus(conn, triggerName),
Timeout: TriggerDeleteTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*glue.GetTriggerOutput); ok {
return output, err
}

return nil, err
}
Loading

0 comments on commit 6585b98

Please sign in to comment.