-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add check for revoked iterations to HCP Packer datasources #240
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package provider | |
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
|
@@ -98,13 +99,18 @@ func dataSourcePackerIterationRead(ctx context.Context, d *schema.ResourceData, | |
return diag.FromErr(err) | ||
} | ||
|
||
if channel.Pointer == nil { | ||
if channel.Iteration == nil { | ||
return diag.Errorf("no iteration information found for the specified channel %s", channelSlug) | ||
} | ||
|
||
iteration := channel.Pointer.Iteration | ||
iteration := channel.Iteration | ||
if !time.Time(iteration.RevokeAt).IsZero() { | ||
// If RevokeAt is not a zero date, it means this iteration is revoked and should not be used | ||
// to build new images. | ||
return diag.Errorf("the iteration %s is revoked and can not be used", iteration.ID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we advise the user what to do/change when they run into this error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can, I will try to think of a better text! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! I also improved some of the tests |
||
} | ||
|
||
d.SetId(channel.Pointer.Iteration.ID) | ||
d.SetId(iteration.ID) | ||
|
||
if err := d.Set("author_id", iteration.AuthorID); err != nil { | ||
return diag.FromErr(err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to get some network updates into the go SDK, so I'll try to release 0.16.0 with your changes tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! So I'll wait for the release to update this one with 0.16.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/hashicorp/hcp-sdk-go/releases/tag/v0.16.0 ✨