Skip to content

Commit

Permalink
v0.0.21 - Set DateCreated from state on update
Browse files Browse the repository at this point in the history
  • Loading branch information
evanverneyfink committed Oct 12, 2022
1 parent 2dbc245 commit 0467a25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mcma/resource_job_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ func resourceJobProfileUpdate(ctx context.Context, d *schema.ResourceData, m int
jobProfile := getJobProfileFromResourceData(d)
jobProfile.Id = d.Id()

if dc, err := time.Parse(time.RFC3339, d.Get("date_created").(string)); err == nil {
jobProfile.DateCreated = dc
} else {
jobProfile.DateCreated = time.Now().UTC()
}

_, err := resourceManager.Update(jobProfile)
if err != nil {
return diag.FromErr(err)
Expand Down
6 changes: 6 additions & 0 deletions mcma/resource_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, m interf
service := getServiceFromResourceData(d)
service.Id = d.Id()

if dc, err := time.Parse(time.RFC3339, d.Get("date_created").(string)); err == nil {
service.DateCreated = dc
} else {
service.DateCreated = time.Now().UTC()
}

_, err := resourceManager.Update(service)
if err != nil {
return diag.FromErr(err)
Expand Down

0 comments on commit 0467a25

Please sign in to comment.