-
Notifications
You must be signed in to change notification settings - Fork 669
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
Added expiration date field to ibm_kms_key resource #1967
Conversation
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.
Since expiration_date is a date field, the Default value has to be a default date or as a null. Setting a string value is not necessary. You can check if any default value is set in KMK or set this a null
So the default value is null but we cannot assign a string as null. The word Default is just a placeholder. Later in the code I have handled it and am sending a null value if 'Default' is not set to any date. |
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.
Add the argument in doc
website/docs/r/kms_key.html.markdown
ibm/resource_ibm_kms_key.go
Outdated
Optional: true, | ||
Description: "The date the key material expires. The date format follows RFC 3339. You can set an expiration date on any key on its creation. A key moves into the Deactivated state within one hour past its expiration date, if one is assigned. If you create a key without specifying an expiration date, the key does not expire", | ||
ForceNew: true, | ||
Default: "Default", |
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.
Don't set any Default value....since the API doesn't have any Default value
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.
Ok. Will do so.
ibm/resource_ibm_kms_key.go
Outdated
@@ -185,13 +192,23 @@ func resourceIBMKmsKeyCreate(d *schema.ResourceData, meta interface{}) error { | |||
kpAPI.Config.InstanceID = instanceID | |||
name := d.Get("key_name").(string) | |||
standardKey := d.Get("standard_key").(bool) | |||
|
|||
expiration_string := d.Get("expiration_date").(string) |
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.
For optional fields use d.GetOk()
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.
Ok
ibm/resource_ibm_kms_key.go
Outdated
expiration_string := d.Get("expiration_date").(string) | ||
var expiration_time time.Time | ||
expiration := &expiration_time | ||
if expiration_string != "Default" { |
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.
So all these logic can be moved loop d.GetOk("XXXXX");ok {
}
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.
Sure that would be cleaner.
ibm/resource_ibm_kms_key_test.go
Outdated
@@ -125,7 +137,7 @@ func testAccCheckIBMKmsResourceRootkeyWithCOSConfig(instanceName, KeyName, cosIn | |||
key_protect = ibm_kms_key.test.id | |||
} | |||
|
|||
`, instanceName, KeyName, cosInstanceName, bucketName) | |||
`, instanceName, KeyName, expirationdate, cosInstanceName, bucketName) | |||
} |
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.
Don't change all existing testcase because we are missing the flow of expiration nil
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.
Which ones should I revert?
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.
Or would I need to write my own test cases?
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.
Let the old testcase remain same..write a new testcase
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.
Ok.
Description : Added expiration date functionality to key creation in ibm_kms_key and made appropriate changes in test file for testing.