// WithChangeSet allows a changeset to be set
194933
func WithChangeSet(cs *source.ChangeSet) source.Option {
	return func(o *source.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, changeSetKey{}, cs)
	}
}
69741
func (s *ChangeBatch) SetChanges(v []*Change) *ChangeBatch {
	s.Changes = v
	return s
}
332546
func (ui *UI) DisplayChangesForPush(changeSet []Change) error {
	if len(changeSet) == 0 {
		return nil
	}

	var columnWidth int
	for _, change := range changeSet {
		if width := wordSize(ui.TranslateText(change.Header)); width > columnWidth {
			columnWidth = width
		}
	}

	for _, change := range changeSet {
		padding := columnWidth - wordSize(ui.TranslateText(change.Header)) + 3
		err := ui.DisplayChangeForPush(change.Header, padding, change.HiddenValue, change.CurrentValue, change.NewValue)
		if err != nil {
			return err
		}
	}

	return nil
}
1097473
func (wi WorkItem) ChangeSet(older change.Detector) (change.Set, error) {
	if older == nil {
		// this is changeset for a new ChangeDetector, report all observed attributes to
		// the change set. This needs extension once we support more attributes.
		changeSet := change.Set{
			{
				AttributeName: SystemState,
				NewValue:      wi.Fields[SystemState],
				OldValue:      nil,
			},
		}
		if wi.Fields[SystemBoardcolumns] != nil && len(wi.Fields[SystemBoardcolumns].([]interface{})) != 0 {
			changeSet = append(changeSet, change.Change{
				AttributeName: SystemBoardcolumns,
				NewValue:      wi.Fields[SystemBoardcolumns],
				OldValue:      nil,
			})
		}
		return changeSet, nil
	}
	olderWorkItem, ok := older.(WorkItem)
	if !ok {
		return nil, errs.New("Other entity is not a WorkItem: " + reflect.TypeOf(older).String())
	}
	if wi.ID != olderWorkItem.ID {
		return nil, errs.New("Other entity has not the same ID: " + olderWorkItem.ID.String())
	}
	changes := []change.Change{}
	// CAUTION: we're only supporting changes to the system.state and to the
	// board position relationship for now. If we need to support more
	// attribute changes, this has to be added here. This will be likely
	// necessary when adding new Actions.
	// compare system.state
	if wi.Fields[SystemState] != olderWorkItem.Fields[SystemState] {
		changes = append(changes, change.Change{
			AttributeName: SystemState,
			NewValue:      wi.Fields[SystemState],
			OldValue:      olderWorkItem.Fields[SystemState],
		})
	}
	// compare system.boardcolumns
	// this field looks like this:
	// system.boardcolumns": ["43f9e838-3b4b-45e8-85eb-dd402e8324b5", "69699af8-cb28-4b90-b829-24c1aad12797"]
	if wi.Fields[SystemBoardcolumns] == nil && olderWorkItem.Fields[SystemBoardcolumns] == nil {
		return changes, nil
	}
	if wi.Fields[SystemBoardcolumns] == nil || olderWorkItem.Fields[SystemBoardcolumns] == nil {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	if len(wi.Fields[SystemBoardcolumns].([]interface{})) == 0 || len(olderWorkItem.Fields[SystemBoardcolumns].([]interface{})) == 0 {
		if len(wi.Fields[SystemBoardcolumns].([]interface{})) == 0 && len(olderWorkItem.Fields[SystemBoardcolumns].([]interface{})) == 0 {
			// both lists are empty, return no change.
			return changes, nil
		}
		// one of the lists is empty, do return a change.
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	bcThis, ok1 := wi.Fields[SystemBoardcolumns].([]interface{})
	bcOlder, ok2 := olderWorkItem.Fields[SystemBoardcolumns].([]interface{})
	if !ok1 || !ok2 {
		return nil, errs.New("Boardcolumn slice is not a interface{} slice")
	}
	if len(bcThis) != len(bcOlder) {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	// because of the handing of interface{}, we need to do manual conversion here.
	thisCopyStr := make([]string, len(bcThis))
	for i := range bcThis {
		thisCopyStr[i], ok = bcThis[i].(string)
		if !ok {
			return nil, errs.New("Boardcolumn slice values are not of type string")
		}
	}
	olderCopyStr := make([]string, len(bcOlder))
	for i := range bcOlder {
		olderCopyStr[i], ok = bcOlder[i].(string)
		if !ok {
			return nil, errs.New("Boardcolumn slice values are not of type string")
		}
	}
	sort.Strings(thisCopyStr)
	sort.Strings(olderCopyStr)
	if !reflect.DeepEqual(thisCopyStr, olderCopyStr) {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	return changes, nil
}
243498
func (s *CreateSqlInjectionMatchSetOutput) SetChangeToken(v string) *CreateSqlInjectionMatchSetOutput {
	s.ChangeToken = &v
	return s
}
787066
func (s *CreateByteMatchSetInput) SetChangeToken(v string) *CreateByteMatchSetInput {
	s.ChangeToken = &v
	return s
}
20920
func (s *DeleteIPSetOutput) SetChangeToken(v string) *DeleteIPSetOutput {
	s.ChangeToken = &v
	return s
}
571487
func (s *DeleteXssMatchSetOutput) SetChangeToken(v string) *DeleteXssMatchSetOutput {
	s.ChangeToken = &v
	return s
}
1063570
func (s *DeleteRegexMatchSetInput) SetChangeToken(v string) *DeleteRegexMatchSetInput {
	s.ChangeToken = &v
	return s
}
695000
func (s *DeleteByteMatchSetInput) SetChangeToken(v string) *DeleteByteMatchSetInput {
	s.ChangeToken = &v
	return s
}
538168
func (s *DescribeChangeSetInput) SetChangeSetName(v string) *DescribeChangeSetInput {
	s.ChangeSetName = &v
	return s
}
1165273
func (s *DeleteSizeConstraintSetInput) SetChangeToken(v string) *DeleteSizeConstraintSetInput {
	s.ChangeToken = &v
	return s
}
695602
func (s *UpdateSizeConstraintSetOutput) SetChangeToken(v string) *UpdateSizeConstraintSetOutput {
	s.ChangeToken = &v
	return s
}
731810
func (s *AssessmentRunStateChange) SetStateChangedAt(v time.Time) *AssessmentRunStateChange {
	s.StateChangedAt = &v
	return s
}
331856
func DeleteChangeSet(stackName string,
	changeSetRequestName string,
	awsCloudFormation *cloudformation.CloudFormation) (*cloudformation.DeleteChangeSetOutput, error) {

	// Delete request...
	deleteChangeSetInput := cloudformation.DeleteChangeSetInput{
		ChangeSetName: aws.String(changeSetRequestName),
		StackName:     aws.String(stackName),
	}

	startTime := time.Now()
	for {
		elapsedTime := time.Since(startTime)

		deleteChangeSetResults, deleteChangeSetResultErr := awsCloudFormation.DeleteChangeSet(&deleteChangeSetInput)
		if nil == deleteChangeSetResultErr {
			return deleteChangeSetResults, nil
		} else if strings.Contains(deleteChangeSetResultErr.Error(), "CREATE_IN_PROGRESS") {
			if elapsedTime > cloudformationPollingTimeout {
				return nil, fmt.Errorf("failed to delete ChangeSet within timeout window: %s", elapsedTime.String())
			}
			sleepDuration := cloudformationPollingDelay()
			time.Sleep(sleepDuration)
		} else {
			return nil, deleteChangeSetResultErr
		}
	}
}
1127313
func (s *DeleteGeoMatchSetInput) SetChangeToken(v string) *DeleteGeoMatchSetInput {
	s.ChangeToken = &v
	return s
}
1322773
func (s *CreateRegexPatternSetOutput) SetChangeToken(v string) *CreateRegexPatternSetOutput {
	s.ChangeToken = &v
	return s
}