Skip to content

Commit

Permalink
Fix UserTask deterministic name for DiscoverEC2 issues (#50051)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis authored Dec 12, 2024
1 parent d027987 commit da6dfdc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions api/types/usertasks/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ func WithExpiration(t time.Time) func(ut *usertasksv1.UserTask) {
// NewDiscoverEC2UserTask creates a new DiscoverEC2 User Task Type.
func NewDiscoverEC2UserTask(spec *usertasksv1.UserTaskSpec, opts ...UserTaskOption) (*usertasksv1.UserTask, error) {
taskName := TaskNameForDiscoverEC2(TaskNameForDiscoverEC2Parts{
Integration: spec.GetIntegration(),
IssueType: spec.GetIssueType(),
AccountID: spec.GetDiscoverEc2().GetAccountId(),
Region: spec.GetDiscoverEc2().GetRegion(),
Integration: spec.GetIntegration(),
IssueType: spec.GetIssueType(),
AccountID: spec.GetDiscoverEc2().GetAccountId(),
Region: spec.GetDiscoverEc2().GetRegion(),
SSMDocument: spec.GetDiscoverEc2().GetSsmDocument(),
InstallerScript: spec.GetDiscoverEc2().GetInstallerScript(),
})

ut := &usertasksv1.UserTask{
Expand Down Expand Up @@ -172,10 +174,12 @@ func validateDiscoverEC2TaskType(ut *usertasksv1.UserTask) error {
}

expectedTaskName := TaskNameForDiscoverEC2(TaskNameForDiscoverEC2Parts{
Integration: ut.Spec.Integration,
IssueType: ut.Spec.IssueType,
AccountID: ut.Spec.DiscoverEc2.AccountId,
Region: ut.Spec.DiscoverEc2.Region,
Integration: ut.Spec.Integration,
IssueType: ut.Spec.IssueType,
AccountID: ut.Spec.DiscoverEc2.AccountId,
Region: ut.Spec.DiscoverEc2.Region,
SSMDocument: ut.Spec.DiscoverEc2.SsmDocument,
InstallerScript: ut.Spec.DiscoverEc2.InstallerScript,
})
if ut.Metadata.GetName() != expectedTaskName {
return trace.BadParameter("task name is pre-defined for discover-ec2 types, expected %q, got %q",
Expand Down

0 comments on commit da6dfdc

Please sign in to comment.