-
Notifications
You must be signed in to change notification settings - Fork 545
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
Make policies importable. #15
Conversation
This makes policies importable. Minor changes were needed for this: * Read now sets name, in addition to policy. * We added the Importer functionality and a test for it. * Our test config needed to be updated to allow the policy name to be injected, to help ensure uniqueness across runs.
Test failure is an acctest vendoring failure. Should be resolved by #12. |
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.
Question about when we set the name
) | ||
|
||
func TestAccPolicy_importBasic(t *testing.T) { | ||
name := "test-" + acctest.RandString(10) |
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.
There's also RandomWithPrefix, if integers are valid in the name.
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.
TIL! Thanks :)
@@ -77,6 +80,7 @@ func policyRead(d *schema.ResourceData, meta interface{}) error { | |||
} | |||
|
|||
d.Set("policy", policy) | |||
d.Set("name", name) |
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.
Should we set this in the CREATE
method, policyWrite
? Right now, policyWrite
does not call policyRead
, so the name
attribute won't be set until a refresh
operation happens.
Normally we call create
and it returns read
. If that's not necessary here, I recommend we set name
in policyWrite
then.
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.
Good call, I missed that wasn't happening here. Updated to now call policyRead
from policyWrite
.
Make sure to read the new policy values out of vault after updating.
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.
👍
…_policy Make policies importable.
This makes policies importable. Minor changes were needed for this:
injected, to help ensure uniqueness across runs.