Skip to content

Commit

Permalink
Updated SSM Association
Browse files Browse the repository at this point in the history
  • Loading branch information
nvnyale committed May 17, 2022
1 parent f8c75ee commit f67007e
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,27 +693,37 @@ type AssociationTarget struct {

func toSSMAssociationDescription(rawDesc *ssm.DescribeAssociationOutput) *AssociationDescription {
const dateLayout = "2006-01-02 15:04:05 +0000"
formatDate := func(t *time.Time) string {
if t != nil {
return t.Format(dateLayout)
}
return ""
}
var status AssociationStatus
if rawDesc.AssociationDescription.Status != nil {
status.Date = formatDate(rawDesc.AssociationDescription.Status.Date)
status.Name = aws.StringValue(rawDesc.AssociationDescription.Status.Name)
status.Message = aws.StringValue(rawDesc.AssociationDescription.Status.Message)
}
var overview AssociationOverview
if rawDesc.AssociationDescription.Overview != nil {
overview.Status = aws.StringValue(rawDesc.AssociationDescription.Overview.Status)
overview.DetailedStatus = aws.StringValue(rawDesc.AssociationDescription.Overview.DetailedStatus)
}

return &AssociationDescription{
Name: aws.StringValue(rawDesc.AssociationDescription.Name),
InstanceId: aws.StringValue(rawDesc.AssociationDescription.InstanceId),
AssociationVersion: aws.StringValue(rawDesc.AssociationDescription.AssociationVersion),
Date: rawDesc.AssociationDescription.Date.Format(dateLayout),
LastUpdateAssociationDate: rawDesc.AssociationDescription.LastUpdateAssociationDate.Format(dateLayout),
Status: AssociationStatus{
Date: rawDesc.AssociationDescription.Status.Date.Format(dateLayout),
Name: aws.StringValue(rawDesc.AssociationDescription.Status.Name),
Message: aws.StringValue(rawDesc.AssociationDescription.Status.Message),
},
Overview: AssociationOverview{
Status: aws.StringValue(rawDesc.AssociationDescription.Overview.Status),
DetailedStatus: aws.StringValue(rawDesc.AssociationDescription.Overview.DetailedStatus),
},
Name: aws.StringValue(rawDesc.AssociationDescription.Name),
InstanceId: aws.StringValue(rawDesc.AssociationDescription.InstanceId),
AssociationVersion: aws.StringValue(rawDesc.AssociationDescription.AssociationVersion),
Date: formatDate(rawDesc.AssociationDescription.Date),
LastUpdateAssociationDate: formatDate(rawDesc.AssociationDescription.LastUpdateAssociationDate),
Status: status,
Overview: overview,
DocumentVersion: aws.StringValue(rawDesc.AssociationDescription.DocumentVersion),
AssociationId: aws.StringValue(rawDesc.AssociationDescription.AssociationId),
Targets: parseAssociationTargets(rawDesc.AssociationDescription.Targets),
LastExecutionDate: rawDesc.AssociationDescription.LastExecutionDate.Format(dateLayout),
LastSuccessfulExecutionDate: rawDesc.AssociationDescription.LastSuccessfulExecutionDate.Format(dateLayout),
LastExecutionDate: formatDate(rawDesc.AssociationDescription.LastExecutionDate),
LastSuccessfulExecutionDate: formatDate(rawDesc.AssociationDescription.LastSuccessfulExecutionDate),
ApplyOnlyAtCronInterval: aws.BoolValue(rawDesc.AssociationDescription.ApplyOnlyAtCronInterval),
}
}
Expand Down

0 comments on commit f67007e

Please sign in to comment.