-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
resource/container_group: add registry credential #1529
resource/container_group: add registry credential #1529
Conversation
dd3f7dd
to
eb822f3
Compare
eb822f3
to
af8f84b
Compare
Hi @lawrencegripper, Regardless thank you for your contribution! As #1509 was just pulling some old commits out of the repo and lacks documentation/tests I am going to close it in favour of yours. I will review it shortly. |
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've left a few inline comments but otherwise this mostly LGTM! Look forward to getting this merged once they are addressed.
@@ -277,6 +309,10 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err | |||
} | |||
flattenAndSetTags(d, resp.Tags) | |||
|
|||
if imageRegCreds := flattenContainerImageRegistryCredentials(d, resp.ImageRegistryCredentials); imageRegCreds != nil { | |||
d.Set("image_registry_credential", imageRegCreds) |
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.
Could we check for an error here? like:
if err := d.Set("capabilities", flattenAzureRmCosmosDBAccountCapabilities(resp.Capabilities)); err != nil {
return fmt.Errorf("Error setting `capabilities`: %+v", err)
}
d.Set()
sill handle a nil value correctly
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, make sense I'll fix this up
password := credConfig["password"].(string) | ||
|
||
output = append(output, containerinstance.ImageRegistryCredential{ | ||
Server: &server, |
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.
Very minor but these could be assigned inline via utils.String()
Server: utils.String(credConfig["username"].(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.
Ah much nicer, I thought about bringing in the to
package from Autorest as has lots of these funcs too didn't realize you already had one.
credConfig["username"] = *cred.Username | ||
} | ||
|
||
for i, configsOld := range configsOld { |
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'm not sure, but i presume the ordering is consistent so you could get the old values this way:
for i, oldIrcConfig := range ircConfigsOld {
...
if v, ok := d.GetOk(fmt.Sprintf("image_registry_credential.%d.password", i)); ok {
block["password"] = v.(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.
I'm a little uncertain on this one so was being careful. Does the ordering of elements relate to the ordering of the elements in HCL? So for example if the user update the password
element in their template but also moved the credential block ahead of another existing block would that affect this approach (making sure the server name matches)? Feels like an edge case either way round.
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.
Yes, the order of the list directly relates to the order of the elements in HCL. So if the user does as you describe, the Apply would be sending a new list anyways, and the subsequent read would be post Update. unless azure returns things in a different order I think it should be fine. You could always write a test to confirm 🙂
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.
Cool, makes sense to me. Will also check with the test just to be on the safe side.
image = "microsoft/aci-helloworld:latest" | ||
cpu = "0.5" | ||
memory = "0.5" | ||
port = "80" |
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.
could we fix the alignment here?
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.
Woop will do
087eaff
to
06aa604
Compare
Tests look good and hopefully all feedback is sorted.
|
func TestAccAzureRMContainerGroup_linuxBasic(t *testing.T) { | ||
resourceName := "azurerm_container_group.test" | ||
ri := acctest.RandInt() | ||
|
||
config := testAccAzureRMContainerGroup_linuxBasic(ri, testLocation()) | ||
config := testAccAzureRMContainerGroup_imageRegistryCredentials(ri, testLocation()) |
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.
the tests are failing since this has been updated but the counts are incorrect; going to push a test to revert this to TestAccAzureRMContainerGroup_linuxBasic
Tests pass: ``` $ acctests azurerm TestAccAzureRMContainerGroup_linuxBasic === RUN TestAccAzureRMContainerGroup_linuxBasic --- PASS: TestAccAzureRMContainerGroup_linuxBasic (86.67s) === RUN TestAccAzureRMContainerGroup_linuxBasicUpdate --- PASS: TestAccAzureRMContainerGroup_linuxBasicUpdate (107.92s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 194.641s ```
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.
LGTM - thanks for this 👍
Thanks @tombuildsstuff, sorry for messing up the linuxBasic tests was only running the new tests I'd added so I missed it - will remember to run all tests in future. |
@lawrencegripper no worries - easily done, thanks again for this PR :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
When I noticed this feature was missing I checked the issues and didn't see anything so set about working on it. When I came to raise the PR I noticed that #1509 was already in progress.
As I'd already included docs, test and an example (not in the current PR work) I thought it's still worth raising this PR as these can be merged into the existing PR and don't go to waste.
cc/ @tharvik and @katbyte
Ps. will check open PR's next time :(