Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_automation_schedule - fix time in future validation #5876

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func resourceArmAutomationSchedule() *schema.Resource {
Optional: true,
Computed: true,
DiffSuppressFunc: suppress.RFC3339Time,
ValidateFunc: validate.RFC3339DateInFutureBy(time.Duration(5) * time.Minute),
ValidateFunc: validate.RFC3339Time,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are removing this constraint, could we add the constraint/check into the create/update function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I have added the check into create/update function.

//defaults to now + 7 minutes in create function if not set
},

Expand Down Expand Up @@ -240,6 +240,10 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte
//start time can default to now + 7 (5 could be invalid by the time the API is called)
if v, ok := d.GetOk("start_time"); ok {
t, _ := time.Parse(time.RFC3339, v.(string)) //should be validated by the schema
duration := time.Duration(5) * time.Minute
if time.Until(t) < duration {
return fmt.Errorf("start_time is %q and should be at least %q in the future", t, duration)
}
properties.StartTime = &date.Time{Time: t}
} else {
properties.StartTime = &date.Time{Time: time.Now().Add(time.Duration(7) * time.Minute)}
Expand Down